Skip to content

Fix GLES3 stereo output (sRGB + lens distortion) #107698

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

Merged
merged 1 commit into from
Jun 21, 2025

Conversation

BastiaanOlij
Copy link
Contributor

This PR fixes two issues in the compatibility renderer.

First, when using OpenXR we have to use GL_SRGB8_ALPHA8 buffers to render to. This triggers a hardware sRGB->Linear conversion when we are reading from this buffer with our final blit to screen. We need to revert that conversion to get proper colors.

Fixes #107655

Second, we never copied over our lens distortion shader used by our MobileVRInterface implementation. This is thus a long standing regression from Godot 3.6 that stops people from using Godot with cardboard-ish phone VR (which yes, still gets used to this day).

This can be tested with: godotengine/godot-demo-projects#1212

#ifdef USE_TEXTURE_3D
vec4 color = textureLod(source_3d, vec3(uv_interp, layer), lod);
vec4 color = textureLod(source_3d, vec3(uv, layer), lod);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note, this extra indent is clang-format being annoying...


Rect2 dst_rect = blit.dst_rect;
_blit_render_target_to_screen(rid_rt, p_screen, dst_rect, blit.multi_view.use_layer ? blit.multi_view.layer : 0, i == 0);
_blit_render_target_to_screen(p_screen, p_render_targets[i], i == 0);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Figured just providing our data as it already is as a parameter, would be much more efficient than copying all the members as parameters.

I wonder if we should insert _blit_render_target_to_screen into blit_render_targets_to_screen, there really isn't a good benefit to these being split.

@BastiaanOlij BastiaanOlij requested review from clayjohn and dsnopek June 19, 2025 05:09
@BastiaanOlij BastiaanOlij added this to the 4.5 milestone Jun 19, 2025
@github-project-automation github-project-automation bot moved this to For team assessment in XR Issue Triage Jun 19, 2025
@BastiaanOlij BastiaanOlij moved this from For team assessment to Fix pending review in XR Issue Triage Jun 19, 2025
Copy link
Contributor

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

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

Thanks!

The code changes seem OK to me, but probably should get review from someone on the rendering team.

I tested on Linux with the MobileVRInterface and it seems to be working great! However, I can't reproduce the issue with incorrect colors on MobileVRInterface, that issue is specific to OpenXR on the desktop, and I don't have time to reboot my computer to Windows at the moment. :-)

If anyone else has time to confirm the fix with OpenXR on Windows, that'd be awesome! Otherwise, I'll give it a test later when I've got a chance.

@BastiaanOlij BastiaanOlij force-pushed the fix_gles3_stereo_output branch from b5b6d6d to 37b7f57 Compare June 20, 2025 00:45
Copy link
Contributor

@devloglogan devloglogan left a comment

Choose a reason for hiding this comment

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

LGTM!

@akien-mga akien-mga merged commit 595395c into godotengine:master Jun 21, 2025
20 checks passed
@akien-mga
Copy link
Member

Thanks!

@BastiaanOlij BastiaanOlij deleted the fix_gles3_stereo_output branch June 21, 2025 10:38
@BastiaanOlij BastiaanOlij moved this from Fix pending review to Done in XR Issue Triage Jun 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

OpenXR compatibility no longer outputting correct colors on desktop
4 participants