Commit Graph

123 Commits

Author SHA1 Message Date
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
tiago costa
d02ba08f8c Support Callable/Miss shaders in MeshPassProcessor.
- useful to gather shader bindings to evaluate materials in callable shaders.
- similar to how it supports compute and hit group shaders.

#rb yuriy.odonnell
#preflight 6287503ac057ee6e23f2f8dc

[CL 20292265 by tiago costa in ue5-main branch]
2022-05-20 05:18:06 -04:00
tiago costa
adedecfd54 Support multiple layers in FRayTracingScene.
- Updated places accessing TLAS SRV to use ERayTracingSceneLayer::Base

#rb yuriy.odonnell
#preflight 62728a70ec1566a70616ac9a

[CL 20041705 by tiago costa in ue5-main branch]
2022-05-04 10:41:10 -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
9e42482f9c Path Tracer: Fix constant invalidation in MRQ renders when camera DOF is animated
#rb Juan.Canada
#preflight 62607917080c6600634cf887

[CL 19838881 by chris kulla in ue5-main branch]
2022-04-20 17:45:54 -04:00
chris kulla
bda019cd15 PathTracer: clamp fog falloff parameters to avoid singularity at 0
#rb trivial
#preflight 624d166b8d1db441a91a82cc

[CL 19642217 by chris kulla in ue5-main branch]
2022-04-06 00:31:08 -04:00
chris kulla
da10b9f80c Path Tracer: fix warnings from bad ShaderType
#rb trivial
#preflight 624b8c2adf7d23dbfe3e00f6

[CL 19619323 by chris kulla in ue5-main branch]
2022-04-04 20:50:10 -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
chris kulla
75cf08df6e GPULightmass: Fix light grid being created per sample (re-use the previous sample's grid instead)
Fix RHI validation errors on "TilePositionsBufferForClear" by moving this buffer to RDG

Fix broken IES support from bad merge

Remove unused View parameter from PrepareLightGrid

Fix several shader compilation warnings

#rb Juan.Canada
#jira none
#preflight 62338a2fe12e0da4a5315444

[CL 19425053 by chris kulla in ue5-main branch]
2022-03-17 15:37:05 -04:00
jason hoerner
6ed56c2410 MGPU: Fix for Path Tracer. Need to read result surface from correct GPU.
#jira UE-144678
#rnx
#rb chris.kulla
#lockdown michal.valient
#preflight 622fa512e348fe2ada3e2047

#ROBOMERGE-AUTHOR: jason.hoerner
#ROBOMERGE-SOURCE: CL 19378469 in //UE5/Release-5.0/... via CL 19379592
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v926-19321884)

[CL 19380082 by jason hoerner in ue5-main branch]
2022-03-14 19:03:34 -04:00
chris kulla
322dc427d6 Fix compilation error in non-editor builds
#rb none
#preflight 62284385a8370672877cc7fb

[CL 19317558 by chris kulla in ue5-main branch]
2022-03-09 01:29:21 -05:00
chris kulla
f4c4970e96 Unify GPU Lightmass shader selection with Path tracing
The logic was nearly identical between both cases, refactoring allows us to share more code and remove virtual calls from FRayTracingMeshProcessor.

Also cleanup the way supported Vertex Factory types are detected by adding a new vertex factory flag.

#rb Juan.Canada
#preflight 6227967d31133a23da4a56bf

[CL 19305870 by chris kulla in ue5-main branch]
2022-03-08 13:03:14 -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
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
chris kulla
b55eaf6925 Reduce the likelyhood of TDRs on Windows by adding a submit hint to the command list after the path tracing ray dispatch
Default value is 2 (flush after each tile) to minimize the overhead when path compaction is used.

#jira UE-140993
#rb Juan.Canada
#preflight 61fac666815d546ad398e880

#ushell-cherrypick of 18793549 by chris.kulla

#ROBOMERGE-AUTHOR: chris.kulla
#ROBOMERGE-SOURCE: CL 18830206 in //UE5/Release-5.0/... via CL 18830317 via CL 18830778
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v910-18824042)

[CL 18830794 by chris kulla in ue5-main branch]
2022-02-02 13:51:37 -05:00
fred kimberley
7fbfaf57c8 Require explicit constructors/casts when converting between FVector, FVector3d, and FVector3f.
#jira UE-122078
#rb Andrew.Davidson, Colin.McGinley
#preflight standard build

#ROBOMERGE-AUTHOR: fred.kimberley
#ROBOMERGE-SOURCE: CL 18817999 in //UE5/Release-5.0/... via CL 18818012 via CL 18822871
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v910-18824042)

[CL 18824721 by fred kimberley in ue5-main branch]
2022-02-02 07:59:31 -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
andrew davidson
cac76b118e Fix FVector2D variant casts - Renderer
Submitted on behalf of fred.kimberley
#rb andy.davidson
#preflight 61f8700e41414fb013dd4002

#ROBOMERGE-AUTHOR: andrew.davidson
#ROBOMERGE-SOURCE: CL 18801433 in //UE5/Release-5.0/... via CL 18802090 via CL 18821511
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v908-18788545)

[CL 18821594 by andrew davidson in ue5-main branch]
2022-02-02 01:43:41 -05:00
ben ingram
d1124c2e41 Move a bunch of lighting calculations to translated world space, fixes various problems at LWC scale
#preflight 61f1760afd5285142b43178a
#rb Daniel.Wright, tiago.costa, Andrew.Lauritzen, charles.derousiers
#jira UE-139831

#ROBOMERGE-AUTHOR: ben.ingram
#ROBOMERGE-SOURCE: CL 18738670 in //UE5/Release-5.0/... via CL 18738820 via CL 18739464
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v903-18687472)

[CL 18740039 by ben ingram in ue5-main branch]
2022-01-26 13:56:31 -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
charles derousiers
078f5165f1 Move SS profiles and SS pre-intregrated profiles textures onto the view in order to make them accessible to all passes without extra manual binding.
#rb sebastien.hillaire, tiantian.xie, wei.liu
#jira none
#preflight 61a61f01f70a9e92dbe9e700

#ROBOMERGE-AUTHOR: charles.derousiers
#ROBOMERGE-SOURCE: CL 18323676 in //UE5/Release-5.0/... via CL 18323690
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469)

[CL 18323696 by charles derousiers in ue5-release-engine-test branch]
2021-11-30 08:27:29 -05:00
chris kulla
31d78db0b7 Add Hair strand path tracing support
Add support for binding a ray tracing material to hair strands so that they can show up in path tracing.

Add hair shading model to path tracer

#rb Charles.deRousiers
#preflight 618e9d3b857f308d859d696a

#ROBOMERGE-AUTHOR: chris.kulla
#ROBOMERGE-SOURCE: CL 18170915 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v894-18169371)
#ROBOMERGE[STARSHIP]: UE5-Release-Engine-Staging Release-5.0

[CL 18170941 by chris kulla in ue5-release-engine-test branch]
2021-11-12 12:39:07 -05:00
chris kulla
fa4b66c67d Implement depth of field support for the path tracer
This implements a ray-traced sampled depth of field which can serve as a ground truth for the post processed depth of field. Users can select between reference quality or post processing with a path tracing specific checkbox in the post process settings.

#rb Guillaume.Abadie,Patric.Kelly,Juan.Canada
#preflight 618bf5abb253729fe2230d0e

#ROBOMERGE-AUTHOR: chris.kulla
#ROBOMERGE-SOURCE: CL 18131692 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v889-18060218)
#ROBOMERGE[STARSHIP]: UE5-Release-Engine-Staging Release-5.0

[CL 18131775 by chris kulla in ue5-release-engine-test branch]
2021-11-10 12:11:09 -05:00
chris kulla
68b736952a Enable Path Tracing by default
This cvar mainly controls the creation of path tracer specific material permutations. Projects which know they do not want to make use the path tracer should turn this off. Note that the DataDrivenPlatformInfo is also checked to make sure the path tracer is supported on a given platform.

#rb Juan.Canada
#p4v-preflight-copy 18094497
#preflight 6189b0b6c717ba4e92145c31

#ROBOMERGE-AUTHOR: chris.kulla
#ROBOMERGE-SOURCE: CL 18096618 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v889-18060218)
#ROBOMERGE[STARSHIP]: UE5-Release-Engine-Staging Release-5.0

[CL 18096707 by chris kulla in ue5-release-engine-test branch]
2021-11-08 19:11:23 -05:00