Skip to content

Why should we make a "viewRay z division" to viewRayOS? #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wqaetly opened this issue Apr 1, 2021 · 2 comments
Open

Why should we make a "viewRay z division" to viewRayOS? #31

wqaetly opened this issue Apr 1, 2021 · 2 comments

Comments

@wqaetly
Copy link

wqaetly commented Apr 1, 2021

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;

@ColinLeung-NiloCat
Copy link
Owner

ColinLeung-NiloCat commented Apr 1, 2021

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

@wqaetly
Copy link
Author

wqaetly commented Apr 2, 2021

Okay, thank you for your reply, I think I already understand why, as shown below

image

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants