Weird shader behavior: discard in one shader causes gl_Normal to be 0 in another

"Peter Dobrev" <[email protected]> Thu, 11 Dec 2008 04:00:35 -0800
Newsgroups gmane.games.devel.opengl
Organization Fat City Network Services, San Diego, California
Message-ID <[email protected]>
Hello!

I have a really strange (at least to me) problem with a bunch of glsl shaders.
So, this is my workflow:
- I'm rendering a point cloud (glPointSize=1) and first want to mark some points
- I do a bunch of rendering passes marking the points and after each
pass I discard the points that have been marked in previous runs. This
I can do in two ways:
    - manually remove the marked points from the dataset after each
rendering (slow)
    - pass a vertex array containing information about which point has
already been marked and use a simple test in the shader like
         if (marked == 1)
              discard;
- After the marking process, I do a completely different rendering
with visualization purposes (and not marking), with a different pair
or shaders and from a different viewpoint.

The problem:
If I use discard; in the marking fragment shader, I get that gl_Normal
is always 0 in the rendering shader, even though I'm passing non-zero
normals along the geometry.

If I manually remove the marked points from the dataset, everything
works out fine and the normals are non-zero.

No GL errors, no shader warnings.

Any clue would be highly appreciated!

Petar.
----- 
FAQ and OpenGL Resources at:
  http://www.geocities.com/SiliconValley/Hills/9956/OpenGL

-- 
Author: Peter Dobrev
  INET: [email protected]

Fat City Hosting, San Diego, California -- http://www.fatcity.com
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [email protected] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB OPENGL-GAMEDEV-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).