I’m new to jME, but have some background in OpenGL/LWJGLv3/GLSL. I’m programming in Java directly, not using the SDK.
I’m experimenting to learn the very nuts and bolts of things, shaders in this case.
I have a basic starter application, based on examples found in the tutorial in the wiki, and other wiki pages. For this particular topic, the starting place is the basic shader demo on the JME3 and Shaders page. That worked just fine.
My experiment was to replace the box with a quad, sized to fit within the coordinates used by projection space (-0.8, -0.8 to 0.8, 0.8), and drop the use of g_WorldViewProjectionMatrix
. In other words, the vertex shader’s only line in its main
method is:
gl_Position = vec4(inPosition, 1.0);
I was expecting this to (a) draw the quad from almost-corner to almost-corner of the screen, and (b) always do so.
The program did (a), but if I move the mouse enough, or hold one of the movement keys for long enough, the quad disappears. It’s easy to find the threshold where jittering back and forth will cause it to appear and disappear.
I presume what is happening is that the quad is leaving the view frustum. (e.g. the amount of movement necessary to cause the quad to disappear is similar to doing exactly that under the normal circumstance of having gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1.0);
) But I find this quite surprising when my vertex shader is simply passing through the inPosition
.
Said differently, since the vertex shader is always saying “use these values between -0.8 and 0.8”, why is the end result ever anything other than that? Or, since the shader isn’t doing any kind of transformation of the vertex positions, what is?