Date: Wed, 06 Jun 2007 14:05:28 +0200
From: Ulrich Hertlein <[EMAIL PROTECTED]>
Subject: Re: [osg-users] Asking again about states in shaders,  and
        texturing       issues
To: osg users <[email protected]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1

Guy Lifchitz wrote:
>  suppose I'm loading two osg models, both using textures and both define
> their texture with the same texturing unit, will the system change one of
> texture texturing unit, or every time one of the object is drawn the
> texture will be replaced on the graphic card, or will there be an bug and
both will use

OSG will bind texture A to unit 0 and draw object A.
It will then bind texture B to unit 0 and draw object B.

The texture is not replaced every time.  You have to distinguish between
texture objects (which hold the texel/image data) and the texture unit
that object is currently bound to.  (You could have the same texture
object bound to different texture units at the same time.)

/Ulrich


Thanks for answering.
I looked at the samples.
Please help me verify that I understand correctly the texturing process:
1. The samplers uniforms are only integers for the texture unit.
2. When creating osg::Texture{nD} object the actual glGenTexture
function is called and the object is created on the graphics card.
3. When binding texture to stateset you only state the texture unit.
4. When rendering, the stateset binds the texture object using the id
generated with the osg::Texture object, and bind it to the texture
unit set with for that object in the stateset.

am I right?

suppose I'm right, this is the process without using shaders.
Now lets add the shaders in.
To use the texture in the shader I need to add uniform with the
sampler name I'm using in the shader and set it's value to the texture
unit I gave the stateset with the osg::Texture?

now if all the above is true I still have two questions:
1. to bind 2 texture units to the same texture object I only need to
pass the same pointer of osg::Texture{nD} with two different calls to
StateSet::setTextureAttribute
that has different texture units?
2. I saw in some examples usage of sampler texUnit0 as the sampler of
the texture, but I haven't seen in the C code any reference to that
name, so I thought it might be a built in uniform but I also haven't
seen it in the quick_ref. How does it work?

thanks again,
Guy.
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to