We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
After a lot of headach digging in shader, it seems that the vertex attribute received by the fragment shader is already in the view space.
For example, i have exactly the same result using :
gl_Position = projection * vertex;
or
gl_Position = transform * vertex;
or
gl_Position = modelview * projection * vertex;
Transform must be modelview * projection ?
Thanks in advance for your reply :)
Answers
Just a precision according to my poor knowledge in shader the vertex received by the vertex shader must be in model space no ?
Nobody have the same issue ?
Thanks again for your help !
Vertex goes to vertex shader in object space (aka model space). So regarding your first post, no the vertex attribute does not go to the fragment shader and no it is not in view space.
The uniform variable (set by Processing) transform is a 4x4 matrix holding the product of the projection and the modelview matrices. The multiplication of a vertex by the transform matrix gives the clip coordinates.
If you were to do it separately, you should do projection * modelview * vertex. So the other way around than from what you write.
You don't post any runnable code that shows this supposed 'bug', so your claim seems to be made with little basis. For debugging shaders you can use colors.
I suggest you read this and for background information you can look at this.
Good luck! ;-)
Thank you for your reply, maybe i just don't understand but here my test. I just set a color if the vertex X position is > 0 or not. So if the vertex is really in world space, not in view, if i move the camera the color would stay at the same position on the box. Here, the color move on the box when i move the camera not the world(so the view matrix ?)
Is-it a normal behaviour ?
Hmm, indeed this is strange. Perhaps with this code example you can open an issue here to shed some light on these matters: https://github.com/processing/processing/issues
Opened !
Thank you again for your time on this subject :)