Skip to content
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

Fragment built-ins "VIEW" is described as being the vector from camera to fragment, when it is actually the vector from fragment to camera. #4267

Closed
Arnklit opened this issue Oct 14, 2020 · 3 comments · Fixed by #6861
Assignees
Labels
area:manual Issues and PRs related to the Manual/Tutorials section of the documentation bug

Comments

@Arnklit
Copy link
Contributor

Arnklit commented Oct 14, 2020

Your Godot version:
3.2.3

Issue description:
Fragment built-ins "VIEW" is described as being the vector from camera to fragment, when it is actually the vector from fragment to camera.

URL to the documentation page:
https://docs.godotengine.org/en/stable/tutorials/shading/shading_reference/spatial_shader.html#fragment-built-ins

@clayjohn
Copy link
Member

Are you sure? Keep in mind, VIEW is in camera space, not in world space.

I guess either way it needs to be updated. Because it is a normalized direction, rather than a vector from one point to another.

@Arnklit
Copy link
Contributor Author

Arnklit commented Oct 14, 2020

Yeah it's definitely a normalized value. I'm pretty sure it's from fragment to camera.
I needed to make a normal point at the camera, so looking at the documentation I assumed I would have to do:

NORMAL = -VIEW;

But that will look like the normal is pointed away from the camera.

NORMAL = VIEW;

Looks like the normal is pointed towards the camera.

image

@clayjohn
Copy link
Member

Thanks for the explanatory image. It's very helpful for me to put my head back on straight. Yes the view vector is relative to the fragment.

It is the direction to the camera from the current fragment. It is used in conjunction with light direction and surface normal to compute lighting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:manual Issues and PRs related to the Manual/Tutorials section of the documentation bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants