cPlane is a vector4f that I send in as a uniform vec4(0.0, 1.0, 0.0 0.0).
The clipplane seems to be stuck in the object space and follows the moving ships movements and do not stay at the world pos.
Any idea what’s wrong?
Either reverse the order of the multiplication or transpose the matrix. OpenGL uses the usual mathematical convention of multiplying with the matrix on the left and a column vector on the right, not the DirectX convention (row vector on the left, matrix on the right). The two are equivalent up to transposition of the matrix: (M.x)T = xT·MT. Matrices generated by GLM or similar will use the OpenGL convention.
If that doesn’t fix it, check that you’re using the correct matrix and that it contains what you expect.
So I imagine some matrix is wrong.
The shader is applied on a ship model which rolls/pitches in the water, and the cPlane is the flat water plane.
Which matrix should be applied on the gl_Vertex and/or cPlane?
But in that case, it would affect the model itself, not just the clip plane.
Although, it’s possible that transformations which should be part of the view matrix are part of the model matrix. Without the clip plane, the individual matrices wouldn’t matter, only their product. So there wouldn’t be any difference between view=A*B,model=C and view=A,model=B*C, as both would give view*model=A*B*C.
I wonder if such behavior would work fine on some ATI graphic card. I well remember the clip plane intrinsic did not work on some ATI hardware, and I made a pure programmable shader to solve that. So just a reminder, beware the compatible issues.