r/GraphicsProgramming • • Feb 11 '16

Orthogonal Matrix using Vertex/Fragment shaders Problem

http://forum.lwjgl.org/index.php?topic=6133.0
1 Upvotes

4 comments sorted by

2

u/kikkurs Feb 11 '16

Some ideas:

  • When no pixels are appearing, ALWAYS begin drawing your first triangle with an untransformed vertex shader (output = input), and a solid color output in the fragment shader. If you can't see anything, you've either incorrectly provided vertices or set your viewport/window up wrong.

  • One thing you could look at is what is happening to your z coordinates. In opengl, all vertices must have xyz for a valid position.

  • Opengl clips off all geometry that is outside of the clip space, and I suspect your ortho projection matrix has incorrect near/far clip values (z values of 0 are clipped because they do not fall into your range of 0.1-100.0)

1

u/Hydroque Feb 12 '16

what is happening to your z coordinates Opengl clips off all geometry that is outside of the clip space,...

Aha! I don't use the Z axis whatsoever. I also don't even use 3 coordinates when I specify, to opengl, how many coordinates I am using for spacial position. So maybe I can play around with that, as it might be clipping it because the matrix transforms it out of scope.

ALWAYS begin drawing your first triangle with an untransformed

I've always defaulted to printing the shit out of variables, and when I can (GLSL yay!) I resort to primitive builds. So I know that the primitive builds went okay (as I stated, I could get it to draw without the projection matrix.)

Perhaps I can use just the projection matrix as the only thing on the matrix stack and try to mess around from there if my Z axis crap doesn't work. I wonder what would happen if I take depth test off and keep using it the way I have had it, as it could stop the erase of the geometry that is out of scope...

1

u/Hydroque Feb 12 '16

I have had no luck. It is not the Z making my objects be clipped.

gl_Position = matrix_projection * matrix_camera * matrix_transform * vec4(position.x, position.y, 1, 1.0);

No matter what I set it, the Z axis isn't changing anything, even without matrix_projection on the stack.

1

u/Hydroque Feb 13 '16

It's a very well constructed question including source and all that.