[osg-users] Can't write to ALPHA component with custom fragment shader in RTT pass

Daniel Holz danielh at cm-labs.com
Mon Mar 9 08:54:32 PDT 2009


Hi,

I just want to make sure that we do not misunderstand each other:
The problem is not to make a fragment invisible (the discard statement 
in fact works for that pretty well) but to simply store normalized data 
([0,1]) as the alpha component of my RGBA texture by using 
gl_FragColor.a = ... . But whatever value I pass in, it is ignored.

In fact I found out that I CAN write to the alpha value IF I use 
texture2D->setInternalFormat(GL_RGBA) but this would give me normalized 
values not just for the alpha component but also for the RGB components 
and that's not what I want. I need 32 bit floats PER component and NOT 
normalized because I want to store world space positions in RGB. That's 
why I decided to use GL_RGBA32F_ARB as internal format.

This decision was motivated by the following behavior of 
osg::Texture2D::setInternalFormat():

In setInternalFormat() the method computeInternalFormatType() is called 
which sets the "internal format type" to GL_FLOAT for the given 
"internal format" GL_RGBA32F_ARB:

    setInternalFormat(GL_RGBA32F_ARB);
    ==> computeInternalFormatType() gives GL_FLOAT as a result.

If I use the "internal format" GL_RGBA the method 
computeInternalFormatType() computes the "internal format type" NORMALIZED:

    setInternalFormat(GL_RGBA);
    ==> computeInternalFormatType() gives NORMALIZED as a result.

So how do I get to write to the alpha if its not normalized?

Cheers
Daniel

Joseba wrote:
> Hi,
> I had some similar problem sometime ago and i solved it changing the internal format of the texture for the RTT. I also had some issues using FRAME_BUFFERS instead of FBOs, but you are already using them.
>
> Regards,
>
> J.
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=8103#8103
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>   




More information about the osg-users mailing list