Skip to content

[7.x.x Backport] Fix an issue in reading the gbuffer for ray traced subsurface scattering (case 1248358) #538

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 1 commit into from
May 18, 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
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 @@ -90,6 +90,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed issue that prevented cubemap thumbnails from rendering (only on D3D11 and Metal).
- Fixed Microshadow not working correctly in deferred with LightLayers
- Tentative fix for missing include in depth of field shaders.
- Fix an issue in reading the gbuffer for ray traced subsurface scattering (case 1248358).

### Changed
- Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,6 @@ void RenderSubsurfaceScattering(HDCamera hdCamera, CommandBuffer cmd, RTHandle c
// Bind the textures for ray generation
cmd.SetRayTracingTextureParam(subSurfaceShader, HDShaderIDs._DepthTexture, sharedRTManager.GetDepthStencilBuffer());
cmd.SetRayTracingTextureParam(subSurfaceShader, HDShaderIDs._NormalBufferTexture, sharedRTManager.GetNormalBuffer());
cmd.SetRayTracingTextureParam(subSurfaceShader, HDShaderIDs._GBufferTexture[0], m_GbufferManager.GetBuffer(0));
cmd.SetRayTracingTextureParam(subSurfaceShader, HDShaderIDs._GBufferTexture[1], m_GbufferManager.GetBuffer(1));
cmd.SetRayTracingTextureParam(subSurfaceShader, HDShaderIDs._GBufferTexture[2], m_GbufferManager.GetBuffer(2));
cmd.SetRayTracingTextureParam(subSurfaceShader, HDShaderIDs._GBufferTexture[3], m_GbufferManager.GetBuffer(3));
cmd.SetRayTracingTextureParam(subSurfaceShader, HDShaderIDs._SSSBufferTexture, m_SSSColor);
cmd.SetGlobalTexture(HDShaderIDs._StencilTexture, sharedRTManager.GetDepthStencilBuffer(), RenderTextureSubElement.Stencil);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,9 @@ void RayGenSubSurface()
PositionInputs posInput = GetPositionInput(currentPixelCoord, 1.0/LaunchDim.xy, depthValue, UNITY_MATRIX_I_VP, GetWorldToViewMatrix(), 0);
posInput.positionWS = GetAbsolutePositionWS(posInput.positionWS);

// Read the bsdf data and builtin data from the gbuffer
BSDFData bsdfData;
ZERO_INITIALIZE(BSDFData, bsdfData);
BuiltinData builtinData;
ZERO_INITIALIZE(BuiltinData, builtinData);
uint featureFlags = MATERIALFEATUREFLAGS_LIT_SUBSURFACE_SCATTERING;
DecodeFromGBuffer(currentPixelCoord, featureFlags, bsdfData, builtinData);
// Read the normal data
NormalData normalData;
DecodeFromNormalBuffer(currentPixelCoord, normalData);

// Read the SSS Data
SSSData sssData;
Expand All @@ -88,7 +84,7 @@ void RayGenSubSurface()

// Do our walk
ScatteringResult scatteringResult;
ScatteringWalk(bsdfData.normalWS, bsdfData.diffuseColor, scatteringDistance, currentPixelCoord, globalSampleIndex, posInput.positionWS, scatteringResult);
ScatteringWalk(normalData.normalWS, sssData.diffuseColor, scatteringDistance, currentPixelCoord, globalSampleIndex, posInput.positionWS, scatteringResult);

// Normalize the throughput
scatteringResult.outputThroughput /= (float)_RaytracingNumSamples;
Expand Down