Skip to content

[Fogbugz 1330769] Fixing bloom bicubic filtering for DRS #4370

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 4 commits into from
Apr 30, 2021

Conversation

kecho
Copy link
Contributor

@kecho kecho commented Apr 28, 2021

Purpose of this PR

Bicubic filtering of bloom was using the wrong dimensions / coordinates for bloom. This PR applies the correct scaling to such parameters.
Fogbugz: https://fogbugz.unity3d.com/f/cases/1330769/
Repro steps in fogbugs

Tested, hardware drs, percentage of 10 to exaggerate artifact:

Before:
image

After:
image


Testing status

  • Tested on hardware DRS, vulkan and dx12 PC
  • Should be tested in consoles (one is enough, i.e. PS4)

@kecho kecho force-pushed the HDRP/FixDRSBloom branch from 48e6d50 to 35cb082 Compare April 28, 2021 18:36
@FrancescoC-unity
Copy link
Contributor

FrancescoC-unity commented Apr 29, 2021

Did you try with SW dyn res too? I am a bit confused as HW dynamic res should have those constants you multiply with should be too far off 1 if a single view is there.

Changes look good I am just a tad confused on why the big difference, I guess we have another camera active? Or maybe depending on starting res the rounding is relevant as going down the mip chain?

@@ -3165,6 +3165,13 @@ void PrepareBloomData(RenderGraph renderGraph, in RenderGraphBuilder builder, Bl
// the mip up 0 will be used by uber, so not allocated as transient.
m_BloomBicubicParams = new Vector4(passData.bloomMipInfo[0].x, passData.bloomMipInfo[0].y, 1.0f / passData.bloomMipInfo[0].x, 1.0f / passData.bloomMipInfo[0].y);
var mip0Scale = new Vector2(passData.bloomMipInfo[0].z, passData.bloomMipInfo[0].w);

//apply DRS on bloom bicubic params
m_BloomBicubicParams.x /= RTHandles.rtHandleProperties.rtHandleScale.x;
Copy link
Contributor

@FrancescoC-unity FrancescoC-unity Apr 29, 2021

Choose a reason for hiding this comment

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

So these parameters should be baked in the actualWidth/actualHeight used here https://github.com/Unity-Technologies/Graphics/pull/4370/files#diff-617165acfec9a5b4c1b26809291f30938d7a152b8e9fec0e5ae2c661078201dbR3148 , by dividing we are undoing that and assuming full resolution source?

I might be misreading here as I didn't have my coffee yet, but worth double checking values :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes! we want exactly that, the actual full resolution of the texture. To understand why, you need to look at bicubic sampling. Thats were these params are used. Bicubic sampling function requires texel size to compute the offsets, but the texel size must be that of the physical texture (so the uv can be offset correctly).
If we use instead say texture.width here, then we have to write special code for hardware drs, because hardware drs hides the render - time resource size. So the easiest way is to just 'undo' the texture scale.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@FrancescoC-unity I have added a comment on this snippet to explain it

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup it does make sense 👍

@kecho
Copy link
Contributor Author

kecho commented Apr 29, 2021

Did you try with SW dyn res too? I am a bit confused as HW dynamic res should have those constants you multiply with should be too far off 1 if a single view is there.

Changes look good I am just a tad confused on why the big difference, I guess we have another camera active? Or maybe depending on starting res the rounding is relevant as going down the mip chain?

Yes so the answer is that hardware res can also have a possible rtHandle scale that is not 1, due to for example planar reflections being present and sharing the same large core textures.
The problem is also aggravated by bicubic sampling, the offsets you see are actually for bicubic sampling, and the offsets are in iv space, so something like 1/hardware width. If that doesnt happen, you can get huge jumps and stair stepping.
I exagerated the problem in the screen shots, used a %10 scale to show the insanely bad offsets

@FrancescoC-unity
Copy link
Contributor

FrancescoC-unity commented Apr 29, 2021

Did you try with SW dyn res too? I am a bit confused as HW dynamic res should have those constants you multiply with should be too far off 1 if a single view is there.
Changes look good I am just a tad confused on why the big difference, I guess we have another camera active? Or maybe depending on starting res the rounding is relevant as going down the mip chain?

Yes so the answer is that hardware res can also have a possible rtHandle scale that is not 1, due to for example planar reflections being present and sharing the same large core textures.
The problem is also aggravated by bicubic sampling, the offsets you see are actually for bicubic sampling, and the offsets are in iv space, so something like 1/hardware width. If that doesnt happen, you can get huge jumps and stair stepping.
I exagerated the problem in the screen shots, used a %10 scale to show the insanely bad offsets

Yes I got that, but that implies that the problem is not there without extra cameras without this PR no? Does it go away?

The SW should show the issue even more for the same rationale (texture width differes from operating width a fair bit)

EDIT: Seeing the bicubic filter now, yeah the sw should do this even more likely as mismatch is likely wider

@sebastienlagarde sebastienlagarde marked this pull request as ready for review April 30, 2021 07:59
@RemyUnity RemyUnity requested a review from TomasKiniulis April 30, 2021 14:37
Copy link
Contributor

@RemyUnity RemyUnity left a comment

Choose a reason for hiding this comment

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

Tested and fixe confirmed on PC.
@TomasKiniulis will check on console for final approval.

Copy link
Contributor

@TomasKiniulis TomasKiniulis left a comment

Choose a reason for hiding this comment

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

Testing repro project on Xbox looks all good as well

@sebastienlagarde sebastienlagarde merged commit d2c8c43 into hd/bugfix Apr 30, 2021
@sebastienlagarde sebastienlagarde deleted the HDRP/FixDRSBloom branch April 30, 2021 16:55
sebastienlagarde added a commit that referenced this pull request Apr 30, 2021
* Fix null exception on Raytracing SSS volume component (#4322)

* Add null check

* changelog

* Fix issue with Eye shader and area light (#4310)

* Fix Ray Tracing Light Cluster debug mode (#4327)

* Remove unneeded position from input layout of light cluster

* Changelog

Co-authored-by: sebastienlagarde <sebastien@unity3d.com>

* Skip adding the LOD's renderer to the checked renderer if it's null (#4313)

* Skip adding the LOD's renderer to the checked renderer if it's null

* changelog

* Add LODgroup missing renderer to "check scene content for ray tracing"

* formatting test

* formatting

Co-authored-by: sebastienlagarde <sebastien@unity3d.com>

* Update doc of transparent motion vectors to specify TAA of object behind will be impacted (#4325)

* Update doc

* Fix doc

* Fixed Look Dev breaking when docked and rendered at zero size. (#4331)

* Fixed an issue where sometime a docked lookdev could be rendered at zero size and break.

* Update changelog

# Conflicts:
#	com.unity.render-pipelines.high-definition/CHANGELOG.md

Co-authored-by: sebastienlagarde <sebastien@unity3d.com>

* [HDRP] Added a bit about scaling issues when dealing with history buffers (#4333)

* Updated troubleshooting custom pass doc

* Update Custom-Pass-Troubleshooting.md

* Fixed an issue where runtime debug window UI would leak game objects. (#4337)

* Fixed an issue where runtime debug window UI would leak game objects.

* Update changelog

* Updated documentation to support #4313 (#4336)

Co-authored-by: Sebastien Lagarde <sebastien@unity3d.com>

* Fixed NaNs when denoising pixels where the dot product between normal and view direction is near zero (#4342)

Co-authored-by: sebastienlagarde <sebastien@unity3d.com>

* updated tooltip (#4334)

* Doc for custom matrix for fog (#4352)

* [Fogbugz 1324000] Fixing unlit emissive reflections (#4340)

* Fix ray tracing unlit emissive exposure.

Changelog

* Automated tests coverage

* update scenes

Co-authored-by: Remi Chapelain <remi.chapelain@unity3d.com>
Co-authored-by: sebastienlagarde <sebastien@unity3d.com>

* [Fogbugz 1329173] Fixing wrong pyramid color dimensions when hardware DRS is on. (#4346)

* Fixing bad pyramid color source texture size. DRS hanlder must be queried since the mip levels depend on the source hardware resolution

* Changelog

Co-authored-by: sebastienlagarde <sebastien@unity3d.com>

* Fix RTHandle scale bias [1329977] (#4320)

* Fix RTHandle scale bias

* Add changelog

* Fix history sacle

* Fix

Co-authored-by: sebastienlagarde <sebastien@unity3d.com>

* Fixed emission material properties not being animable (#4366)

* Fixed emission material properties not being animable

* Updated changelog

Co-authored-by: sebastienlagarde <sebastien@unity3d.com>

* Fix fog precision (#4364)

Co-authored-by: sebastienlagarde <sebastien@unity3d.com>

* Fix erroneous tile coordinate calculations in contact shadows (#4335)

* Fix wrong tile coord calculations

* Changelog

* Update test scene for contact shadow to cover data

* update references screenshots

Co-authored-by: Sebastien Lagarde <sebastien@unity3d.com>

* [HDRP]Fix history buffer allocation for AOVs when the request does not come in first frame (#4361)

* Fix  history buffer allocation for AOVs when the request does not come in first frame

* Add a break in the for loop

Co-authored-by: sebastienlagarde <sebastien@unity3d.com>

* Fix for volumetric clouds performing Read and Write on same texture [Unsupported on some platforms] (#4356)

* Fix for usage of camera color RW when not supported.

* Re-enable on metal

* changelog

Co-authored-by: sebastienlagarde <sebastien@unity3d.com>

* Update TestCaseFilters.asset

* update metal screenshots

* missing meta

* [Fogbugz 1330769] Fixing bloom bicubic filtering for DRS (#4370)

* Fixing bloom bicubic filtering for DRS, bicubic was using the wrong dimensions / texel sizes

* Adding better comment to explain offseting of bicubic texture offset fix

* update reference screenshots

Co-authored-by: sebastienlagarde <sebastien@unity3d.com>

Co-authored-by: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com>
Co-authored-by: Rémi Chapelain <57442369+remi-chapelain@users.noreply.github.com>
Co-authored-by: JulienIgnace-Unity <julien@unity3d.com>
Co-authored-by: Antoine Lelievre <antoinel@unity3d.com>
Co-authored-by: Lewis Jordan <lewis.jordan@hotmail.co.uk>
Co-authored-by: Pavlos Mavridis <pavlos.mavridis@unity3d.com>
Co-authored-by: Adrien de Tocqueville <adrien.tocqueville@unity3d.com>
Co-authored-by: Kleber Garcia <kleber.garcia@unity3d.com>
Co-authored-by: Remi Chapelain <remi.chapelain@unity3d.com>
Co-authored-by: skhiat <55133890+skhiat@users.noreply.github.com>
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.

5 participants