[osg-users] Image from shader
Glenn Waldron
gwaldron at gmail.com
Thu Oct 3 10:59:47 PDT 2019
I think you want:
gl_FragColor = color;
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:
gl_FrontColor = gl_Color;
And read from gl_Color in the fragment shader:
gl_FragColor = gl_Color;
Glenn Waldron / osgEarth
On Thu, Oct 3, 2019 at 1:54 PM Lucas Amparo <lucas.barbosa at fieb.org.br>
wrote:
> 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
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20191003/d905f95c/attachment.html>
More information about the osg-users
mailing list