Hi Sebastian,
Thanks for the detailed explanation and the hints regarding texture/world 
coordinates. I've tried binding at the tile level as you suggested, but 
apparently the additional data source is not fast enough to be used at 
real-time.
At this point, I'm going to have the original terrain model regenerated with 
two textures for each tile, instead of constructing the second texture on the 
fly. As far as I understand, binding a second texture should be possible with 
the OSG and TXP formats.
So thanks again for attempting to help with issue.

Best,
Shahar


Sebastian Messerschmidt wrote:
> You don't really need to bind at a level this deep. Usually if the 
> "terrain tile" is loaded and represent a LOD you want to work with, you 
> can simple add your data texture(s) as uniform to the stateset of the tile.
> Given you have a texture with the data-image called "texture" you can do 
> it this way in your callback:
> 
> osg::StateSet* state_set = node->getOrCreateStateSet();
> osg::Uniform* sampler = new osg::Uniform("MyDataSamper",  2 
> /*texture unit*/);
> 
> state_set->setTextureAttribute(unit, texture ,osg::StateAttribute::ON);
> state_set->addUniform(sampler);
> 
> With this you bind the texture to a sampler for your shader, at the 
> texture unit 2. Depending on how many textures are already bound you 
> might need to modify the unit.
> In the fragment shader you can now access the texture via:
> 
> uniform sampler2D MyDataSampler
> ..
> ..
> 
> main()
> {
> vec2 tex_coord = gl_TexCoord[0].st;
> vec4 data = texture2D(MyDataSampler, tex_coord);
> }
> 


------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=55008#55008





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to