Commit Graph

11 Commits

Author SHA1 Message Date
chris kulla
703b25cc16 Path Tracer: re-enable mGPU support
Remove coherent sampler since it would be complicated to support in the mGPU case and isn't really necessary for performance anymore

#rb Jason.Hoerner
#preflight 624b79f09f404234149aec8e

[CL 19617353 by chris kulla in ue5-main branch]
2022-04-04 19:23:28 -04:00
chris kulla
b46d29e962 Implement Sky Atmosphere and Exponential Height Fog support in the Path Tracer
This is the start of volumetric support in the path tracer, so a lot of basic infrastructure had to be put into place, making this changelist fairly large. Some shuffling of light parameters had to be done to make room for the volumetric scattering multiplier.

The integration strategy is to use null tracking (with Spectral MIS) for choosing a random scatter point along the ray. This point is chosen similarly to transparent hits, so surface and volume shading are unified. However, these volume hits are chosen proportionally to transmittance times scattering which is not optimal for lights embedded in the volume. To handle the latter, we also allow the main trace call to return a volume segment over which we can compute the direct lighting from local light sources. To simplify the handling of overlapping media and inter-mixed transparent hits, we stochastically select a ray segment. From this point on, we can evaluate direct lighting using equi-angular sampling. The MIS combination of equi-angular sampling and null tracked spectral density sampling was prototyped but found not to bring any improvement for the currently implemented volume types. This will likely have to be revisited in the future.

To improve quality and reduce the amount of ray-marching required, the volume API allows for analytic implementations of transmittance for cases where this is possible to do more efficiently than by ray-marching.

Implementation details for Atmosphere: This volume type is a planet sized, spherically symetric model. Because the default units in UE are centimeters, objects like the planet that are kilometer sized will run into all sorts of numerical precision artifacts. To solve this, an implementation of double-word arithmetic was added which allows enough decimal digits to robustly intersect the planet, as well as cary out the lookups required. The Transmittance is cached in a lookup table indexed by height above the ground and viewing angle cosine. This is similar to the LUT used by the realtime version but with a different parameterization which covers the full range of angles/heights with high precision. This lookup table is automatically baked on demand when atmosphere parameters change. The volumetric sky model is only used when "reference atmosphere" is enabled in the post process volume. This is because the existing approached (cached into a skylight) is generally a bit faster and supports clouds. This toggle may be removed as the support for volumes matures.

Implementation details for ExponentialHeightFog: This volume is represented as a finite slab centered around the camera. Transmittance is easily computed analytically for this volume. We only add this volume when the volumetric fog checkbox is enabled, as the default parameters are not fully physically based. We limit the fog to be present only within a certain radius of the camera, to prevent rays from scattering forever.

#preflight 620ad32d583261b0a66af216
#rb Sebastien.Hillaire,Patrick.Kelly
#preflight 620dd2270931bfd925e5936b

[CL 19031069 by chris kulla in ue5-main branch]
2022-02-17 00:21:09 -05:00
chris kulla
dd3268b97e Avoid wave operations in path compaction shader which appears to give a slight speedup despite additional contention on the atomic and does not require running with SM6.
Implement tiled dispatch in the path tracer to reduce the likelyhood of GPU timeouts when rendering at high resolution. This also reduces the memory requirements for path state when running with path compaction enabled.

Change from a uint buffer to a structured buffer for storing path states which gives a small speedup.

Add indirect dispatch support to launch less work for compacted bounces (off by default as it does not seem to provide a speedup so far)

#jira TM-6595
#rb Juan.Canada
#robomerge 5.0
#preflight 61b27c6a2b48d03df526ce85
#preflight 61b28773ee0de9822e0f02de

[CL 18426885 by chris kulla in ue5-main branch]
2021-12-09 18:34:33 -05:00
chris kulla
4c6213cd1d Implement alpha channel support for the path tracer
To maintain consistency with the rasterizer implementation, keep track of background visibility (1.0 where there is background, 0.0 where there are solid objects). MRQ will flip this quantity before outputing to disk.

#rb Juan.Canada
#preflight 6149fccbe594c90001d9c558

[CL 17584574 by chris kulla in ue5-main branch]
2021-09-21 13:08:41 -04:00
chris kulla
9a973bae18 Implement absorption support for refractive translucent materials in the path tracer
The absorption coefficient is derived from the BaseColor of the material and a global scale factor that gives the inverse distance at which the target BaseColor is achieved. Setting this cvar to 0 disables the effect. The default value of 0.01 corresponds to specifing the target color after travelling through 1 meter of surface. This scale factor will not be needed in future material models that provide more direct control over the absorption color.

The implementation remembers the current absorption value as part of the PathState. For shadow rays, when approximate caustics are being used, the contribution is tracked by simply counting up/down at each interface. An offset is used to account for the possibility of light starting inside an object for finite light sources.

Refactored TraceTransparentRay to directly use the PathState struct since it was accessing most of its fields anyway and the function signature was getting too long

#rb Patrick.Kelly
#preflight 61422aac3c7c67000197ca0b

[CL 17524226 by chris kulla in ue5-main branch]
2021-09-15 14:42:45 -04:00
chris kulla
23759344ed Implement BxDF energy conservation for the path tracer
Implement basic energy conservation using albedo tables of the GGX and cloth lobes. Reflection and refraction are tabulated independently.

Also provide analytic approximations for the reflection case if a tabulation is not convenient. If a good analytic approximation for the glass case can be found (requires a 3D fit), we should remove the tabulated implementation which was done mainly to provide a baseline.

The albedo table is also used to improve lobe selection probabilities, which improves sampling of the clearcoat case in particular.

Refactored how the path tracer's internal view state data is stored to keep the structure details fully hidden inside PathTracing.cpp

#rb Patrick.Kelly
#preflight 613814072d09b900014699c9

[CL 17452976 by chris kulla in ue5-main branch]
2021-09-07 22:20:36 -04:00
chris kulla
9f44c07046 Implement path compaction for the path tracer to keep GPU lanes more fully occupied as rays bounce around the scene
The basic idea is to breakup the bounce loop in the path tracer into independent launches so we can group active paths together. This step is done with wave ops + atomics. The implementation is rather naive at the moment, but it already gives a 2x speedup on most scenes. This is on par or better than the speedup from the coherent sampler, but without inposing any constraints on the random numbers.
#preflight 60db7bf119a0060001f8e9a9

[CL 16800791 by chris kulla in ue5-main branch]
2021-06-29 17:04:40 -04:00
chris kulla
d064996317 Improve path tracer performance with simplified materials
GPU Lightmass saw a performance regression after using more of the material model for translucent shadow support. Reclaim some performance by special casing more of the material logic for the subset that GPULM needs.

#rb Yujiang.Wang
#preflight 609ad275ab726700013a472c

[CL 16278525 by chris kulla in ue5-main branch]
2021-05-11 15:46:27 -04:00
aurel cordonnier
50944fd712 Merge UE5/RES @ 16162155 to UE5/Main
This represents UE4/Main @ 16130047 and Dev-PerfTest @ 16126156

[CL 16163576 by aurel cordonnier in ue5-main branch]
2021-04-29 19:32:06 -04:00
chris kulla
ec009af823 Path Tracing setting cleanups
Add PPV flag to enable path traced emissive materials (on by default). These paths are not always needed if there are lots of tiny emitters, or if the scene was modelled with both emissive geometry and lights.

Change Skip* variables to Enable* to be more intuitive

Turn the sampler options into a proper enum since they were intended to be mutually exclusive

Tweak MaxPathIntensity logic to match Lumen and avoid color shifts

#rb Juan.Canada
#preflight 6079ba3dd400b70001571289

[CL 16036532 by chris kulla in ue5-main branch]
2021-04-16 13:23:59 -04:00
chris kulla
a42b669d3c Add light culling for path tracer
Split the light list info finite (point, spot, rect) and infinite (skydome, directional) sets. Build a 2d grid of which finite lights overlap particular regions. The grid is aligned to the bounding box of all lights and collapsed along the shortext axis so that memory usage scales quadratically with resolution instead of cubically. The light list per cell is currently pre-allocated up to a maximum count per cell (overflow is simply cut and lights are dropped as they were prior to this change). In most scenes I have tried so far this maximum is never reached with the current defaults of 256^2 resolution and 128 max lights per cluster.

#rb Patrick.Kelly
#preflight 60785d289e2d7a00016e3032

[CL 16022731 by chris kulla in ue5-main branch]
2021-04-15 12:22:28 -04:00