Skip to content

Commit f814383

Browse files
committed
Improved behaviour of media with respect to large distances or high densities (method 3 only).
1 parent 1968b7d commit f814383

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

changes.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ Reported via Windows Crash Reports:
373373

374374
Miscellaneous:
375375

376+
- Fixed media cutting out or fading to black above the horizon (sample method
377+
3 only; other methods remain problematic).
376378
- Animation status messages now consistently display a running frame count and
377379
the total number of frames actually to be rendered, properly taking into
378380
account the Frame_Step setting.

source/core/material/media.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,18 @@ void MediaFunction::ComputeMediaAdaptiveSampling(MediaVector& medias, LightSourc
457457
// keep a sum of the results
458458
// do some attenuation, too, since we are doing samples in order
459459
// TODO - we could do even better if we handled attenuation on a per-sample basis
460-
i->te += Result * Exp(-(i->od + ODResult * 0.5) * dd);
460+
461+
// Compute attenuation due to earlier sub-intervals.
462+
Result *= Exp(-(i->od) * dd);
463+
// Compute attenuation due to the sub-interval itself.
464+
// NB: This formula is mathematically precise under the presumption that the ratio of emission to absorbtion
465+
// remains constant throughout the entire sub-interval.
466+
for (int iChannel = 0; iChannel < Result.channels; ++iChannel)
467+
{
468+
if (ODResult[iChannel] != 0.0)
469+
Result[iChannel] *= (1.0 - exp(-ODResult[iChannel] * dd)) / (ODResult[iChannel] * dd);
470+
}
471+
i->te += Result;
461472

462473
// move c1 to c0 to go on to next sample/interval
463474
C0 = C1;

0 commit comments

Comments
 (0)