WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-03-2012, 02:48 AM
cade_mccall cade_mccall is offline
Member
 
Join Date: Sep 2004
Posts: 61
multitexturing with a lightmap

Hellooooo,

I've made an ive with a lightmap that looks good in Vizard. Now I want use multitexturing so that I can blend between multiple textures. I'm able to add textures to different units, but when I use texblend to blend in a unit above 1, I lose the lightmap (which is in unit 1). So, is there a way to use texblend without losing the lightmap? If possible, I'd like to use the lightmap instead of baking the light onto each of the textures I'm using since I'm using many of them.

Thanks,
Cornelius
Reply With Quote
  #2  
Old 09-20-2012, 07:03 AM
cade_mccall cade_mccall is offline
Member
 
Join Date: Sep 2004
Posts: 61
Was it something I said?
Reply With Quote
  #3  
Old 09-20-2012, 11:37 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Yeah Cornelius, if that's your real name

You can write a simple shader that mixes multiple textures together and combines it with the lightmap. Here is an example that uses the gallery model included with Vizard. It allows you to blend between a wood and slate texture and then adds the existing lightmap onto it. You might have to tweak the texture unit numbers when using this with your model.

Code:
import viz
viz.go()

NAME = 'wood_flloor'

slate = viz.addTexture('images/tile_slate.jpg',wrap=viz.REPEAT)

model = viz.add('gallery.osgb')
model.texture(slate,node=NAME,unit=2)

frag = """
uniform sampler2D map1;
uniform sampler2D map2;
uniform sampler2D lightmap;
uniform float blend;
void main()
{
	vec4 clr1 = texture2D(map1,gl_TexCoord[0].st);
	vec4 clr2 = texture2D(map2,gl_TexCoord[0].st);
	vec4 light = texture2D(lightmap,gl_TexCoord[1].st);
	gl_FragColor = mix(clr1,clr2,blend) * light;
}
"""
shader = viz.addShader(frag=frag)
shader.attach(viz.addUniformInt('map1',0))
shader.attach(viz.addUniformInt('lightmap',1))
shader.attach(viz.addUniformInt('map2',2))
blend = viz.addUniformFloat('blend',0.0)
shader.attach(blend)
model.apply(shader,node=NAME)

slider = viz.addSlider(pos=(0.5,0.1,0))
slider.set(0)

import vizact
vizact.onslider(slider,blend.set)
Reply With Quote
  #4  
Old 10-12-2012, 07:42 AM
cade_mccall cade_mccall is offline
Member
 
Join Date: Sep 2004
Posts: 61
Perfect

Thanks! That did the trick.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Lightmap VRAY davidrichens Vizard 3 03-12-2012 05:53 AM


All times are GMT -7. The time now is 05:17 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC