Hi,
you can supply uniforms to the shaders to point to your bounded
textures, e.g.
(this is from the osgmultiplerendertargets example in svn)
in the shader:
uniform sampler2DRect textureID0;
uniform sampler2DRect textureID1;
uniform sampler2DRect textureID2;
uniform sampler2DRect textureID3;
void main(void)
{
gl_FragData[0] =
vec4(texture2DRect( textureID0, gl_TexCoord[0].st).rgb,1) +
vec4(texture2DRect( textureID1, gl_TexCoord[0].st ).rgb, 1) +
vec4(texture2DRect( textureID2, gl_TexCoord[0].st ).rgb, 1) +
-0.5*vec4(texture2DRect( textureID3, gl_TexCoord[0].st ).rgb, 1);
}
in the code:
stateset->addUniform(new osg::Uniform("textureID0", 0));
stateset->addUniform(new osg::Uniform("textureID1", 1));
stateset->addUniform(new osg::Uniform("textureID2", 2));
stateset->addUniform(new osg::Uniform("textureID3", 3));
hope it helps.
jp
Johan Johnsson wrote:
> Hi !
>
>
>
> I am developing a shader and need to have acess to the optional textures
> which is affected by the coordinates in tgl_TexCoord[1].
>
> How do i do this, how do i send the second texture from the ive file
> (the shadow map) into the shader, or how do i reach it in the shader if
> its passed in automatic? should i set something in the stateset of the
> specific node i run the shader on?
>
>
>
> Tnx for advices.
>
>
>
>
>
> // shaders without unreleveant code.
>
> // vertex
>
> void main()
>
> {
>
> gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
>
> gl_TexCoord[1] = gl_TextureMatrix[1] * gl_MultiTexCoord1;
>
> }
>
>
>
> // fragment
>
> void main()
>
> {
>
> vec4 color = texture2D(tex, gl_TexCoord[0].st);
>
> vec4 map = texture2D(tex1, gl_TexCoord[1].st);
>
> }
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
--
This message is subject to the CSIR's copyright terms and conditions, e-mail
legal notice, and implemented Open Document Format (ODF) standard.
The full disclaimer details can be found at
http://www.csir.co.za/disclaimer.html.
This message has been scanned for viruses and dangerous content by MailScanner,
and is believed to be clean. MailScanner thanks Transtec Computers for their
support.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org