There are two fragment programs up there where one activates red is x is less than 1.0 and the other one activates red if x is greater than or equal to one. Given the same values of x (vvertex) with the two programs it always draws a red.
How can x be both greater than equal to 1 and less than 1 at the same time?
Because you probably normalize a null vector which produces a division by 0, and probably an undefined value or a NaN (not a number).
An undefined value is neither positive nor negative, just undefined.
Read the section that starts with
“A second pitfall to be aware of is that sometimes a variable may have an “undefined” value…” in the following reference:
oh wow that is exactly it.
so you are saying that vec3 vertex may have a length 0?
I’m just trying to draw the world coordinates of pixels on the screen as vectors represented by colors.
What I do is I just multiply the vertex coordinates by model matrix in the vertex program and have it interpolate over the surface.
First of all that will definitely lead into negative numbers and for that I just added 1000.0 to the vector for now. It is not the robust way but it makes sense as the models are at most around -100 in x,y,z. But it definitely should not lead into zeros.
Do you know of the correct way to draw the world coordinates like you would draw the normals of pixels?
>>2.How can you write the world coordinates to a floating point buffer as they are (with the negative values)?
I write in a FBO with 1-4 attached RGBA32f textures, when I debug.
Can I simply output floating values ‘including the negative ones’ as pixel colors and in a different shader directly access them as they are? (Also the same for the normal, so that there would be no need for +1 /2) ?