Stereo issue with shader

14 views
Skip to first unread message

Toan Dinh Nguyen

unread,
Oct 25, 2016, 10:15:53 PM10/25/16
to omegalib
Hi Alessandro,

I have simple point shaders:

vert:
#version 120
void main()
{
    gl_Position = ftransform();
    gl_FrontColor = gl_Color;
    gl_PointSize = 20.0;
}

frag:
#version 120
void main() {
    N.xy = gl_PointCoord* 2.0 - vec2(1.0);    
    float mag = dot(N.xy, N.xy);
    if (mag > 1.0) discard;   
    gl_FragColor = gl_Color;
}

and a C program that renders some testing points using the shaders. If I enable the line "if (mag > 1.0) discard;", stereo is disabled and I only see normal 3D points! 

This doesn't happen with python code using cyclops module. I am using Omegalib v13. Any ideas/suggestions?

Thanks,
 

Alessandro Febretti

unread,
Oct 25, 2016, 11:36:15 PM10/25/16
to omegalib
If instead of discarding the fragment  you set its alpha to 0 do you get correct stereo?

Toan Dinh Nguyen

unread,
Oct 25, 2016, 11:39:55 PM10/25/16
to omegalib
I get stereo but black pixels outside the circle. I guess unless they are depth sorted setting alpha won't work.

Alessandro Febretti

unread,
Oct 25, 2016, 11:52:12 PM10/25/16
to omeg...@googlegroups.com
you should be able to make them fully transparent without issues even if  they are not sorted since you aren't really doing any blending.

If you are writing straight OpenGL code, make sure you have
glEnable(GL_BLEND)

somewhere before your draw code
Reply all
Reply to author
Forward
Message has been deleted
0 new messages