Skip to content

[HDRP][Path Tracing] Added alpha channel to path traced results #3127

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 5 commits into from
Jan 18, 2021

Conversation

eturquin
Copy link
Contributor

@eturquin eturquin commented Jan 15, 2021

Addresses https://fogbugz.unity3d.com/f/cases/1304187/

The alpha channel of path-traced images was always set to 1.
Now, if there is no sky, it will use the alpha value of the clear color on camera ray misses (set to 0 by default), to match rasterization behaviour.

This change has been tested with and without presence of sky, and with a clear color with alpha going from 0 to 1:

  • with a sky: output alpha is 1
  • without a sky: output alpha is equal to alpha of the clear color
  • if a ray hit a geometry, alpha is 1 (no matter if the material has refraction or not)

Note that for now, volumetrics are ignored and won't affect the alpha.

@pmavridis
Copy link
Contributor

Perhaps it is worth backporting this to 10.x? The PR seems simple-enough/back-portable.

Copy link
Contributor

@sebastienlagarde sebastienlagarde left a comment

Choose a reason for hiding this comment

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

Agree for backporting to 10.x.
The PR miss a changelog
and we should update the doc about alpha to say that it also work with path tracer

https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@10.2/manual/Alpha-Output.html

@eturquin
Copy link
Contributor Author

The PR miss a changelog
and we should update the doc about alpha to say that it also work with path tracer

Ok, adding both.

@eturquin eturquin marked this pull request as ready for review January 15, 2021 17:51
Copy link
Contributor

@remi-chapelain remi-chapelain left a comment

Choose a reason for hiding this comment

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

Tested with a camera outputting the path traced result to a render texture and then using the texture in a transparent and/or a opaque alpha clipped material. ✔️
Tested that it only worked with Sky setup to None ✔️
Don't know if "worth doc mentioning" but worth noting a few things even though they're expected :

  • HDRP Color buffer needs to be setup with an alpha channel (R16B16G16A16) for this PR to have any effect
  • Doesn't work with Unity Recorder (Recorder does not care about alpha)
  • Doesn't work with CaptureScreenshot (Game view discards alpha)

Thanks to @pmavridis who helped me test this.

606e1293d2254aaf49f5c66979c4f30e.mp4

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

Successfully merging this pull request may close these issues.

4 participants