UnityURPUnlitScreenSpaceDecalShader
UnityURPUnlitScreenSpaceDecalShader copied to clipboard
Why should we make a "viewRay z division" to viewRayOS?
Good guy, I have some doubts when studying the code, why do we need to do perspective division on the ray from the model space camera to the vertex? In my cognition, perspective division is only to get the NDC coordinates, and there are some unclear meanings here.
大佬好,在研究代码的时候有一些疑惑,为什么要对模型空间相机到顶点的射线做透视除法,在我的认知里透视除法只是为了得到NDC坐标,而这里让我有些摸不到头脑
i.viewRayOS.xyz = i.viewRayOS.xyz / i.viewRayOS.w;
after i.viewRayOS.xyz /= i.viewRayOS.w; i.viewRayOS.xyz is now an object space view direction with view space depth = 1 (not a unit vector). cameraPosOS.xyz + i.viewRayOS.xyz * linearEyeDepth = reconstruct scene position in object space from depth texture
Okay, thank you for your reply, I think I already understand why, as shown below
In addition, I wrote a technical blog to analyze this project, hoping to help those who want to understand the principles of the project,https://www.lfzxb.top/screen-space-decal-in-urp-study/