We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello, I need some help to understand vertex shader in Processing.
What I want to do is just to change vertices coordinates in vertex shaders, such as in "www.vertexshaderart.com" . In order to do that:
restore the vertices coordinates into the world coordinates like
worldPos = modlviewInv * vertex
move vertices as we like
re-restore the vertices coordinates into the eye coordinates like
newPos = projection * modelview * worldPos
According to the official explanations (https://github.com/processing/processing/wiki/Advanced-OpenGL), the modelview matrix in the vertex shader in Processing is an "IDENTITY" matrix for some performance issues, which means our vertex shader does not know the original modelview matrix, we need to send the unmodified modelview matrix from the processing side to the vertex shader explicitly.
I thought the code below might work, but I failed, which I do not know why:
PGraphicsOpenGL pg = (PGraphicsOpenGL)g; shader.set("modelviewOriginal", pg.modelview);//send the modelview matrix to the uniform mat4 variable "modelviewOriginal"
vertex shader side:
vec4 worldPos = modelviewInv * vertex;//restore world coordinates worldPos = vec4(worldPos.x + 100., worldPos.yzw);//for example, translate x pos vec4 newPos = projection * modelviewOriginal * worldPos;//re-restore eye coordinates
Probably, I have been missing something basic stuff, I could not have figured them out so far...
So...., please help me !!!!!