0
Completed

custom projection matrix for custom reflections

Mehrdad Ataee 6 years ago updated by Freya Holmér (Developer) 6 years ago 2

hi there!

I have an script that create a custom projection matrix and inject it to the shader via SetGlobalMatrix to simulate correct reflection from camera view

this reflection is not a cubemap but a 2D texture

the matrix should help to wrap and stretch the texture correctly on top of the model as if its a reflection.

(there are actually 2 texture2Ds one on top and one on the bottom instead of 6 for performance reasons)

here is the matrix

projectionMatrix = GL.GetGPUProjectionMatrix(camera.projectionMatrix, true);
projectionParams = new Vector3(projectionMatrix[0, 0], projectionMatrix[1, 1], projectionMatrix[2, 2]);

is there any way to use this matrix in Shader Forge.

I have multiplied it with "view dir", "normal dir" and "scene uv" and has splitted the RG channels as reflection UV but all was some blind shots with no success after almost spending 10 hrs playing around it.

so I would be very grateful if anyone could help, thanks.

Answer

Answer

I have found my answer

you either have to multiply view_refl_dir to the matrix by MatrixMultiplier node

or just use mul(matrix,view_refl_dir); in code.


please don't hesitate to delete this post if you discernmented so!

Answer

I have found my answer

you either have to multiply view_refl_dir to the matrix by MatrixMultiplier node

or just use mul(matrix,view_refl_dir); in code.


please don't hesitate to delete this post if you discernmented so!