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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]