<div dir="ltr"><div dir="ltr"><div>I think you want:</div><div>gl_FragColor = color;<br></div><div><br></div><div>Or, if you'd rather use the built-ins, get rid of your "out vec4 color" and write to gl_FrontColor in the vertex shader:</div><div>gl_FrontColor = gl_Color;</div><div><br></div><div>And read from gl_Color in the fragment shader:</div><div>gl_FragColor = gl_Color;</div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Glenn Waldron / osgEarth</div></div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 3, 2019 at 1:54 PM Lucas Amparo <<a href="mailto:lucas.barbosa@fieb.org.br">lucas.barbosa@fieb.org.br</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi everyone,<br>
<br>
I'm trying to retrieve an image from a shader using OpenGL in OSG/OSGOcean.<br>
<br>
I can retrieve the depth from the simulation but can't access properly the color from each vertex.<br>
<br>
Using this code on *.vert<br>
<br>
<br>
Code:<br>
<br>
out vec3 pos<br>
out vec4 color<br>
<br>
void main() {<br>
pos = (gl_ModelViewMatrix * gl_Vertex).xyz;<br>
color = gl_Color;<br>
}<br>
<br>
<br>
<br>
<br>
and this in *.frag<br>
<br>
<br>
Code:<br>
<br>
in vec3 pos;<br>
in vec4 color;<br>
<br>
uniform float farPlane;<br>
<br>
void main() {<br>
float linearDepth = length(pos);<br>
<br>
float dist_ratio = linearDepth / farPlane;<br>
<br>
gl_FragDepth = dist_ratio;<br>
gl_FragColor = gl_FrontColor;<br>
}<br>
<br>
<br>
<br>
<br>
I'm achieving this image (image2.png on attachment) when I'm trying to produce that image (image1.png on attachment).<br>
<br>
Could someone bring me to light? I'm very lost on this...<br>
<br>
Thank you!<br>
<br>
Cheers,<br>
Lucas<br>
<br>
------------------<br>
Read this topic online here:<br>
<a href="http://forum.openscenegraph.org/viewtopic.php?p=76777#76777" rel="noreferrer" target="_blank">http://forum.openscenegraph.org/viewtopic.php?p=76777#76777</a><br>
<br>
<br>
<br>
<br>
Attachments: <br>
<a href="http://forum.openscenegraph.org//files/image1_169.png" rel="noreferrer" target="_blank">http://forum.openscenegraph.org//files/image1_169.png</a><br>
<a href="http://forum.openscenegraph.org//files/image2_731.png" rel="noreferrer" target="_blank">http://forum.openscenegraph.org//files/image2_731.png</a><br>
<br>
<br>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org" target="_blank">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote></div></div>