Skip to content
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 @@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed timing issues with accumulation motion blur
- Fixed an issue with the frame count management for the volumetric fog (case 1299251).
- Fixed an issue with material using distortion from ShaderGraph init after Material creation (case 1294026)
- Fixed issues with path-traced volumetric scattering (cases 1295222, 1295234).

### Changed
- Removed the material pass probe volumes evaluation mode.
Expand All @@ -49,6 +50,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Density Volumes can now take a 3D RenderTexture as mask, the mask can use RGBA format for RGB fog.
- Decreased the minimal Fog Distance value in the Density Volume to 0.05.
- Changed the convergence time of ssgi to 16 frames and the preset value
- Improved robustness of volumetric sampling in path tracing (case 1295187).

## [10.3.0] - 2020-12-01

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,68 +52,46 @@ bool SampleVolumeScatteringPosition(inout float sample, inout float t, inout flo
tMax = tFog;
#endif

// FIXME: not quite sure what the sigmaS, sigmaT values are supposed to be...
const float sigmaS = (t == FLT_MAX) ? 1.0 : sqrt(Luminance(_HeightFogBaseScattering.xyz));
// FIXME: not quite sure what the sigmaT value is supposed to be...
const float sigmaT = _HeightFogBaseExtinction;
const float transmittanceMax = exp(-tMax * sigmaT);
const float transmittanceTMax = max(exp(-tMax * sigmaT), 0.01);
const float transmittanceThreshold = t < FLT_MAX ? 1.0 - min(0.5, transmittanceTMax) : 1.0;

const float pdfNoVolA = 1.0 - sigmaS;
const float pdfNoVolB = sigmaS * transmittanceMax;
const float pdfNoVol = pdfNoVolA + pdfNoVolB;
pdfVol *= 1.0 - pdfNoVol;

if (sample >= sigmaS)
if (sample >= transmittanceThreshold)
{
// Re-scale the sample
sample -= sigmaS;
sample /= 1.0 - sigmaS;
sample -= transmittanceThreshold;
sample /= 1.0 - transmittanceThreshold;

// Set the pdf
pdf *= pdfNoVol;
// Adjust the pdf
pdf *= 1.0 - transmittanceThreshold;

return false;
}

// Re-scale the sample
sample /= sigmaS;

// Evaluate the length to a potential volume scattering event
if (-log(1.0 - sample) / sigmaT >= tMax)
{
// Re-scale the sample
sample -= 1.0 - transmittanceMax;
sample /= transmittanceMax;

// Set the pdf
pdf *= pdfNoVol;
sample /= transmittanceThreshold;

return false;
}
// Adjust the pdf
pdf *= pdfVol * transmittanceThreshold;

if (sampleLocalLights)
{
// Re-scale the sample
sample /= 1.0 - transmittanceMax;

// Linear sampling
float deltaT = tMax - tMin;
t = tMin + sample * deltaT;

// Set the pdf
pdf *= pdfVol / deltaT;
// Adjust the pdf
pdf /= deltaT;
}
else
{
// Let's (avoid very low transmittance, for robustness sake (minor bias)
if (transmittanceMax < 0.01)
sample = sample * 0.99 / (1.0 - transmittanceMax);

// Log sampling
float transmittance = 1.0 - sample;
// Exponential sampling
float transmittance = transmittanceTMax + sample * (1.0 - transmittanceTMax);
t = -log(transmittance) / sigmaT;

// Set the pdf
pdf *= pdfVol * sigmaT * transmittance;
// Adjust the pdf
pdf *= sigmaT * transmittance;
}

return true;
Expand Down