WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

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


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.

Reply With Quote
Old 09-20-2012, 06:03 AM
cade_mccall cade_mccall is offline
Join Date: Sep 2004
Posts: 61
Was it something I said?
Reply With Quote
Old 09-20-2012, 10: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.

import viz

NAME = 'wood_flloor'

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

model = viz.add('gallery.osgb')

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)
blend = viz.addUniformFloat('blend',0.0)

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

import vizact
Reply With Quote
Old 10-12-2012, 06:42 AM
cade_mccall cade_mccall is offline
Join Date: Sep 2004
Posts: 61

Thanks! That did the trick.
Reply With Quote

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 04:53 AM

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

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