View Single Post
  #3  
Old 12-04-2015, 03:13 PM
pitbool pitbool is offline
Member
 
Join Date: Oct 2012
Posts: 31
#
Code:
import viz
import vizfx

terrain = vizfx.addChild('blendTest.OSGB')
viz.go()

viz.MainView.setPosition([58.64860153198242, 0.0, -6.446604251861572])

algaeTexture = viz.addTexture('algae_texture3.jpg', type=viz.TEX_2D, wrap=viz.REPEAT)
# Create shader effect that blends textures and applies to diffuse color
code = """
Effect "Texture Blend" {

Float BlendAmount { value 0 }
Texture2D Texture1 { unit 0 }
Texture2D Texture2 { unit 1 }

Shader {

	BEGIN Material
	m.diffuse = mix( texture2D( Texture1, uvTexture1).rgb, texture2D( Texture2, uvTexture2).rgb, BlendAmount);
	END

}

}
"""
texBlendEffect = viz.addEffect(code)

itemFromTerrain = terrain.getChild('Terrain_Zone03')
oldTex = itemFromTerrain.getTexture()
itemFromTerrain.texture(oldTex)
itemFromTerrain.texture(algaeTexture, '', unit=1)
itemFromTerrain.apply(texBlendEffect)
itemFromTerrain.setUniformFloat('BlendAmount', 0.0)

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

def setBlendAmount2(blendRatioFromSlider):
	global itemFromTerrain
	itemFromTerrain.setUniformFloat('BlendAmount', blendRatioFromSlider)
vizact.onslider(slider, setBlendAmount2)

#

I couldn't find a Vizard resource to recreate this issue, so here is a link to download a zip of my shortest test py file with the terrain osgb and the algae jpg that I am trying to blend - https://stanford.box.com/s/5myna254j...5mkbkfmzdjug28.
Reply With Quote