[osg-users] Setting alpha channel in Frag Shader does not work.
Daniel Holz
danielh at cm-labs.com
Thu Mar 19 09:20:15 PDT 2009
I suppose you are writing the data in a texture with gl_FragColor = vec4(..., depth).
What exactly are you doing with the data that you write afterwards, or how do you actually obtain your point cloud?
If for example you take the position vec4(..., depth) (which is a world space position?) and you would project it on the image plane by doing
PROJECTIONMATRIX * MODELVIEWMATRIX * vec4(..., depth) then, if depth is not equals 1.0 you get a completely different projection on the screen after doing the perspective division.
Remember: your world space positions are specified in the homogenous coordinate system, meaning that a world space position (x,y,z) is represented by (x,y,z,1). If you want to project a world space position on the image plane it needs to have the w component (the 4th one) set to 1, since that's where the effect of perspective foreshortening is kind of "stored" after multiplication with the projection matrix.
The perspective division (dividing the x,y,z component by the resulting w component) then actually performs the projection.
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=8776#8776
More information about the osg-users
mailing list