Skip to content

Hdrp/pt fix sss and accum #257

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 24, 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
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ bool CreateMaterialData(PathIntersection pathIntersection, BuiltinData builtinDa
mtlData.subsurfaceWeightFactor = subsurfaceWeight;

SSS::Result subsurfaceResult;
float3 meanFreePath = -0.001 / (_ShapeParamsAndMaxScatterDists[mtlData.bsdfData.diffusionProfileIndex].rgb * _WorldScalesAndFilterRadiiAndThicknessRemaps[mtlData.bsdfData.diffusionProfileIndex].x);
float3 meanFreePath = 0.001 / (_ShapeParamsAndMaxScatterDists[mtlData.bsdfData.diffusionProfileIndex].rgb * _WorldScalesAndFilterRadiiAndThicknessRemaps[mtlData.bsdfData.diffusionProfileIndex].x);

if (!SSS::RandomWalk(shadingPosition, mtlData.bsdfData.normalWS, mtlData.bsdfData.diffuseColor, meanFreePath, pathIntersection.pixelCoord, subsurfaceResult))
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ internal Vector4 GetFrameWeights()

float weight = isRecording ? ShutterProfile(time) : 1.0f;

m_AccumulatedWeight += weight;
if (m_CurrentIteration < m_AccumulationSamples)
m_AccumulatedWeight += weight;

if (m_AccumulatedWeight > 0)
{
return new Vector4(weight, totalWeight, 1.0f / m_AccumulatedWeight, 0.0f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ void RenderPathTracing(HDCamera hdCamera, CommandBuffer cmd, RTHandle outputText
cmd.SetGlobalTexture(HDShaderIDs._ScramblingTexture, m_Asset.renderPipelineResources.textures.scramblingTex);

// Inject the ray generation data

cmd.SetGlobalFloat(HDShaderIDs._RaytracingNumSamples, m_SubFrameManager.subFrameCount);
cmd.SetGlobalFloat(HDShaderIDs._RaytracingMinRecursion, m_PathTracingSettings.minimumDepth.value);
cmd.SetGlobalFloat(HDShaderIDs._RaytracingMaxRecursion, m_PathTracingSettings.maximumDepth.value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ void RayGenSubSurface()
DECODE_FROM_SSSBUFFER(posInput.positionSS, sssData);
float3 shapeParam = _ShapeParamsAndMaxScatterDists[sssData.diffusionProfileIndex].rgb * _WorldScalesAndFilterRadiiAndThicknessRemaps[sssData.diffusionProfileIndex].x;

// Deduce our scattering distance
// For some reason the value in shapeParam is negative, convert it to milimeters while we are there.
// Deduce our scattering distance (converted to mm)
float3 scatteringDistance = 1.0 / shapeParam * 0.001;

// Define which sample in the sequence we are up to.
Expand Down