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

Create xr full screen effects doc page #10727

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

devloglogan
Copy link

@devloglogan devloglogan commented Feb 28, 2025

Adds a doc page informing on how users can take asymmetric FOV into account in full screen quad post-processing shaders.

@BastiaanOlij mentioned that attempting to do this while reading from the screen texture is a big no-no so I also included a section at the bottom attempting to warn users about that.

@devloglogan devloglogan added enhancement topic:xr Related to XR documentation area:manual Issues and PRs related to the Manual/Tutorials section of the documentation labels Feb 28, 2025
@devloglogan devloglogan added this to the 4.x milestone Feb 28, 2025
@BastiaanOlij
Copy link
Contributor

Personally i feel we shouldn't be talking about post processing here. Post processing effects suggest that you modify the rendered output and that is where the big no-no's come in.

Vignettes' etc are not post processes. They are screen space effects that use a quad to render their output (actually a single triangle would be better but we don't have an easy primitive for that). So I think we need to come up with better naming.

In the same line, I don't think that referencing the original post processing document is a good idea. Again, we just set people on the wrong footing, they will read that, figure out they can do that in XR as well, and then when they are too far along find out that doing so is what is causing their performance to never get up to spec. By then it's too late.

@devloglogan
Copy link
Author

@BastiaanOlij understood, and now that I understand the term a bit better I fully agree! @dsnopek had mentioned something similar to me elsewhere. I'll rework this soon to swap that term out for something like "full screen effects" and also remove the reference to the other doc.

@BastiaanOlij
Copy link
Contributor

@devloglogan it does feel like nitpicking but I feel we can prevent ourselves a bit of hardship if we get that bit right :)

@devloglogan devloglogan force-pushed the asymmetrical-fov-doc branch from 5eacb0c to 8847300 Compare March 3, 2025 21:54
@devloglogan devloglogan changed the title Create xr post-processing doc page Create xr full screen effects doc page Mar 3, 2025
@devloglogan
Copy link
Author

Alright, I've opted for "full screen effects" as the term instead and removed the reference to the other doc entirely (which adds a touch more on the basic full screen quad setup).

Comment on lines 16 to 26
shader_type spatial;
render_mode depth_test_disabled, skip_vertex_transform, unshaded, cull_disabled;

void vertex() {
POSITION = vec4(VERTEX.xy, 1.0, 1.0);
}

void fragment() {
ALBEDO = vec3(0.0);
ALPHA = dot(UV * 2.0 - 1.0, UV * 2.0 - 1.0) * 2.0;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about including the incorrect shader code in full, because folks may not read very closely and just copy-paste this.

I think it may be better to only show full shader code for the correct one, and maybe put comments calling out the part that adjusts for the asymmetric projection matrix? Saying like, "if you remove this, the effect won't be correctly centered")

Comment on lines 11 to 12
Here is a simple vignette shader that you might apply to the quad, darkening the edges
of a user's screen:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're not linking to https://docs.godotengine.org/en/latest/tutorials/shaders/advanced_postprocessing.html, then I think we need to include some more information than this, explaining:

  1. The MeshInstance3D node they need to add, the size of the quad mesh, and to put it as a child of the camera. Some of this is shown in the images, but I think we should have it in words too.
  2. That we're making it full screen by setting the POSITION in the shader. (This ends up being implied in the "Applying the projection matrix" section, but I feel like it'd be best to state it up front)

Comment on lines 29 to 30
However, when creating an effect that is centered straight ahead in the user's view
(such as the above vignette effect), the end result may look incorrect in XR.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is shown wonderfully in the picture, but I think we should also say in words, why it doesn't look correct in XR (that the center of the rendered output we are producing isn't necessarily the center of the user's view in XR, because our output will be deformed to match the lenses of the headset)

Also, I think it would also be cool to show a screenshot from inside the headset showing how the correct and incorrect versions look, in addition to the screenshots of the render target texture. Maybe it could be shown in a 2x2 grid, with the headset image above the render target image? Otherwise, it might not be entirely clear that the off-center effect on the render target is actually the correct one that will look centered in the headset

Comment on lines 78 to 81
Currently, full screen effects that require reading from the screen texture effectively disable all
rendering performance optimizations in XR. This is because, when reading from the screen texture,
Godot makes a full copy of the render buffer. Since this may create performance issues, it is recommended
that custom effects be limited to per-pixel ones such as the above vignette shader.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it could be made a little clearer that this limitation doesn't apply to the technique shown here. Having a "Limitations" section makes it sound like this is a limitation of what was shown above, rather than a limitation of a totally different way to approach doing this, which we didn't show :-)

@devloglogan devloglogan force-pushed the asymmetrical-fov-doc branch from 8847300 to 68e234e Compare March 7, 2025 16:41
@devloglogan
Copy link
Author

@dsnopek Thanks for the review! I believe I've addressed all of your suggestions, please take another look at the doc when you get a chance. :)

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 enhancement topic:xr Related to XR documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants