I am quite interested in the management of the texture units also, since I'm doing work with depthshadows, and I have to take into account that the objects that get shadowed might have textures enabled on them. This becomes even more complicated if I consider adding bump-mapping or normal mapping to some of the objects. Therefore a variable number of texture units can be active.
Currently, osgdepthshadow uses an uniform variable, I think it's called 'unit', to choose between fragment shaders that apply shadow for a textured or untextured object. In this implementation, if the scene uses textures, the depth-map for the shadow is created on texUnit 1, using texUnit 0 for textures; otherwise only texUnit 0 is used for generatig the depth map. Roger, you can look at the code in osgdephshadow.cpp for the code. The parts that I was talking about are in main() and in the shader code. Is there any place to start looking for management of textures and texture units ? I'm not sure if this would be at the viewer level or at the scenegraph level. What would make me very happy would be something that could allow me to manage not just the texture objects within OSG, but also to have the ability to controll where they are stored also, in GPU ram or in system memory. -- Mihai Radu cm-labs.com On Monday 11 September 2006 13:12, Mike Weiblen wrote: > Hi Roger, > > Roger James wrote: > > I apologise in advance for this being somewhat off topic, but this was > > the best place I could think of for a quick answer. > > > > > > Q. In an OpenGL fragment shader program, how do I find out which texture > > units are currently active? > > If by active, you mean they're enabled for fixed-functionality texturing, > then no, there is not a built-in GLSL uniform to query the > fixed-functionality enable state of texture units. > > > The reason I ask this is that I am trying to add a procedural texture to > > part of my scene graph. Other built in functionality texture units may > > well also be active at this point. > > > > Because the fragment shader replaces all the built in texture processing > > I need to know whether to apply these texture within the shader as well. > > Your app will need to convey that information via uniforms. > > > The fragment shader function texture2D seems to return vec4(0,0,0,0) > > when no texture is assigned, but this does not seem to be documented. So > > can I rely on it? > > I would not, unless the Spec clearly defined that behavior. > > Cheers > -- mew > > _______________________________________________ > osg-users mailing list > [email protected] > http://openscenegraph.net/mailman/listinfo/osg-users > http://www.openscenegraph.org/ -- Mihai Radu cm-labs.com _______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
