Vizard 8 » Tutorials & Examples » Appearance & texturing » Multitexturing » Tutorial: Real-time adjustments
8.0

Tutorial: Real-time adjustments

Next, let's add a slider that will allow the user to control how much to blend between the textures. The following code will add a slider and place it at the bottom of the screen:

slider = viz.addSlider()
slider.setPosition(0.5,0.1)

All we have to do now is register a function that is called when the slider event occurs and within that function, change the parameter of the blend program.  This is done using vizact.onslider().

def blendTextures(pos):
    blend.setProperty('BlendAmount', pos)

vizact.onslider(slider, blendTextures)

When the slider object is moved we set the blend amount to the position of the slider, which goes from 0 to 1.  So, when the slider is at the very right edge, the value will be 1, which means 0% of texture 1 will be blended with 100% of texture 2. Run your script and move the slider back and forth to see the textures blending in real time. Multi-texturing can be used to create many interesting effects, especially when used with the power of shader effects.

Loading multiple textures

Blending the textures

Real-time adjustments