Skip to content

Fix for white flash happening when changing lighting condition (like teleport) #140

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 7 commits into from
Apr 16, 2020
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
2 changes: 2 additions & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fix issue causing wrong planar reflection rendering when more than one camera is present.
- Fix black screen in XR when HDRP package is present but not used.
- Fixed an issue with the specularFGD term being used when the material has a clear coat (lit shader).
- Fixed white flash happening with auto-exposure in some cases (case 1223774)
- Fixed NaN which can appear with real time reflection and inf value

### Changed
- Color buffer pyramid is not allocated anymore if neither refraction nor distortion are enabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ float4 SampleEnv(LightLoopContext lightLoopContext, int index, float3 texCoord,
color.rgb = SampleSkyTexture(texCoord, lod, sliceIdx).rgb;
}

// Planar, Reflection Probes and Sky aren't pre-expose, so best to clamp to max16 here in case of inf
color.rgb = ClampToFloat16Max(color.rgb);

return color;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Shader "Hidden/HDRP/ScreenSpaceShadows"
#pragma target 4.5
#pragma only_renderers d3d11 playstation xboxone vulkan metal switch
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Builtin/BuiltinData.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/NormalBuffer.hlsl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,15 +351,26 @@ public void BeginFrame(CommandBuffer cmd, HDCamera camera, HDRenderPipeline hdIn
}
else
{
if (IsExposureFixed())
// Fix exposure is store in Exposure Textures at the beginning of the frame as there is no need for color buffer
// Dynamic exposure (Auto, curve) is store in Exposure Textures at the end of the frame (as it rely on color buffer)
// Texture current and previous are swapped at the beginning of the frame.
bool isFixedExposure = IsExposureFixed();
if (isFixedExposure)
{
using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.FixedExposure)))
{
DoFixedExposure(cmd, camera);
}
}

cmd.SetGlobalTexture(HDShaderIDs._ExposureTexture, GetExposureTexture(camera));
// Note: GetExposureTexture(camera) must be call AFTER the call of DoFixedExposure to be correctly taken into account
// When we use Dynamic Exposure and we reset history we can't use pre-exposure (as there is no information)
// For this reasons we put neutral value at the beginning of the frame in Exposure textures and
// apply processed exposure from color buffer at the end of the Frame, only for a single frame.
// After that we re-use the pre-exposure system
RTHandle currentExposureTexture = (camera.resetPostProcessingHistory && !isFixedExposure) ? m_EmptyExposureTexture : GetExposureTexture(camera);

cmd.SetGlobalTexture(HDShaderIDs._ExposureTexture, currentExposureTexture);
cmd.SetGlobalTexture(HDShaderIDs._PrevExposureTexture, GetPreviousExposureTexture(camera));
}
}
Expand Down Expand Up @@ -464,9 +475,9 @@ void PoolSource(ref RTHandle src, RTHandle dst)
cmd.DispatchCompute(cs, kernel, (camera.actualWidth + 7) / 8, (camera.actualHeight + 7) / 8, camera.viewCount);

PoolSource(ref source, destination);
}
}
}
}

if (m_PostProcessEnabled)
{
Expand Down Expand Up @@ -846,9 +857,9 @@ void DoDynamicExposure(CommandBuffer cmd, HDCamera camera, RTHandle colorBuffer)

if (camera.resetPostProcessingHistory)
{
kernel = cs.FindKernel("KReset");
cmd.SetComputeTextureParam(cs, kernel, HDShaderIDs._OutputTexture, prevExposure);
cmd.DispatchCompute(cs, kernel, 1, 1, 1);
// For Dynamic Exposure, we need to undo the pre-exposure from the color buffer to calculate the correct one
// When we reset history we must setup neutral value
prevExposure = m_EmptyExposureTexture; // Use neutral texture
}

m_ExposureVariants[0] = 1; // (int)exposureSettings.luminanceSource.value;
Expand Down