Hello, Sebastian
There is also another strange problem . When
Vertex shader is as follows:
varying out vec3 pos;
varying out float dist2;
void main()
{
vec3 pos1 = (gl_ModelViewMatrix * (gl_Vertex -
vec4(0.0,0.0,0.0,0.0))).xyz;
dist2= length(pos1)
gl_Position = ftransform();
}
Frag shader is as follows:
varying in vec3 pos;
varying in float dist2;
out vec4 Frag_Color;
void main()
{
Frag_Color = vec4(abs(dist2/100),0,0,1);
}
Then when Frag_color is read via Image, the output is:
0,0,0,1
While in my programme, the dist2 should be equal to for some fragments
0.18 , for other fragments 0.56 and for still others not available
because no geometry covers those fragments.
But when the shader is written like this:
vertex shader:
varying out vec3 pos;
void main()
{
pos = (gl_ModelViewMatrix * (gl_Vertex -
vec4(0.0,0.0,0.0,0.0))).xyz;
gl_Position = ftransform();
}
Fragment shader:
varying in vec3 pos;
out vec4 Frag_Color;
void main()
{
float dist2= length(pos);
Frag_Color = vec4(abs(dist2/100),0,0,1);
}
Then when Frag_color is read via Image, the output is:
0.188235,0,0,1
0.560784,0,0,1
so this time it works!
I really cannot figure out why this happens!
Thank you very much in advance for any advice!
Shuiying
On 01/18/2012 08:11 AM, Sebastian Messerschmidt wrote:
I suppose you are using a normal framebuffer.
I this case it is pretty normal, that your original value that is in
the image (you unfortunately didn't tell use if the value comes from a
texture)
doesn't exactly match the value in the framebuffer. Usually the
framebuffer has 8bit per color channel, which makes the value of
0.174977 not representable.
If you need the "exact" value to be in the framebuffer you'll have to
render it to a floating point buffer via RTT.
Also you didn't tell us how you got the result value. There is also
the possibility that you read an interpolated/filtered value.
If you provide a bit more context someone might be able to help you
with your problem
Hello,
when I write gl_FragColor = vec4(0.174977,0,0,1) in Frag shader,
then I get through a related image: float Vec4: (0.176471,0,0,1)
so why 0.174977 changed into 0.176471?
I think there should be no process there after per fragment
operations that can change this element in the rendering pipeline.
Blend, alphatest and so on are all disenabled.
Thank you in advance!
Shuiying
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org