- Home /
Several questions about OnRenderObject and Camera projection matrix use.
Hi, I implemented a prosedure mesh way to simulate rain and snow effect,using the method shaderX7 chapter 5.1 presented. It works fine now, but I'm still confusing about something in unity. I expose a public Camera pointer to get the main camera,and render the mesh use graphis.DrawMeshNow in OnRenderObject.
1.When I play the game in editor,everythings works fine if only Scene View or Game View is visible. If I change the editor layout, make the Scene View and Game View both visble, camera parameters which I pass to shader seems wrong. 2.I need to get the camera projection matrix and pass it to the shader. I found in forward rendering I can use it directly,but in deffered rendering I need to do some flip like this for(int i=0;i<4;i++) { P[1,i] = -P[1,i]; P[2,i] = P[2,i] 0.5 + P[3,i] 0.5f; } I found it in some thread but I don't know why. 3.It seems I can't use Camera.current to get the parameters in OnRenderObject.When the camera moves, the parameters go wrong.
Thanks for any help.
Your answer
![](https://koobas.hobune.stream/wayback/20220613071822im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to get screen coordinates of object from shader 0 Answers
A bit more texture detail in Vertex Lit 1 Answer
Semi transparent Object behind walls? 1 Answer
Camera with shader? 2 Answers