Skip to content

Linear Color Space #14

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

Open
matijamandurov opened this issue Nov 17, 2021 · 7 comments
Open

Linear Color Space #14

matijamandurov opened this issue Nov 17, 2021 · 7 comments
Assignees
Labels
question Further information is requested

Comments

@matijamandurov
Copy link

Does the project support the Linear Color Space option, background removal seems to be greatly reduced in quality when switching from Gamma to Linear Color Space?

@keijiro keijiro self-assigned this Nov 17, 2021
@keijiro keijiro added the question Further information is requested label Nov 17, 2021
@keijiro
Copy link
Owner

keijiro commented Nov 17, 2021

Maybe you have to add linear-to-gamma conversion to the preprocess compute kernel.

@matijamandurov
Copy link
Author

Perfect, thank you. Do you have a quick example of how I could add that. I assume I have to convert the rgb component using a method similar to this, only in the other direction?

http://chilliant.blogspot.com/2012/08/srgb-approximations-for-hlsl.html?m=1

@keijiro
Copy link
Owner

keijiro commented Nov 18, 2021

Yes.

@matijamandurov
Copy link
Author

Thank you, so I tried adding the above formula to both the Preprocess Compute Shader and the Compositor Compute Shader but there seems to be some issues with it. The closest I have come to getting the same quality of the cutout was if I added the conversion twice in the Compositor. Do you by any chance know exactly where in the flow should I be converting from Gamma to Linear?

@keijiro
Copy link
Owner

keijiro commented Nov 20, 2021

@SilverXenolupus
Copy link

After struggling with this one for a while, I found that if you change line 84 of SegmentationFilter.cs to
var segsRT = output.ToRenderTexture(RenderTextureFormat.DefaultHDR, 0, 0, 1.0f / 32, 0.5f);,
the lost data is conserved. The problem was the RenderTexture was losing data outside the 0 and 1 range that the Linear colorspace is not confined to, so the RenderTexture must be HDR. No other changes are necessary.

@matijamandurov
Copy link
Author

perfect. Works just as expected. Consider this resolved and maybe should be added to the project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants