WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 12-03-2015, 05:08 PM
pitbool pitbool is offline
Join Date: Oct 2012
Posts: 31
multitex fragment shader issue for different sized textures


I am trying to blend an algae texture to a sea floor texture. The algae texture file is a 512x512 jpg image. I am retrieving the other texture from our ocean osgb model. This texture is a 1024x1024 baked into the model.

I have tried four ways (see below), but unfortunately, none works!
All are shaders, except for the first.

1. Using texblend - this gives some kind of blending, but it is non-uniform and not upto our expectations.
2. Using the texBlendFP.frag shader - the first texture do not show up at all.
3. Using the custom blend shader from \examples\shader\ - the first texture do not show up at all.
4. Using the code from (Tutorial: Multi-texturing) - strangely, same result as in option 1 above!

I have attached the py file in txt format here.
Any suggestions on how to get this to work?

Thank you!
Attached Files
File Type: txt (3.5 KB, 671 views)
Reply With Quote
Old 12-04-2015, 12:11 PM
Jeff Jeff is offline
WorldViz Team Member
Join Date: Aug 2008
Posts: 2,471
It will be best if you can post example Vizard code that reproduces the issue and can be run directly.
Reply With Quote
Old 12-04-2015, 03:13 PM
pitbool pitbool is offline
Join Date: Oct 2012
Posts: 31
import viz
import vizfx

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

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);


texBlendEffect = viz.addEffect(code)

itemFromTerrain = terrain.getChild('Terrain_Zone03')
oldTex = itemFromTerrain.getTexture()
itemFromTerrain.texture(algaeTexture, '', unit=1)
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 -
Reply With Quote
Old 12-08-2015, 08:22 PM
pitbool pitbool is offline
Join Date: Oct 2012
Posts: 31
Jeff, just letting you know that I was able to solve the problem, with the help of Jorge, a Worldviz 3D artist. The baked texture in the terrain was a blend of two textures and a masked texture. I think he used the "render to texture" feature in 3DS max to export all of it to a single texture, which I used instead of retrieving the texture1 from the terrain at runtime. Then I blended it using the algae texture in the unit 1 of multitexturing.

Thank you.
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
Multiple Textures for Diffuse and Specularity Shader Issue shivanangel Vizard 1 05-11-2009 11:44 AM
Specular Shader Issue shivanangel Vizard 2 05-06-2009 12:08 PM

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

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