[osg-users] Several RTT camera/shader issue(s) on multipass shading

Mihai Radu radu at cm-labs.com
Thu Oct 4 19:46:12 PDT 2007

Hi Christian,

A short comment before looking at any of the code ( can't open the zip ).

>From the snippets you posted, it looks to me like the texture
coordinates used for textureUnit 0 are not correct.
If they are set with the geometry ( per vertex ), then the first part
should work well, if they are either object-relative or eye-relative
with a TexGen to calculate them, that requires some calculations in the
vertex shader ( that are done automatically by the fixed-function
pipeline ).

Looking even more closely, I can see you are rendering to a single quad
( z values are 0 ), and the last line scales everything in the [0.0,1.0]
range, from the usual [-1.0,1.0], something that is done with projective
texturing ( see osgshadow example for the way _texGen is being scaled ).
I think the only reason your second snippet is working is because you
are using an identity matrix for the camera, if you were using anything
else, your results would probably be off.

summary: check the texture coordinates for the pass you are referring to :)


Christian Heine wrote:
> Hello,
> 2nd issue (Shader):
> If i use in the vertex shader the values of the rendering pipeline with
> the following
> setups, the RTT result is shown like in the working screenshot. The blur
> effect
> of the second pass is not effected but the shader executed (set color to
> red):
> gl_Position = ftransform();
> vTexCoord = gl_MultiTexCoord0;
> If i use this simple code sniplet (used in RenderMonkey for Shadertest)
> then the
> RTT is moved to screen center and sized up where nothing is shown (See
> defect_vertexShader
> Screenshot):
>  vec2 Position;
>  Position.xy = sign(gl_Vertex.xy);
>  gl_Position = vec4(Position.xy, 0.0, 1.0);
>  vTexCoord = Position.xy *.5 + .5;
> I couldn't be explain, why this simple snipplet occurs in such an
> effect. There is
> nothing special done ...
> Thanks for any help,
> best regards
> Chris

More information about the osg-users mailing list