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

Black get_texture() from viewport on desktop, works fine on mobile. #93422

Closed
Bimbam360 opened this issue Jun 21, 2024 · 4 comments · Fixed by #94233
Closed

Black get_texture() from viewport on desktop, works fine on mobile. #93422

Bimbam360 opened this issue Jun 21, 2024 · 4 comments · Fixed by #94233

Comments

@Bimbam360
Copy link

Bimbam360 commented Jun 21, 2024

Tested versions

  • Reproducible in v4.3.beta1.official [a4f2ea9] and v4.3.beta2.official [b75f048]

System information

Pop!_OS 22.04 LTS - X11 - GLES3 (Compatibility)

Issue description

This code (based on the sample in the docs) successfully produces screenshots on Android mobile:

	await RenderingServer.frame_post_draw
	var tex = Globals.main_viewport.get_texture().get_image().get_region(region)
	tex.save_png("user://creator/level_"+str(Globals.creator_level_id)+".png

This works fine on Android:
image

But on Desktop:
image

This was also present on Windows 11, but am now on PopOS.

This seems to be caused by enabling Use HDR 2D, but it is unclear why it behaves differently for desktop.

Steps to reproduce

See description.

Minimal reproduction project (MRP)

Will make one if required.

@matheusmdx
Copy link
Contributor

Tested on latest master [04bf7d4] and i can confirm the issue, also the forward and mobile rendering mode shows a different behaviour with HDR and get_viewport().get_texture().get_image().save_png()

HDR Test


In editor and playing the scene the image is rendered normally, like the no hdr image, but saving the viewport texture show the results in the image above.

I bisected the issue and found a culprit for the compatibility issue and another for the forward/mobile


Compatibility culprit: #87360

Captura 2024-06-22 19-51-56-322391


Forward/mobile culprit: #80215

Captura 2024-06-23 02-06-16-261316

@clayjohn
Copy link
Member

@matheusmdx Great work!

The output of the Forward+ and Mobile renderers are what is expected with the HDR2D mode enabled as the image is stored in an HDR format in linear space, instead of in an LDR format in sRGB space. #92496 documents this requirement and adds a helpful linear_to_srgb() function to make converting the texture easier.

For the compatibility renderer it seems like it is copying from the wrong texture when doing the screen copy. We will likely need to add some logic to the function that copies the screen texture to ensure that it is copying from the correct texture

@ChristopheClaustre
Copy link
Contributor

@matheusmdx thanks you for introducing me to the git bisect command I didn't know and it seems awesome.
Did you take the correction of the wrong texture copied in compatibility as @clayjohn mentionned or can I look at it ?

Also @clayjohn is HDR feature available in compatibility ?

@matheusmdx
Copy link
Contributor

Did you take the correction of the wrong texture copied in compatibility as @clayjohn mentionned or can I look at it ?

I don't know where this adjust needs to be done so feel free to take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

6 participants