Commit Graph

211 Commits

Author SHA1 Message Date
aleksander netzel
bc3681c180 Add initial support for rendering water in path tracer:
* Add missing water Material ID cases for material hit shaders
* Make water translucent in the initial version
* Disable underwater postprocess material when running PT

#rb Chris.Kulla
#preflight 629725f92a1851b4ccb93408

[CL 20450504 by aleksander netzel in ue5-main branch]
2022-06-01 06:14:24 -04:00
tiago costa
fc62d1fc0e Initial support for deferred decals in path tracer.
- Decals materials are evaluated using callable shaders in PathTracingKernel.
- Decals are culled using a 2D grid similar to the existing light grid.
- In order to correctly handle decal blending order, decals are sorted using the same logic as the rasterizer on CPU. The compute shader that builds the decal grid maintains the correct order.
- Decal materials are wrapped in FRayTracingDecalMaterialShader. The instance parameters of each decal are bound using uniform buffers.

#preflight 628f3fed2f2409bc1e7a6414
#rb Yuriy.ODonnell, chris.kulla, Jeremy.Moore

[CL 20377336 by tiago costa in ue5-main branch]
2022-05-26 05:59:55 -04:00
chris kulla
afd70ee879 Path Tracer: expose azimuthal roughness on hair via the scatter (metallic) parameter. The default value of 0 corresponds to 1.0 azimuthal roughness (current behavior) while increasing the scatter amount makes the hair more and more forward scattering, leading to a softer appearance. The lowest possible roughness is limited to 0.1 to limit noise.
#fyi Charles.deRousiers
#preflight 6287e4406c7692ac8cce4084

[CL 20300704 by chris kulla in ue5-main branch]
2022-05-20 15:06:27 -04:00
chris kulla
fa3b008395 Path Tracer: Fix for potential NaNs in hair shading model
#rb trivial
#preflight 6279f3f34b6e4b76c9300fb9

[CL 20119257 by chris kulla in ue5-main branch]
2022-05-10 01:25:42 -04:00
chris kulla
fe0131977b Path Tracer: Take the normal map into account at the exit point of the random walk for better detail preservation in SSS
#rb TianTian.Xie
#preflight 62759517f27a22404d1fb373

[CL 20085984 by chris kulla in ue5-main branch]
2022-05-06 17:45:06 -04:00
eric mcdaniel
0e83e877fa Shader compilation fix
- fix for shader compilation on an NDA'd platform introduced in CL 20008404

#rb none, trivial
#jira none, CIS error
#rnx
#preflight 626ff999ad00dced62ce4325
#fyi Yujiang.Wang

[CL 20010260 by eric mcdaniel in ue5-main branch]
2022-05-02 12:22:48 -04:00
Yujiang Wang
98416f4a74 GPULM: Properly integrate direct lighting SH as we have 2 directions now (1 from BRDF sampling and 1 from NEE). Luminance for first bounce ray guiding is accumulated separately
#preflight none

[CL 20008404 by Yujiang Wang in ue5-main branch]
2022-05-02 10:33:43 -04:00
chris kulla
f7c987fcf6 Path Tracer: Implement alpha holdout blendmode properly
This should render black, with alpha controlled by the opacity.

#jira UE-149843
#rb Juan.Canada
#preflight 626c0be0ce3959ce8fe57a38

[CL 19980869 by chris kulla in ue5-main branch]
2022-04-29 12:06:48 -04:00
chris kulla
f8f584945a Path Tracer: Remove RayCone from path tracer payload as it was not actually used
If we want to re-introduce this notion, we should be able to handle this directly in the material given the world position and camera matrix.

This frees up 4 bytes (in preparation for Strata support) and also reduces the path state structure size by 4 bytes.

I've measured around 3% speedup from this removal.

#rb Yuriy.ODonnell,Charles.deRousiers
#preflight 626ae4926461dd769ffe4394

[CL 19966893 by chris kulla in ue5-main branch]
2022-04-28 15:20:39 -04:00
Yujiang Wang
069ee84d68 GPU Lightmass Solver Improvements
Irradiance Caching
* Instead of setting a per-cell cap of samples, now we use the first X path samples of the receiver (lightmap texels) to adaptively distribute the irradiance cache samples. This will distribute them where BRDF sampling thinks the most important (more around corners and fewer in open area, for example). This is also the distribution that the old school irradiance caching's distance-based heuristics approximates for.
* New cache cells are only spawned during the first X passes. This avoids the case where the cache is constantly thrashed when it is not big enough to cover the scene.
* The image is reset after the first X passes are done. Like path guiding, these passes are uncached and thus contain high variance. Mixing them with the passes later will actually increase overall variance.

First Bounce Ray Guiding
* Now the FBRG passes run after IC passes are done. Way less input noise into the guiding PDF and better at locating importance sources.

New Parameter Tweaking Strategy for IC and FBRG
* IC: set quality to 1/16-1/8 of GI samples. Increase when seeing bright splotches around corners, or color discrepancies over large area.
* FBRE: set trial samples to 1/4 of GI samples. Increase when fireflies or small square-shaped artifacts are introduced by this technique.

General Cleanups
* IC and FBRG passes now add to the total number of passes to render instead of being subtracted from the number of GI Samples to reduce user confusion.
* IC buffer size reduction to save some GPU memory.

#rb juan.canada
#preflight 625ef3cb5f498a37c921b2f0

[CL 19815248 by Yujiang Wang in ue5-main branch]
2022-04-19 15:43:02 -04:00
Tiantian Xie
bcb085c183 Improve the specular matching between raster and path tracer for subsurface scattering.
1. Use the decoding used by raster for the path tracer.
2. Use direct encoding from material roughness to lobe roughness instead of going through the average, which leads to underestimation (2%) and clamping (20%) of the value space.

Also clean up the code a little.

#jira UE-148244
#rb chris.kulla, sebastien.hillaire, krzysztof.narkowicz
#preflight 624f17ce6d3bb118aaf08c74

[CL 19673284 by Tiantian Xie in ue5-main branch]
2022-04-07 13:41:02 -04:00
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
tiago costa
e5e24be439 Added support for storing a custom uint in FRayTracingIntersectionAttributes.
- Can be used to output 32 bits worth of data from ray tracing intersection shaders.
- Enabled by defining RAY_TRACING_SUPPORT_CUSTOM_UINT_IN_INTERSECTION_ATTRIBUTES in Vertex Factory.
- When enabled, barycentrics are stored using half precision floats.
- Renamed FDefaultAttributes to FRayTracingIntersectionAttributes.

#rb yuriy.odonnell
#preflight 6246c547981a2c8eb48d7715
#jira none

[CL 19586038 by tiago costa in ue5-main branch]
2022-04-01 06:08:16 -04:00
eric mcdaniel
6e12f45643 Resolve shadowed name errors in FVolumeLightSampleSetup during shader compilation on some platforms
#rb Wojciech.Krywult
#jira none
#preflight 6234ed824b540ca4e5d85b39

[CL 19441720 by eric mcdaniel in ue5-main branch]
2022-03-18 17:25:42 -04:00
Tiantian Xie
f6bc47958c # Match pathtracer and rasterizer/raytracing SSS
## Major benefit
 * SSS rasterizer matches as close as possible to pathtracer without transmission. Ultimate goal is the user can use rasterizer to look and dev subsurface scattering.
 * SSProfile will use mfp. Next is to unify all scattering parameters to mfp.
 * Smooth upgrade for rasterizer/raytracing real-time renderer. Path tracer appearance will match rasterizer as previously the parameters are used differently for path tracer and rasterizer.
 * Path tracer supports SSS below 1mm.

## The break down of the CL

 0. Use mfp instead of dmfp to select the channel to scatter (CL19255292).
 1. Match burley high quality rasterizer with pathtracer in ideal SSS condition (CL19227570).
 2. Match the low quality burley, separable filter(CL19244046).
 3. Upgrade dmfp to mfp in UI. (This one includings all previous CLs).

## Issue
There are two issues I am hunting down

0. Need to scale the scatter distance by 2 for separable filtering so that it matches MC sampling in high quality Burley.
1. Need to scale down the mfp by a magic number 0.6 to match path tracer with high quality burley. However it has no impact for new SS profiles. The mfp is as it is.

#jira UE-138109
#preflight 622f933e511d438d6b5cbccc

[CL 19377844 by Tiantian Xie in ue5-main branch]
2022-03-14 16:13:58 -04:00
guillaume abadie
fc45b950e2 Fixes remaining short-circuit in the renderer
#rb rune.stubbe

#ROBOMERGE-AUTHOR: guillaume.abadie
#ROBOMERGE-SOURCE: CL 19352016 via CL 19352024
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v926-19321884)

[CL 19356595 by guillaume abadie in ue5-main branch]
2022-03-11 12:09:45 -05:00
chris kulla
97e0648efc Use sample stretching for reservoir sampling in the path tracer
This speeds up the main trace loop by requiring fewer random numbers to be generated.

#rb Patrick.Kelly
#preflight 621e5d8fe15c51d8c5d4dbe7

[CL 19201993 by chris kulla in ue5-main branch]
2022-03-01 13:13:47 -05: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
tiago costa
1722da7465 Raytracing in translated world space
- Raytracing shadows/reflections/AO/GI/etc and path tracer now work in large worlds.
- Updated parts of Lumen using raytracing to work in large worlds.
- This change doesn't not address (all) GPU Lightmass issues in large worlds.

Changes:
- Build TLAS with instances in translated world space.
- Move ray origin to translated world space.
- Updated raytracing shaders to use translated world space (most LWCHackToFloat in these shaders are now gone).
- Store gather points positions in translated world space.
- Removed unused RayTracingDynamicMeshVS(...)

#rb Yuriy.ODonnell, Patrick.Kelly, chris.kulla, rob.krajcarski
#jira UE-140558
#preflight 620bb3ff4353dc61c7f51e64

[CL 18995354 by tiago costa in ue5-main branch]
2022-02-15 09:20:03 -05:00
Charles deRousiers
86ece99784 Add rect light texture atlas support.
This changes allow to bind a larger amount of rect. light texture, and allows future support for rect light in forward & cluster passes.

#jira none
#rb sebastien.hillaire
#preflight 61fcebd0b5092d45ad110db4

[CL 18861192 by Charles deRousiers in ue5-main branch]
2022-02-04 04:18:10 -05:00
tiago costa
0d12b0df17 Updated FPathTracingLight to use translated world space
- Store Position and Bounds in translated world space
- Not using TilePosition+RelativeWorldPosition to avoid increasing struct size.
- FPathTracingLight arrays seem to be calculated every frame so shouldn't be a problem.
- LightGrid fully built in translated world space.
- TraceLight/SampleLight/EstimateLight/InitLightPickingCdf now expect rays and positions in translated world space.

#preflight 61f98c744b0bc1c4176461df
#rb chris.kulla

#ROBOMERGE-AUTHOR: tiago.costa
#ROBOMERGE-SOURCE: CL 18813277 in //UE5/Release-5.0/... via CL 18813296 via CL 18822754
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v910-18824042)

[CL 18824289 by tiago costa in ue5-main branch]
2022-02-02 07:35:04 -05:00
tiago costa
62da9fa98f LightGrid in translated world space
- not yet taking full advantage of LWC since light positions are still sent to shader as world space floats.

#preflight 61f9535e8b4112f7cc9a3600
#rb Chris.Kulla

#ushell-cherrypick of 18809796 by tiago.costa

[CL 18823427 by tiago costa in ue5-main branch]
2022-02-02 05:42:49 -05:00
UnrealBot
c47e81b2cb Branch snapshot for CL 18531810
[CL 18531810 in ue5-main branch]
2022-01-06 16:44:09 +00:00
UnrealBot
2987349d36 Branch snapshot for CL 18514113
[CL 18514113 in ue5-main branch]
2022-01-05 20:41:17 +00:00
tiantian xie
63f63d8e15 Remove the parameterization of Dipole code path for Separable SSS.
#jira UE-136412
#rb sebastien.hillaire, wei.liu
#preflight 61d49b935d522c9b40837c1c

#ROBOMERGE-AUTHOR: tiantian.xie
#ROBOMERGE-SOURCE: CL 18518799 in //UE5/Release-5.0/... via CL 18518817
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v899-18417669)

[CL 18518828 by tiantian xie in ue5-release-engine-test branch]
2022-01-05 10:06:19 -05:00