Skip to content

Fix Panini Projection for floating point color buffers (Case 1325845) #4133

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
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed broken Lanczos filter artifacts on ps4, caused by a very aggressive epsilon (case 1328904)
- Fixed global Settings ignore the path set via Fix All in HDRP wizard (case 1327978)
- Fixed GBuffer clear option in FrameSettings not working
- Fixed usage of Panini Projection with floating point HDRP and Post Processing color buffers.

### Changed
- Changed Window/Render Pipeline/HD Render Pipeline Wizard to Window/Rendering/HDRP Wizard
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/PostProcessDefines.hlsl"

#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch

#pragma kernel KMain

#pragma multi_compile GENERIC UNITDISTANCE
#pragma multi_compile _ ENABLE_ALPHA

TEXTURE2D_X(_InputTexture);

RW_TEXTURE2D_X(float3, _OutputTexture);
RW_TEXTURE2D_X(CTYPE, _OutputTexture);

SAMPLER(sampler_LinearClamp);

Expand Down Expand Up @@ -125,7 +127,7 @@ void KMain(uint3 dispatchThreadId : SV_DispatchThreadID)
}
else
{
float3 smp = SAMPLE_TEXTURE2D_X_LOD(_InputTexture, sampler_LinearClamp, ClampAndScaleUVForBilinear(coords), 0.0).xyz;
CTYPE smp = SAMPLE_TEXTURE2D_X_LOD(_InputTexture, sampler_LinearClamp, ClampAndScaleUVForBilinear(coords), 0.0).CTYPE_SWIZZLE;
_OutputTexture[COORD_TEXTURE2D_X(posInputs.positionSS)] = smp;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3019,6 +3019,9 @@ TextureHandle PaniniProjectionPass(RenderGraph renderGraph, HDCamera hdCamera, T
else
passData.paniniProjectionCS.EnableKeyword("UNITDISTANCE");

if (m_EnableAlpha)
Copy link
Contributor

Choose a reason for hiding this comment

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

You may want to add the else statement to disable the keyword.
It will avoid issues when doing two cameras back to back with one using alpha and the other not. The second camera would then not use the proper keyword.
(It's not currently possible to have different color buffer types per camera but with render graph it should be soon a possibility so might as well do it right now)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do - also there are a few other instances in the post stack that only enable that keyword, like Stop NaNs pass:

if (m_EnableAlpha)
passData.nanKillerCS.EnableKeyword("ENABLE_ALPHA");

I can also fix that up for the other instances of it in this PR.

passData.paniniProjectionCS.EnableKeyword("ENABLE_ALPHA");

passData.paniniParams = new Vector4(viewExtents.x, viewExtents.y, paniniD, paniniS);
passData.paniniProjectionKernel = passData.paniniProjectionCS.FindKernel("KMain");

Expand Down