[osg-users] Image from shader
    Lucas Amparo 
    lucas.barbosa at fieb.org.br
       
    Thu Oct  3 10:46:31 PDT 2019
    
    
  
Hi everyone,
I'm trying to retrieve an image from a shader using OpenGL in OSG/OSGOcean.
I can retrieve the depth from the simulation but can't access properly the color from each vertex.
Using this code on *.vert
Code:
out vec3 pos
out vec4 color
void main() {
pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
color = gl_Color;
}
and this in *.frag
Code:
in vec3 pos;
in vec4 color;
uniform float farPlane;
void main() {
float linearDepth = length(pos);
float dist_ratio = linearDepth / farPlane;
gl_FragDepth = dist_ratio;
gl_FragColor = gl_FrontColor;
}
I'm achieving this image (image2.png on attachment) when I'm trying to produce that image (image1.png on attachment).
Could someone bring me to light? I'm very lost on this...
Thank you!
Cheers,
Lucas
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=76777#76777
Attachments: 
http://forum.openscenegraph.org//files/image1_169.png
http://forum.openscenegraph.org//files/image2_731.png
    
    
More information about the osg-users
mailing list