Commit Graph

116 Commits

Author SHA1 Message Date
marc audy
65de35fdfb Lof elements that were not renamed yet.
- MSM_Substrate
- MCT_Substrate
- FStrataMaterialInput

#rb charles.derousiers

[CL 27563163 by marc audy in ue5-main branch]
2023-09-01 15:06:19 -04:00
sebastien hillaire
09ef6f1c14 Substrate - Rename/move file(s) for shader folder only.
#rb none
[FYI] charles.derousiers

[CL 27514918 by sebastien hillaire in ue5-main branch]
2023-08-31 04:46:35 -04:00
chris kulla
57e91c3478 Simplify the logic for GGX Visible normal sampling
Note that the new code accepts a pair of random numbers in the unit square instead of on the unit disk. This required updating all callers (which all passed in the result of UniformSampleDisk anyway).

Also, call the aniso variant which saves a useless square followed by sqrt. The old non-aniso method is removed as there is no real savings to be had from the non-anisotropic case anymore.

#rb Sebastien.Hillaire

[CL 26031587 by chris kulla in ue5-main branch]
2023-06-15 20:36:40 -04:00
charles derousiers
34c6c73c28 Add Disney LTC cloth model to the pather tracer.
#rb chris.kulla
[FYI] sebastien.hillaire

[CL 25910635 by charles derousiers in ue5-main branch]
2023-06-10 08:58:57 -04:00
charles derousiers
c8e424126e Change SpecularProfile evalution to be shared.
#rb none
[FYI] sebastien.hillaire

[CL 25910335 by charles derousiers in ue5-main branch]
2023-06-10 02:09:01 -04:00
chris kulla
a026d90edb Path Tracer: Fix compilation error when substrate is enabled
#rb trivial

[CL 25886994 by chris kulla in ue5-main branch]
2023-06-08 21:31:09 -04:00
chris kulla
7592dad893 Path Tracing: Fix darkening in SSS
When the subsurface scattering radius become small, a fair amount of energy is lost which darkens the result in an un-desireable way. To avoid this, clamp the radius to a safe value and blend the subsurface albedo back towards diffuse instead. This keeps the overall energy contribution while avoiding small radii. It also improves the transition between radius 0 and radius slightly above 0.

#rb none

[CL 25870598 by chris kulla in ue5-main branch]
2023-06-08 10:13:25 -04:00
charles derousiers
3448f6a9c8 Add initial glint support for PT.
Current limitations:
* The GlintUV derivatives are incorrect/hardcoded for now.
* Sampling is done as a single lobe, without knowledge of the glints.

#rb chris.kulla
[FYI] sebastien.hillaire

[CL 25837504 by charles derousiers in ue5-main branch]
2023-06-07 02:55:42 -04:00
charles derousiers
903991b4b7 Add Substrate specular profile to the path tracer.
#rb chris.kulla
#preflight shader
[FYI] sebastien.hillaire

[CL 25780882 by charles derousiers in ue5-main branch]
2023-06-03 02:44:34 -04:00
chris kulla
160032b9c7 Path Tracer: Simplify handling of "micro occlusion" which lowers F90 color as F0 tends to zero
There is no need to multiply F0 by the microocclusion factor as it is already becoming 0.

Also make the equivalent change on the substrate side.

#rb none
#jira none
#preflight 6470d31f9c600ef1537c61a9
#fyi Sebstien.Hillaire,Charles.deRousiers

[CL 25646946 by chris kulla in ue5-main branch]
2023-05-26 12:45:40 -04:00
chris kulla
f08906adfc Substrate: Remove STRATA_DIFFUSE_CHAN in favor of using MATERIAL_ROUGHDIFFUSE
Having two shader defines that did the same thing was a bit confusing. Instead use MATERIAL_ROUGHDIFFUSE for both substrate and non-substrate cases, and handle the logic purely on the C++ side.

#fyi Sebastien.Hillaire,Charles.deRousiers
#jira none
#preflight 6456d9c0ed7ffaa0f5283ca8

[CL 25366546 by chris kulla in ue5-main branch]
2023-05-06 19:26:57 -04:00
chris kulla
8b6f93a6db Path Tracing: Implement refraction for Substrate materials
When a material is flagged to used refraction, compute the IOR and set it on the slab (for the bottom slabs only). For now this case is split into its own logic with

A different implementation is used for Thin vs Solid cases for now.

This implementation is still a work in progress. In particular, the treatment of the diffuse color (which controls the medium albedo) is not complete.

#rb none
#jira UE-173840
#preflight 6456d9ef994d8a3d0aa6d479

[CL 25366534 by chris kulla in ue5-main branch]
2023-05-06 19:07:39 -04:00
chris kulla
1b87f29590 Path Tracing: Implement basic support for transparency for Substrate materials
Add basic handling of plain transparency, and refactor some code related to thin translucent to cleanup header includes.

#rb none
#jira  UE-173840
#preflight 644c195d864f15ebf5019464

[CL 25239956 by chris kulla in ue5-main branch]
2023-04-28 16:31:00 -04:00
chris kulla
5470194c24 Path Tracer: Fix corner cases with invalid Strata materials
There were rare cases where we could generate invalid code.

Also comment out some common methods that are unused when compiling GPU Lightmass

#rb trivial
#jira UE-173840
#preflight 64496441877716c878add9e1

[CL 25203917 by chris kulla in ue5-main branch]
2023-04-26 14:31:24 -04:00
chris kulla
dc4e2f00a5 Path Tracer: Fix rough diffuse not working when Substrate is enabled
Try to simplify logic around STRATA_DIFFUSE_CHAN being set from several places at once and remove logic which only looked at the rough diffuse setting on consoles

#rb Sebastien.Hillaire,Charles.DeRousiers
#preflight 64434c0bc023bb1f737a733c
#jira none

[CL 25167579 by chris kulla in ue5-main branch]
2023-04-24 13:44:09 -04:00
Tiantian Xie
a3e766a021 Modify the path tracing depth write logic to match the rasterizer path. Write the depth when 1) solid or masked material. or 2) when output depth and velocity is set and Opacity >= Opacity mask clip value for translucent, additive and modulate, blending, alpha holdout, alpha composite mode to match the behavior of the rasterizer path.
Rename `output depth` to `output depth and velocity`.

#jira UE-179272
#preflight 6446acb9c632d1e89b43db16
#rb chris.culla

[CL 25166338 by Tiantian Xie in ue5-main branch]
2023-04-24 12:23:58 -04:00
chris kulla
ca0e189d75 Path Tracer: Add decal support with Substrate enabled
Refactor the decal apply logic so that we adjust diffuse/specular _after_ having applied the decals so that we can properly handle BaseColor even in the presence of subsurface scattering.

Refactor EnableDBuffer logic to remove the decal data after the second trace so we don't need to check it again. This keeps the dbuffer logic more self contained.

PT_Decals in EngineTest is mostly passing, but there are a few differences that need to be investigated more carefully. I suspect that some of them might be due to the round trip between diffuse/specular color and metallic/specular workflow.

#rb Sebastien.Hillaire,Tiago.Costa
#jira UE-173840
#preflight 643eea360a5a4b944e936ffc

[CL 25117919 by chris kulla in ue5-main branch]
2023-04-19 18:15:06 -04:00
Tiantian Xie
8307bb7838 Add depth pass for path tracing. The output is in DepthZ. The user can use the same depth post process material to output in MRQ. The user can use r.PathTracing.Override.Depth 0 to disable path traced depth buffer and use the depth from the rasterizer instead.
#jira UE-179272
#preflight 643db54fa35280ed4fef97f8
#rb chris.kulla

[CL 25077186 by Tiantian Xie in ue5-main branch]
2023-04-17 17:55:45 -04:00
chris kulla
3fdab2b8b1 Path Tracer: Add support for legacy clearcoat shading model with Substrate
Re-use the shadingmodel id for clearcoat to signal we want the alternate interpretation of specular blending. Note that the resulting shading includes fuzz and subsurface which could arise from legacy clearcoat getting combined with newer features through layering or parameter blending.

Cleanup how SSS probabilities are calculated to re-use existing logic.

#jira UE-173840
#fyi Sebastien.Hillaire,Charles.deRousiers
#preflight 642c9c3bc6769c6082802c61

[CL 24923139 by chris kulla in ue5-main branch]
2023-04-04 21:32:56 -04:00
chris kulla
3028b7764e Path Tracing: Fix dual specular blending in substrate slab
#rb trivial
#jira UE-173840
#preflight skip

[CL 24884414 by chris kulla in ue5-main branch]
2023-04-01 01:52:48 -04:00
chris kulla
35b3ff7194 Path Tracer: Fix non-slab shading models with Substrate support, add support for SSS profile legacy shading model, fix one-sided emission support
#rb none
#jira UE-173840
#preflight 6427924e9834526476c8f9e8

[CL 24884204 by chris kulla in ue5-main branch]
2023-04-01 00:52:46 -04:00
chris kulla
100676517b Path Tracer: Add basic Substrate support
Implement the core slab BSDF in the path tracer. When Strata is enabled, enlarge the payload slightly to be able to encode a slab without needing to rely on Substrate's packing routines. This allows the path tracer to be more independent of the project settings. Multiple slabs are handled by stochastically returning a single slab from the hit shader. This approaches greatly simplifies the handling of SSS slabs and refractive/translucent cases in the future.

Also added a cvar that lets you toggle (at runtime) to the fully simplified form of the material. This doesn't appear that much faster, but it could be interesting to validate the appearance of the simplification procedure. It is gated by an extra cvar to avoid compiling extra permutations by default.

#rb Sebastien.Hillaire, Charles.deRousiers
#jira UE-173840
#preflight 642709ca91589478cd1575ed

[CL 24874059 by chris kulla in ue5-main branch]
2023-03-31 13:00:22 -04:00
chris kulla
425e989413 Path Tracer: Fix incorrect pdfs returned by sample method
When refactoring the code for splitting diffuse from specular, a subtle error was introduced that could cause materials to render incorrectly under certain illumination conditions. This could only be seen when comparing the direct illumination output under MISMode 0,1,2. While modes 0 and 1 (corresponding to BSDF and Light sampling respetively) matched in all cases, the MIS combination of the two did not and frequently rendered darker.

The reason is that the eval function uses MIS across all lobes, while sample only returns the result of a single lobe. The weight would lead to the correct result, but the pdf did not compare correctly with the one returned by eval, leading to incorrect results when MIS favored BSDF sampling over light sampling.

To fix this, all multi-lobed shading models need to account for the probability of generating the same direction through all other lobes.

Along the way, change to extinction encoding for solid glass to avoid precision issues with transmission color in solidglass.

Also apply the RescaleRandomNumber function consistently across material sampling routines.


#jira UE-181325
#rb Aleksander.Netzel
#preflight 64220959974dfaa53cb614c8

[CL 24814539 by chris kulla in ue5-main branch]
2023-03-27 23:22:49 -04:00
chris kulla
c0f49f2d10 Path Tracer: Fix fireflies that can occur from the rough diffuse shading model at grazing angles
The model is mostly energy conserving except at grazing angles where the weights can becomes slightly above 1.0. In the path tracing context this can become problematic in corners of models or when the shading normals diverge too much from the base surface (as can happen with some Nanite fallback meshes).

Clamping the weight to 1 fixes these issues without altering the overall shape of the BSDF

#rb trivial
#jira IRON-401
#preflight trivial

[CL 24766724 by chris kulla in ue5-main branch]
2023-03-23 15:31:42 -04:00
chris kulla
4591aab281 Path Tracing: Refactor path tracing code to minimize material/blend type related special cases in the integrator
Revisit payload encoding to handle blend mode logic entirely in the shader. This removes the need for a blendmode field and simplifies the logic in the raygen shader, reducing the amount of switch statements. We also gain back 3 extra bits that can be spent on output flags.

Refactor how random walk selection is performed to avoid shadingmodel specific code in the integrator. Also refactor the code to allow transparency to be combined with SSS.

Unify the handling of SingleLayerWater and solid glass since they were mostly sharing the same code. Both cases now use the DEFAULT_LIT shading model. This required extending the logic for camera medium tracking a bit. It now always runs (with a cvar to turn it off for debugging) instead of being tied to View.IsUnderwater() which could only work for water geometry. This makes it possible to achieve the under-water effect with regular refractive materials as well.

#rb Aleksander.Netzel
#jira none
#preflight 63efbaa090198dffbafaaf38

[CL 24286321 by chris kulla in ue5-main branch]
2023-02-17 13:15:33 -05:00