View Single Post
  #3  
Old 07-01-2015, 05:51 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
For the first question, you could use a shader to multiply a blend value with the transparent texture and add that to the base texture. Here's an example:

Code:
import viz
viz.go()

viz.addChild('piazza.osgb')

quad = viz.addTexQuad(pos=[0,1.8,5])
texture = viz.addTexture('images/tile_grass.jpg')
texture2 = viz.addTexture('crosshair.png')
quad.texture(texture)
quad.texture(texture2,unit=1)

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

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

import vizact
vizact.onslider(slider,blend.set)
Please create a new thread for the second question for further assistance. The model does not seems to have texture coordinates.
Reply With Quote