Skip to content

Commit 8387320

Browse files
eturquinVic-Cooper
andauthored
[HDRP][Path Tracing] AxF material support (#4525)
* Merge stacklit changes. * Updated changelog. * Updated docs Removed Stacklit material limitation from Path tracing docs., * Fixed issue with NaNs generated on backfaces. * Merged AxF base support, and SVBRDF implementation. * Switched isoGGX to visible normal anisoGGX implementation. * Refined SVBRDF and added Car Paint support. * Updated changelog, and minor cosmetic changes. * ... * ... * Updated couple test reference images (marginal changes). * Changed test 1000 PT, which had also marginally changed. Co-authored-by: Vic-Cooper <vic.cooper@unity3d.com>
1 parent b88f16e commit 8387320

File tree

19 files changed

+684
-87
lines changed

19 files changed

+684
-87
lines changed
Loading
Loading
Loading

com.unity.render-pipelines.high-definition/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
5757
- Added the ability to animate many physical camera properties with Timeline.
5858
- Added a mixed RayMarching/RayTracing mode for RTReflections and RTGI.
5959
- Added path tracing support for stacklit material.
60+
- Added path tracing support for AxF material.
6061
- Added support for surface gradient based normal blending for decals.
6162
- Added support for tessellation for all master node in shader graph.
6263

com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public struct SurfaceData
7474
public Vector3 specularColor;
7575

7676
[SurfaceDataAttributes("Fresnel F0")]
77-
public Vector3 fresnelF0;
77+
public Vector3 fresnel0;
7878

7979
[SurfaceDataAttributes("Specular Lobe")]
8080
public Vector3 specularLobe; // .xy for SVBRDF, .xyz for CARPAINT2, for _CarPaint2_CTSpreads per lobe roughnesses
@@ -152,12 +152,12 @@ public struct BSDFData
152152
[SurfaceDataAttributes("", true)]
153153
public Vector3 tangentWS;
154154
[SurfaceDataAttributes("", true)]
155-
public Vector3 biTangentWS;
155+
public Vector3 bitangentWS;
156156

157157
// SVBRDF Variables
158158
public Vector3 diffuseColor;
159159
public Vector3 specularColor;
160-
public Vector3 fresnelF0;
160+
public Vector3 fresnel0;
161161
public float perceptualRoughness; // approximated for SSAO
162162
public Vector3 roughness; // .xy for SVBRDF, .xyz for CARPAINT2, for _CarPaint2_CTSpreads per lobe roughnesses
163163
public float height_mm;

com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.cs.hlsl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ struct SurfaceData
9696
float3 tangentWS;
9797
float3 diffuseColor;
9898
float3 specularColor;
99-
float3 fresnelF0;
99+
float3 fresnel0;
100100
float3 specularLobe;
101101
float height_mm;
102102
float anisotropyAngle;
@@ -128,10 +128,10 @@ struct BSDFData
128128
float specularOcclusion;
129129
float3 normalWS;
130130
float3 tangentWS;
131-
float3 biTangentWS;
131+
float3 bitangentWS;
132132
float3 diffuseColor;
133133
float3 specularColor;
134-
float3 fresnelF0;
134+
float3 fresnel0;
135135
float perceptualRoughness;
136136
float3 roughness;
137137
float height_mm;
@@ -188,7 +188,7 @@ void GetGeneratedSurfaceDataDebug(uint paramId, SurfaceData surfacedata, inout f
188188
needLinearToSRGB = true;
189189
break;
190190
case DEBUGVIEW_AXF_SURFACEDATA_FRESNEL_F0:
191-
result = surfacedata.fresnelF0;
191+
result = surfacedata.fresnel0;
192192
break;
193193
case DEBUGVIEW_AXF_SURFACEDATA_SPECULAR_LOBE:
194194
result = surfacedata.specularLobe;
@@ -282,7 +282,7 @@ void GetGeneratedBSDFDataDebug(uint paramId, BSDFData bsdfdata, inout float3 res
282282
result = bsdfdata.tangentWS * 0.5 + 0.5;
283283
break;
284284
case DEBUGVIEW_AXF_BSDFDATA_BI_TANGENT_WS:
285-
result = bsdfdata.biTangentWS * 0.5 + 0.5;
285+
result = bsdfdata.bitangentWS * 0.5 + 0.5;
286286
break;
287287
case DEBUGVIEW_AXF_BSDFDATA_DIFFUSE_COLOR:
288288
result = bsdfdata.diffuseColor;
@@ -291,7 +291,7 @@ void GetGeneratedBSDFDataDebug(uint paramId, BSDFData bsdfdata, inout float3 res
291291
result = bsdfdata.specularColor;
292292
break;
293293
case DEBUGVIEW_AXF_BSDFDATA_FRESNEL_F0:
294-
result = bsdfdata.fresnelF0;
294+
result = bsdfdata.fresnel0;
295295
break;
296296
case DEBUGVIEW_AXF_BSDFDATA_PERCEPTUAL_ROUGHNESS:
297297
result = bsdfdata.perceptualRoughness.xxx;

com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.hlsl

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ float3 CarPaint_BTF(float thetaH, float thetaD, SurfaceData surfaceData, BSDFDa
880880
// Base refers to the "base layer", ie not the coat if present.
881881
float3 GetColorBaseFresnelF0(BSDFData bsdfData)
882882
{
883-
return bsdfData.fresnelF0.r * bsdfData.specularColor;
883+
return bsdfData.fresnel0.r * bsdfData.specularColor;
884884
}
885885

886886
// For raytracing fit to standard Lit:
@@ -1157,6 +1157,8 @@ float MultiLobesCookTorrance(BSDFData bsdfData, float NdotL, float NdotV, float
11571157

11581158
specularIntensity += coeff * CT_D(NdotH, spread) * CT_F(VdotH, F0);
11591159
}
1160+
1161+
// FIXME: should be 4 instead of PI at the denominator, this was a mistake in the original paper
11601162
specularIntensity *= G_CookTorrance(NdotH, NdotV, NdotL, VdotH) // Shadowing/Masking term
11611163
/ (PI * max(1e-3, NdotV * NdotL));
11621164

@@ -1212,7 +1214,7 @@ BSDFData ConvertSurfaceDataToBSDFData(uint2 positionSS, SurfaceData surfaceData)
12121214

12131215
bsdfData.normalWS = surfaceData.normalWS;
12141216
bsdfData.tangentWS = surfaceData.tangentWS;
1215-
bsdfData.biTangentWS = cross(bsdfData.normalWS, bsdfData.tangentWS);
1217+
bsdfData.bitangentWS = cross(bsdfData.normalWS, bsdfData.tangentWS);
12161218

12171219
bsdfData.roughness = 0;
12181220
// see AxFData.hlsl: important, this is used in PostEvaluateBSDF here and in AxFRayTracing
@@ -1222,7 +1224,7 @@ BSDFData ConvertSurfaceDataToBSDFData(uint2 positionSS, SurfaceData surfaceData)
12221224
bsdfData.diffuseColor = surfaceData.diffuseColor;
12231225
bsdfData.specularColor = surfaceData.specularColor;
12241226

1225-
bsdfData.fresnelF0 = surfaceData.fresnelF0; // See AxfData.hlsl: the actual sampled texture is always 1 channel, if we ever find otherwise, we will use the others.
1227+
bsdfData.fresnel0 = surfaceData.fresnel0; // See AxfData.hlsl: the actual sampled texture is always 1 channel, if we ever find otherwise, we will use the others.
12261228
bsdfData.height_mm = surfaceData.height_mm;
12271229

12281230
bsdfData.roughness.xy = HasAnisotropy() ? surfaceData.specularLobe.xy : surfaceData.specularLobe.xx;
@@ -1240,7 +1242,7 @@ BSDFData ConvertSurfaceDataToBSDFData(uint2 positionSS, SurfaceData surfaceData)
12401242
bsdfData.clearcoatNormalWS = HasClearcoat() ? surfaceData.clearcoatNormalWS : surfaceData.normalWS;
12411243

12421244
bsdfData.specularColor = GetCarPaintSpecularColor();
1243-
bsdfData.fresnelF0 = GetCarPaintFresnel0();
1245+
bsdfData.fresnel0 = GetCarPaintFresnel0();
12441246
bsdfData.roughness.xyz = surfaceData.specularLobe.xyz; // the later stores per lobe possibly modified (for geometric specular AA) _CarPaint2_CTSpreads
12451247
bsdfData.height_mm = 0;
12461248
#endif
@@ -1397,7 +1399,7 @@ PreLightData GetPreLightData(float3 viewWS_Clearcoat, PositionInputs posInput
13971399

13981400
// todo_fresnel: TOCHECK: Make BRDF and FGD for env. consistent with dirac lights for HasFresnelTerm() handling:
13991401
// currently, we only check it for Ward and its variants.
1400-
float3 tempF0 = HasFresnelTerm() ? bsdfData.fresnelF0.rrr : 1.0;
1402+
float3 tempF0 = HasFresnelTerm() ? bsdfData.fresnel0.rrr : 1.0;
14011403
tempF0 *= bsdfData.specularColor; // Important to use in the PreIntegratedFGD interpolated fetches!
14021404

14031405
float specularReflectivity;
@@ -1767,12 +1769,12 @@ float3 ComputeWard(float3 H, float LdotH, float NdotL, float NdotV, PreLightData
17671769
float F = 1.0;
17681770
switch (AXF_SVBRDF_BRDFVARIANTS_FRESNELTYPE)
17691771
{
1770-
case 1: F = F_FresnelDieletricSafe(Fresnel0ToIorSafe(bsdfData.fresnelF0.r), LdotH); break;
1771-
case 2: F = F_Schlick(bsdfData.fresnelF0.r, LdotH); break;
1772+
case 1: F = F_FresnelDieletricSafe(Fresnel0ToIorSafe(bsdfData.fresnel0.r), LdotH); break;
1773+
case 2: F = F_Schlick(bsdfData.fresnel0.r, LdotH); break;
17721774
}
17731775

17741776
// Evaluate normal distribution function
1775-
float3 tsH = float3(dot(H, bsdfData.tangentWS), dot(H, bsdfData.biTangentWS), dot(H, bsdfData.normalWS));
1777+
float3 tsH = float3(dot(H, bsdfData.tangentWS), dot(H, bsdfData.bitangentWS), dot(H, bsdfData.normalWS));
17761778
//float2 rotH = tsH.xy / tsH.z;
17771779
float2 rotH = tsH.xy / max(0.00001, tsH.z);
17781780
//float2 roughness = bsdfData.roughness.xy;
@@ -1804,7 +1806,7 @@ float3 ComputeBlinnPhong(float3 H, float LdotH, float NdotL, float NdotV, PreLi
18041806
float2 exponents = 2 * rcp(max(0.0001,(bsdfData.roughness.xy*bsdfData.roughness.xy))) - 2;
18051807

18061808
// Evaluate normal distribution function
1807-
float3 tsH = float3(dot(H, bsdfData.tangentWS), dot(H, bsdfData.biTangentWS), dot(H, bsdfData.normalWS));
1809+
float3 tsH = float3(dot(H, bsdfData.tangentWS), dot(H, bsdfData.bitangentWS), dot(H, bsdfData.normalWS));
18081810
float2 rotH = tsH.xy;
18091811

18101812
float3 N = 0;
@@ -1841,7 +1843,7 @@ float3 ComputeCookTorrance(float3 H, float LdotH, float NdotL, float NdotV, Pre
18411843
float sqNdotH = Sq(NdotH);
18421844

18431845
// Evaluate Fresnel term
1844-
float F = F_Schlick(bsdfData.fresnelF0.r, LdotH);
1846+
float F = F_Schlick(bsdfData.fresnel0.r, LdotH);
18451847

18461848
// Evaluate (isotropic) normal distribution function (Beckmann)
18471849
float roughness = GetScalarRoughnessFromAnisoRoughness(bsdfData.roughness.x, bsdfData.roughness.y);
@@ -1858,9 +1860,9 @@ float3 ComputeCookTorrance(float3 H, float LdotH, float NdotL, float NdotV, Pre
18581860
float3 ComputeGGX(float3 H, float LdotH, float NdotL, float NdotV, PreLightData preLightData, BSDFData bsdfData)
18591861
{
18601862
// Evaluate Fresnel term
1861-
float F = F_Schlick(bsdfData.fresnelF0.r, LdotH);
1863+
float F = F_Schlick(bsdfData.fresnel0.r, LdotH);
18621864

1863-
float3 tsH = float3(dot(H, bsdfData.tangentWS), dot(H, bsdfData.biTangentWS), dot(H, bsdfData.normalWS));
1865+
float3 tsH = float3(dot(H, bsdfData.tangentWS), dot(H, bsdfData.bitangentWS), dot(H, bsdfData.normalWS));
18641866

18651867
// Evaluate normal distribution function (Trowbridge-Reitz)
18661868
float N = D_GGXAniso(tsH.x, tsH.y, tsH.z, bsdfData.roughness.x, bsdfData.roughness.y);
@@ -2050,7 +2052,7 @@ CBSDF EvaluateBSDF(float3 viewWS_Clearcoat, float3 lightWS_Clearcoat, PreLightDa
20502052

20512053
// Apply flakes
20522054
//TODO_FLAKES
2053-
specularTerm += CarPaint_BTF(thetaH, thetaD, (SurfaceData)0, bsdfData, /*useBSDFData:*/true);;
2055+
specularTerm += CarPaint_BTF(thetaH, thetaD, (SurfaceData)0, bsdfData, /*useBSDFData:*/true);
20542056

20552057
cbsdf.diffR = clearcoatExtinction * diffuseTerm * saturate(NdotL);
20562058
cbsdf.specR = (clearcoatExtinction * specularTerm * saturate(NdotL) + clearcoatReflectionLobeNdotL);

com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.shader

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,43 @@ Shader "HDRP/AxF"
757757

758758
ENDHLSL
759759
}
760+
761+
Pass
762+
{
763+
Name "PathTracingDXR"
764+
Tags{ "LightMode" = "PathTracingDXR" }
765+
766+
HLSLPROGRAM
767+
768+
#pragma only_renderers d3d11
769+
#pragma raytracing surface_shader
770+
771+
#pragma multi_compile _ DEBUG_DISPLAY
772+
773+
#define SHADERPASS SHADERPASS_PATH_TRACING
774+
775+
// This is just because it needs to be defined, shadow maps are not used.
776+
#define SHADOW_LOW
777+
778+
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingMacros.hlsl"
779+
780+
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/ShaderVariablesRaytracing.hlsl"
781+
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
782+
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl"
783+
784+
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/ShaderPass/AxFSharePass.hlsl"
785+
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingIntersection.hlsl"
786+
787+
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl"
788+
#define HAS_LIGHTLOOP
789+
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RayTracingCommon.hlsl"
790+
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.hlsl"
791+
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxFData.hlsl"
792+
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxFPathTracing.hlsl"
793+
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassPathTracing.hlsl"
794+
795+
ENDHLSL
796+
}
760797
}
761798

762799
CustomEditor "Rendering.HighDefinition.AxFGUI"

com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxFData.hlsl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p
636636

637637
// The AxF models include both a general coloring term that they call "specular color" while the f0 is actually another term,
638638
// seemingly always scalar:
639-
surfaceData.fresnelF0 = AXF_SAMPLE_SMP_TEXTURE2D(_SVBRDF_FresnelMap, sampler_SVBRDF_FresnelMap, uvMapping).x;
639+
surfaceData.fresnel0 = AXF_SAMPLE_SMP_TEXTURE2D(_SVBRDF_FresnelMap, sampler_SVBRDF_FresnelMap, uvMapping).x;
640640
surfaceData.height_mm = AXF_SAMPLE_SMP_TEXTURE2D(_SVBRDF_HeightMap, sampler_SVBRDF_HeightMap, uvMapping).x * _SVBRDF_HeightMapMaxMM;
641641
// Our importer range remaps the [-HALF_PI, HALF_PI) range to [0,1). We map back here:
642642
surfaceData.anisotropyAngle =
@@ -672,7 +672,7 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p
672672

673673
// Useless for car paint BSDF
674674
surfaceData.specularColor = 0;
675-
surfaceData.fresnelF0 = 0;
675+
surfaceData.fresnel0 = 0;
676676
surfaceData.height_mm = 0;
677677
surfaceData.anisotropyAngle = 0;
678678
#endif
@@ -739,7 +739,7 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p
739739
surfaceData.tangentWS = Orthonormalize(surfaceData.tangentWS, surfaceData.normalWS);
740740

741741
// Instead of
742-
// surfaceData.biTangentWS = Orthonormalize(input.tangentToWorld[1], surfaceData.normalWS),
742+
// surfaceData.bitangentWS = Orthonormalize(input.tangentToWorld[1], surfaceData.normalWS),
743743
// make AxF follow what we do in other HDRP shaders for consistency: use the
744744
// cross product to finish building the TBN frame and thus get a frame matching
745745
// the handedness of the world space (tangentToWorld can be passed right handed while
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingIntersection.hlsl"
2+
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingMaterial.hlsl"
3+
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingBSDF.hlsl"
4+
5+
// AxF Material Data:
6+
//
7+
// bsdfWeight0 Diffuse BRDF
8+
// bsdfWeight1 Clearoat BRDF
9+
// bsdfWeight2 Specular BRDF(s)
10+
11+
float3 GetCoatNormal(MaterialData mtlData)
12+
{
13+
return mtlData.bsdfData.clearcoatNormalWS;
14+
}
15+
16+
#ifdef _AXF_BRDF_TYPE_CAR_PAINT
17+
float GetSpecularCoeffSum(MaterialData mtlData)
18+
{
19+
return mtlData.bsdfData.height_mm;
20+
}
21+
#endif
22+
23+
void ProcessBSDFData(PathIntersection pathIntersection, BuiltinData builtinData, MaterialData mtlData, inout BSDFData bsdfData)
24+
{
25+
// Adjust roughness to reduce fireflies
26+
bsdfData.roughness.x = max(pathIntersection.maxRoughness, bsdfData.roughness.x);
27+
bsdfData.roughness.y = max(pathIntersection.maxRoughness, bsdfData.roughness.y);
28+
#ifdef _AXF_BRDF_TYPE_CAR_PAINT
29+
bsdfData.roughness.z = max(pathIntersection.maxRoughness, bsdfData.roughness.z);
30+
#endif
31+
32+
// One of the killer features of AxF, optional specular Fresnel...
33+
if (!HasFresnelTerm())
34+
bsdfData.fresnel0 = 1.0;
35+
36+
// Make sure we can get valid coat normal reflection directions
37+
if (HasClearcoat())
38+
bsdfData.clearcoatNormalWS = ComputeConsistentShadingNormal(mtlData.V, bsdfData.geomNormalWS, bsdfData.clearcoatNormalWS);
39+
40+
#ifdef _AXF_BRDF_TYPE_CAR_PAINT
41+
// We hijack height_mm, as it is not used here otherwise, to store the specular coefficients sum
42+
bsdfData.height_mm = 0.0;
43+
UNITY_UNROLL
44+
for (uint i = 0; i < CARPAINT2_LOBE_COUNT; i++)
45+
bsdfData.height_mm += _CarPaint2_CTCoeffs[i];
46+
#endif
47+
}
48+
49+
bool CreateMaterialData(PathIntersection pathIntersection, BuiltinData builtinData, BSDFData bsdfData, inout float3 shadingPosition, inout float theSample, out MaterialData mtlData)
50+
{
51+
// Alter values in the material's bsdfData struct, to better suit path tracing
52+
mtlData.V = -WorldRayDirection();
53+
mtlData.Nv = ComputeConsistentShadingNormal(mtlData.V, bsdfData.geomNormalWS, bsdfData.normalWS);
54+
mtlData.bsdfData = bsdfData;
55+
ProcessBSDFData(pathIntersection, builtinData, mtlData, mtlData.bsdfData);
56+
57+
mtlData.bsdfWeight = 0.0;
58+
59+
// First determine if our incoming direction V is above (exterior) or below (interior) the surface
60+
if (IsAbove(mtlData))
61+
{
62+
float NcoatdotV = dot(GetCoatNormal(mtlData), mtlData.V);
63+
float NspecdotV = dot(GetSpecularNormal(mtlData), mtlData.V);
64+
float Fcoat = F_Schlick(IorToFresnel0(bsdfData.clearcoatIOR), NcoatdotV);
65+
float Fspec = Luminance(F_Schlick(mtlData.bsdfData.fresnel0, NspecdotV));
66+
67+
#if defined(_AXF_BRDF_TYPE_SVBRDF)
68+
float specularCoeff = Luminance(mtlData.bsdfData.specularColor);
69+
#elif defined(_AXF_BRDF_TYPE_CAR_PAINT)
70+
float specularCoeff = GetSpecularCoeffSum(mtlData);
71+
#endif
72+
73+
mtlData.bsdfWeight[1] = HasClearcoat() ? Fcoat * Luminance(mtlData.bsdfData.clearcoatColor) : 0.0;
74+
float clearcoatTransmission = HasClearcoat() ? 1.0 - Fcoat : 1.0;
75+
mtlData.bsdfWeight[2] = clearcoatTransmission * lerp(Fspec, 0.5, GetScalarRoughness(mtlData.bsdfData.roughness)) * specularCoeff;
76+
mtlData.bsdfWeight[0] = clearcoatTransmission * Luminance(mtlData.bsdfData.diffuseColor) * mtlData.bsdfData.ambientOcclusion;
77+
}
78+
79+
// Normalize the weights
80+
float wSum = mtlData.bsdfWeight[0] + mtlData.bsdfWeight[1] + mtlData.bsdfWeight[2];
81+
82+
if (wSum < BSDF_WEIGHT_EPSILON)
83+
return false;
84+
85+
mtlData.bsdfWeight /= wSum;
86+
87+
return true;
88+
}
89+
90+
#if defined(_AXF_BRDF_TYPE_SVBRDF)
91+
# include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxFPathTracingSVBRDF.hlsl"
92+
#elif defined(_AXF_BRDF_TYPE_CAR_PAINT)
93+
# include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxFPathTracingCarPaint.hlsl"
94+
#endif
95+
96+
float3 GetLightNormal(MaterialData mtlData)
97+
{
98+
// If both diffuse and specular normals are quasi-indentical, return one of them, otherwise return a null vector
99+
return dot(GetDiffuseNormal(mtlData), GetSpecularNormal(mtlData)) > 0.99 ? GetDiffuseNormal(mtlData) : float3(0.0, 0.0, 0.0);
100+
}
101+
102+
float AdjustPathRoughness(MaterialData mtlData, MaterialResult mtlResult, bool isSampleBelow, float pathRoughness)
103+
{
104+
// Adjust the max roughness, based on the estimated diff/spec ratio
105+
float maxSpecRoughness = Max3(mtlData.bsdfData.roughness.x, mtlData.bsdfData.roughness.y, mtlData.bsdfData.roughness.z);
106+
float adjustedPathRoughness = (mtlResult.specPdf * maxSpecRoughness + mtlResult.diffPdf) / (mtlResult.diffPdf + mtlResult.specPdf);
107+
108+
return adjustedPathRoughness;
109+
}
110+
111+
float3 ApplyAbsorption(MaterialData mtlData, SurfaceData surfaceData, float dist, bool isSampleBelow, float3 value)
112+
{
113+
return value;
114+
}

0 commit comments

Comments
 (0)