Why does my object disappear?

I am just starting to learn GLSL. In my first experiment, I tried a debugging technique I used with assembly shader language. I would write intermediate calculations out as the output color so that I could visualize my math. When I try this in GLSL, my polygon disappears. I tried various forms of the output statement (in the vertex shader), and even something simple like the following causes the polygon to disappear:

gl_FrontColor = (1.0, 1.0, 1.0, 1.0);

The shader compiles and links with no errors, but the polygon is not visible. I am assuming the polygon is rendered with an alpha value of 0, so it gets discarded.

GeForce 6800 Ultra with driver 61.77

Any clues?

A little more shader code would be fine.

gl_FrontColor = (1.0, 1.0, 1.0, 1.0);
needs to be
gl_FrontColor = vec4(1.0, 1.0, 1.0, 1.0);
or more compact
gl_FrontColor = vec4(1.0);

Have you calculated the gl_Position?

It’s always a good idea to use a weird color to clear the background during debugging, to see if you render black-on-black.

Yes, I am computing position. I am trying to get my vertex-rate lighting working. The flow is basically as follows:

color = globalAmbient * vertexColor + emmissive
color += lightSourceAmbient
compute diffuse and specular terms
color += diffuse
color += specular
gl_FrontColor = color

The code displays a polygon, but I believe my diffuse term is incorrect.

If I comment out the gl_FrontColor command and insert a debug command after the globalAmbient term I can display the global ambient color and see the polygon.

If I insert the debug command after the light source ambient, I see that.

But if I insert the command after I start doing the diffuse vector math, the polygon disappears, even with a simple debug statement (vec4(1.0) does not work either).

I have used this technique succesfully with assembly code to display various vectors and intermediate terms. I just don’t know why it kills my polygon in GLSL.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.