Skip to content
Merged
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ -726,6 +726,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed robustness issue with GetOddNegativeScale() in ray tracing, which was impacting normal mapping (1261160).
- Fixed regression where moving face of the probe gizmo was not moving its position anymore.
- Fixed XR single-pass macros in tessellation shaders.
- Fixed path-traced subsurface scattering mixing with diffuse and specular BRDFs (1250601).

### Changed
- Improve MIP selection for decals on Transparents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ bool CreateMaterialData(PathIntersection pathIntersection, BuiltinData builtinDa
// Otherwise, we just compute BSDFs as usual
mtlData.subsurfaceWeightFactor = 1.0 - subsurfaceWeight;

mtlData.bsdfWeight[0] -= subsurfaceWeight;
mtlData.bsdfWeight[0] = max(mtlData.bsdfWeight[0] - subsurfaceWeight, BSDF_WEIGHT_EPSILON);
mtlData.bsdfWeight /= mtlData.subsurfaceWeightFactor;

sample -= subsurfaceWeight;
Expand Down Expand Up @@ -147,8 +147,7 @@ bool SampleMaterial(MaterialData mtlData, float3 inputSample, out float3 sampleD
if (!BRDF::SampleLambert(mtlData, inputSample, sampleDir, result.diffValue, result.diffPdf))
return false;

result.diffValue *= mtlData.bsdfData.ambientOcclusion * mtlData.bsdfData.subsurfaceMask * (1.0 - mtlData.bsdfData.transmittanceMask);
result.diffPdf *= mtlData.subsurfaceWeightFactor;
result.diffValue *= mtlData.bsdfData.ambientOcclusion * (1.0 - mtlData.bsdfData.transmittanceMask);

return true;
}
Expand All @@ -175,7 +174,7 @@ bool SampleMaterial(MaterialData mtlData, float3 inputSample, out float3 sampleD
result.specPdf += mtlData.bsdfWeight[1] * pdf;
}

result.diffValue *= mtlData.bsdfData.ambientOcclusion * (1.0 - mtlData.bsdfData.subsurfaceMask) * (1.0 - mtlData.bsdfData.transmittanceMask) * (1.0 - fresnelClearCoat);
result.diffValue *= mtlData.bsdfData.ambientOcclusion * (1.0 - mtlData.bsdfData.transmittanceMask) * (1.0 - fresnelClearCoat);

if (mtlData.bsdfWeight[2] > BSDF_WEIGHT_EPSILON)
{
Expand All @@ -196,7 +195,7 @@ bool SampleMaterial(MaterialData mtlData, float3 inputSample, out float3 sampleD
if (mtlData.bsdfWeight[0] > BSDF_WEIGHT_EPSILON)
{
BRDF::EvaluateDiffuse(mtlData, sampleDir, result.diffValue, result.diffPdf);
result.diffValue *= mtlData.bsdfData.ambientOcclusion * (1.0 - mtlData.bsdfData.subsurfaceMask) * (1.0 - mtlData.bsdfData.transmittanceMask) * (1.0 - fresnelClearCoat);
result.diffValue *= mtlData.bsdfData.ambientOcclusion * (1.0 - mtlData.bsdfData.transmittanceMask) * (1.0 - fresnelClearCoat);
result.diffPdf *= mtlData.bsdfWeight[0];
}

Expand Down Expand Up @@ -226,7 +225,7 @@ bool SampleMaterial(MaterialData mtlData, float3 inputSample, out float3 sampleD
if (mtlData.bsdfWeight[0] > BSDF_WEIGHT_EPSILON)
{
BRDF::EvaluateDiffuse(mtlData, sampleDir, result.diffValue, result.diffPdf);
result.diffValue *= mtlData.bsdfData.ambientOcclusion * (1.0 - mtlData.bsdfData.subsurfaceMask) * (1.0 - mtlData.bsdfData.transmittanceMask) * (1.0 - fresnelClearCoat);
result.diffValue *= mtlData.bsdfData.ambientOcclusion * (1.0 - mtlData.bsdfData.transmittanceMask) * (1.0 - fresnelClearCoat);
result.diffPdf *= mtlData.bsdfWeight[0];
}
}
Expand All @@ -248,8 +247,8 @@ bool SampleMaterial(MaterialData mtlData, float3 inputSample, out float3 sampleD
#endif

#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
result.diffPdf *= mtlData.subsurfaceWeightFactor;
result.specPdf *= mtlData.subsurfaceWeightFactor;
// We compensate for the fact that there is no spec when computing SSS
result.specValue /= mtlData.subsurfaceWeightFactor;
#endif
}
else // Below
Expand Down Expand Up @@ -295,8 +294,7 @@ void EvaluateMaterial(MaterialData mtlData, float3 sampleDir, out MaterialResult
if (mtlData.isSubsurface)
{
BRDF::EvaluateLambert(mtlData, sampleDir, result.diffValue, result.diffPdf);
result.diffValue *= mtlData.bsdfData.subsurfaceMask * (1.0 - mtlData.bsdfData.transmittanceMask); // AO purposedly ignored here
result.diffPdf *= mtlData.subsurfaceWeightFactor;
result.diffValue *= 1.0 - mtlData.bsdfData.transmittanceMask; // AO purposedly ignored here

return;
}
Expand All @@ -319,7 +317,7 @@ void EvaluateMaterial(MaterialData mtlData, float3 sampleDir, out MaterialResult
if (mtlData.bsdfWeight[0] > BSDF_WEIGHT_EPSILON)
{
BRDF::EvaluateDiffuse(mtlData, sampleDir, result.diffValue, result.diffPdf);
result.diffValue *= (1.0 - mtlData.bsdfData.transmittanceMask) * (1.0 - mtlData.bsdfData.subsurfaceMask) * (1.0 - fresnelClearCoat); // AO purposedly ignored here
result.diffValue *= (1.0 - mtlData.bsdfData.transmittanceMask) * (1.0 - fresnelClearCoat); // AO purposedly ignored here
result.diffPdf *= mtlData.bsdfWeight[0];
}

Expand All @@ -331,8 +329,8 @@ void EvaluateMaterial(MaterialData mtlData, float3 sampleDir, out MaterialResult
}

#ifdef _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
result.diffPdf *= mtlData.subsurfaceWeightFactor;
result.specPdf *= mtlData.subsurfaceWeightFactor;
// We compensate for the fact that there is no spec when computing SSS
result.specValue /= mtlData.subsurfaceWeightFactor;
#endif
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ bool RandomWalk(float3 position, float3 normal, float3 diffuseColor, float3 mean
// Evaluate the length of our steps
rayDesc.TMax = -log(1.0 - distSample) / sigmaT[channelIdx];

// Sample our next sepath segment direction
// Sample our next path segment direction
rayDesc.Direction = walkIdx ?
SampleSphereUniform(dirSample0, dirSample1) : SampleHemisphereCosine(dirSample0, dirSample1, -normal);

Expand All @@ -489,7 +489,7 @@ bool RandomWalk(float3 position, float3 normal, float3 diffuseColor, float3 mean
TraceRay(_RaytracingAccelerationStructure, RAY_FLAG_FORCE_OPAQUE | RAY_FLAG_CULL_FRONT_FACING_TRIANGLES,
RAYTRACINGRENDERERFLAG_PATH_TRACING, 0, 1, 1, rayDesc, intersection);

// Define if we did a hit
// Check if we hit something
hit = intersection.t > 0.0;

// How much did the ray travel?
Expand All @@ -513,10 +513,24 @@ bool RandomWalk(float3 position, float3 normal, float3 diffuseColor, float3 mean
while (!hit && walkIdx < MAX_WALK_STEPS);

// Set the exit intersection position and normal
result.exitPosition = rayDesc.Origin;
result.exitNormal = intersection.value;
if (!hit)
{
result.exitPosition = position;
result.exitNormal = normal;
result.throughput = diffuseColor;

// By not returning false here, we default to a diffuse BRDF when an intersection is not found;
// this is physically wrong, but may prove more convenient for a user, as results will look
// like diffuse instead of getting slightly darker when the mean free path becomes shorter.
//return false;
}
else
{
result.exitPosition = rayDesc.Origin;
result.exitNormal = intersection.value;
}

return hit;
return true;
}

} // namespace SSS
Expand Down