-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add a section about coordinate spaces to shader pages. #9757
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
Conversation
@@ -83,6 +83,51 @@ Render modes | |||
| **fog_disabled** | Disable receiving depth-based or volumetric fog. Useful for blend_add materials like particles. | | |||
+-------------------------------+------------------------------------------------------------------------------------------------------+ | |||
|
|||
Coordinate spaces |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should either put this section here, or at the bottom of the page.
Pros for here:
- It's a prerequisite for understanding everything else on the page.
Pros for end of page:
- Once you already know what the spaces are, it may be annoying to scroll past it every time you're reading. The page already functions fine without a coordinate space section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upon further reflection, this section should go at the bottom of the page unless there's a strong argument otherwise.
7d9df6b
to
07af357
Compare
vec3 position_view = (VIEW_MATRIX * MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz; | ||
} | ||
|
||
You can transform to one coordinate space, do some operations, and transform back. This snippet scales ``VERTEX`` in model space, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe change this example. It might encourage bad practice, since in most cases you can do this with a single transformation, and without the expensive inverse().
On the other hand this specific example of manipulating vertices with both world and model space does come up a lot, including the lack of an INV_MODEL_MATRIX
.
vec3 normal_world = (INV_VIEW_MATRIX * vec4(NORMAL, 0.0)).xyz; | ||
} | ||
|
||
You can also compose multiple transformations together. To transform ``VERTEX`` from model space to view space, first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe change the example since MODELVIEW_MATRIX already does this.
9dfcdc8
to
9237a80
Compare
|
||
|
||
|
||
Working with coordinate spaces |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arguably this whole section should be a separate page.
f2d8faa
to
11b1c9a
Compare
|
||
Screen space to clip space: | ||
|
||
.. code-block:: glsl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be some variation on the function for screen to view, but I can't figure it out
+-------------------------------+----------------------------------------------------------------------------------------+ | ||
| Screen space | TODO | | ||
+-------------------------------+----------------------------------------------------------------------------------------+ | ||
| Normalized device coordinates | Usually not used directly. ``xy`` alues range from ``-1.0`` to ``1.0``, with | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this actually guaranteed to be Vulkan NDC coordinates (-1,-1,0) to (1,1,1)? In the compatibility renderer, can it be in (-1,-1,-1) to (1,1,1)?
11b1c9a
to
c270749
Compare
@tetrapod00 is this something you're still working on? |
Not actively working on this. We can archive it. If I pick it back up again, I'll either amend this PR or make a new one. |
Resolves #9780.
This PR aims to add a list of coordinate spaces to various shader pages: