浏览代码

Merge pull request #1533 from Unity-Technologies/Add-support-for-multiple-PreIntegratedFGD

HDRP: Add support for multiple PreIntegratedFGD + updte hlsl debug nu…
/main
GitHub 6 年前
当前提交
5a626b21
共有 25 个文件被更改,包括 413 次插入156 次删除
  1. 61
      com.unity.render-pipelines.core/CoreRP/ShaderLibrary/BSDF.hlsl
  2. 11
      com.unity.render-pipelines.core/CoreRP/ShaderLibrary/CommonLighting.hlsl
  3. 68
      com.unity.render-pipelines.core/CoreRP/ShaderLibrary/ImageBasedLighting.hlsl
  4. 3
      com.unity.render-pipelines.high-definition/HDRP/Editor/RenderPipeline/HDAssetFactory.cs
  5. 2
      com.unity.render-pipelines.high-definition/HDRP/Material/Builtin/BuiltinData.cs
  6. 4
      com.unity.render-pipelines.high-definition/HDRP/Material/Builtin/BuiltinData.cs.hlsl
  7. 2
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.cs
  8. 8
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.cs.hlsl
  9. 10
      com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.cs
  10. 48
      com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.cs.hlsl
  11. 10
      com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.hlsl
  12. 106
      com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/PreIntegratedFGD.cs
  13. 17
      com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/PreIntegratedFGD.hlsl
  14. 4
      com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/preIntegratedFGD_CharlieClothLambert.shader
  15. 12
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.cs
  16. 114
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.cs.hlsl
  17. 4
      com.unity.render-pipelines.high-definition/HDRP/Material/Unlit/Unlit.cs
  18. 4
      com.unity.render-pipelines.high-definition/HDRP/Material/Unlit/Unlit.cs.hlsl
  19. 5
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDStringConstants.cs
  20. 5
      com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/HDRenderPipelineResources.asset
  21. 3
      com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/RenderPipelineResources.cs
  22. 9
      com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/preIntegratedFGD_CharlieClothLambert.shader.meta
  23. 59
      com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/preIntegratedFGD_GGXDisneyDiffuse.shader
  24. 0
      /com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/preIntegratedFGD_GGXDisneyDiffuse.shader.meta
  25. 0
      /com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/preIntegratedFGD_CharlieClothLambert.shader

61
com.unity.render-pipelines.core/CoreRP/ShaderLibrary/BSDF.hlsl


return I;
}
//-----------------------------------------------------------------------------
// Cloth
//-----------------------------------------------------------------------------
// Ref: https://knarkowicz.wordpress.com/2018/01/04/cloth-shading/
real D_CharlieNoPI(real NdotH, real roughness)
{
float invR = rcp(roughness);
float cos2h = NdotH * NdotH;
float sin2h = 1.0 - cos2h;
// Note: We have sin^2 so multiply by 0.5 to cancel it
return (2.0 + invR) * PositivePow(sin2h, invR * 0.5) / 2.0;
}
real D_Charlie(real NdotH, real roughness)
{
return INV_PI * D_CharlieNoPI(NdotH, roughness);
}
real CharlieL(real x, real r)
{
r = saturate(r);
r = (1. - r * r);
float a = lerp(25.3245, 21.5473, r);
float b = lerp(3.32435, 3.82987, r);
float c = lerp(0.16801, 0.19823, r);
float d = lerp(-1.27393, -1.97760, r);
float e = lerp(-4.85967, -4.32054, r);
return a / (1. + b * PositivePow(x, c)) + d * x + e;
}
// Note: This version don't include the softening of the paper: Production Friendly Microfacet Sheen BRDF
real V_Charlie(real NdotL, real NdotV, real roughness)
{
real lambdaV = NdotV < 0.5 ? exp(CharlieL(NdotV, roughness)) : exp(2.0 * CharlieL(0.5, roughness) - CharlieL(1.0 - NdotV, roughness));
real lambdaL = NdotL < 0.5 ? exp(CharlieL(NdotL, roughness)) : exp(2.0 * CharlieL(0.5, roughness) - CharlieL(1.0 - NdotL, roughness));
return 1.0 / ((1.0 + lambdaV + lambdaL) * (4.0 * NdotV * NdotL));
}
// We use V_Ashikhmin instead of V_Charlie in practice for game due to the cost of V_Charlie
real V_Ashikhmin(real NdotL, real NdotV)
{
// Use soft visibility term introduce in: Crafting a Next-Gen Material Pipeline for The Order : 1886
return 1.0 / (4.0 * (NdotL + NdotV - NdotL * NdotV));
}
// A diffuse term use with cloth done by tech artist - empirical
real ClothLambertNoPI(real roughness)
{
return lerp(1.0, 0.5, roughness);
}
real ClothLambert(real roughness)
{
return INV_PI * ClothLambertNoPI(roughness);
}
#endif // UNITY_BSDF_INCLUDED

11
com.unity.render-pipelines.core/CoreRP/ShaderLibrary/CommonLighting.hlsl


return max(NdotV, 0.0001);
}
// return usual BSDF angle
void GetBSDFAngle(float3 V, float3 L, float NdotL, float unclampNdotV, out float LdotV, out float NdotH, out float LdotH, out float clampNdotV, out float invLenLV)
{
// Optimized math. Ref: PBR Diffuse Lighting for GGX + Smith Microsurfaces (slide 114).
LdotV = dot(L, V);
invLenLV = rsqrt(max(2.0 * LdotV + 2.0, FLT_EPS)); // invLenLV = rcp(length(L + V)), clamp to avoid rsqrt(0) = NaN
NdotH = saturate((NdotL + unclampNdotV) * invLenLV); // Do not clamp NdotV here
LdotH = saturate(invLenLV * LdotV + invLenLV);
clampNdotV = ClampNdotV(unclampNdotV);
}
// Inputs: normalized normal and view vectors.
// Outputs: front-facing normal, and the new non-negative value of the cosine of the view angle.
// Important: call Orthonormalize() on the tangent and recompute the bitangent afterwards.

68
com.unity.render-pipelines.core/CoreRP/ShaderLibrary/ImageBasedLighting.hlsl


#if !defined SHADER_API_GLES
// Ref: Listing 18 in "Moving Frostbite to PBR" + https://knarkowicz.wordpress.com/2014/12/27/analytical-dfg-term-for-ibl/
real4 IntegrateGGXAndDisneyFGD(real3 V, real3 N, real roughness, uint sampleCount = 8192)
real4 IntegrateGGXAndDisneyDiffuseFGD(real3 V, real3 N, real roughness, uint sampleCount = 8192)
{
real NdotV = ClampNdotV(dot(N, V));
real4 acc = real4(0.0, 0.0, 0.0, 0.0);

}
#else
// Not supported due to lack of random library in GLES 2
#define IntegrateGGXAndDisneyFGD ERROR_ON_UNSUPPORTED_FUNCTION(IntegrateGGXAndDisneyFGD)
#define IntegrateGGXAndDisneyDiffuseFGD ERROR_ON_UNSUPPORTED_FUNCTION(IntegrateGGXAndDisneyDiffuseFGD)
#endif
#if !defined SHADER_API_GLES
real4 IntegrateCharlieAndClothLambertFGD(real3 V, real3 N, real roughness, uint sampleCount = 8192)
{
real NdotV = ClampNdotV(dot(N, V));
real4 acc = real4(0.0, 0.0, 0.0, 0.0);
// Add some jittering on Hammersley2d
real2 randNum = InitRandom(V.xy * 0.5 + 0.5);
real3x3 localToWorld = GetLocalFrame(N);
for (uint i = 0; i < sampleCount; ++i)
{
real2 u = frac(randNum + Hammersley2d(i, sampleCount));
real NdotL;
real weightOverPdf;
// Ref: Production Friendly Microfacet Sheen BRDF
// Paper recommend plain uniform sampling of upper hemisphere instead of importance sampling for Charlie
real3 localL = SampleHemisphereUniform(u.x, u.y);
real3 L = mul(localL, localToWorld);
NdotL = saturate(dot(N, L));
if (NdotL > 0.0)
{
// Sampling weight for each sample
// pdf = 1 / 2PI
// weight = fr * (N.L) with fr = CharlieV * CharlieD / PI
// weight over pdf is:
// weightOverPdf = (CharlieV * CharlieD / PI) * (N.L) / (1 / 2PI)
// weightOverPdf = 2 * CharlieV * CharlieD * (N.L)
real3 H = normalize(V + L);
real NdotH = dot(N, H);
// Note: we use V_Charlie and not the approx when computing FGD texture as we can afford it
weightOverPdf = 2.0 * V_Charlie(NdotL, NdotV, roughness) * D_CharlieNoPI(NdotH, roughness) * NdotL;
// Integral{BSDF * <N,L> dw} =
// Integral{(F0 + (1 - F0) * (1 - <V,H>)^5) * (BSDF / F) * <N,L> dw} =
// (1 - F0) * Integral{(1 - <V,H>)^5 * (BSDF / F) * <N,L> dw} + F0 * Integral{(BSDF / F) * <N,L> dw}=
// (1 - F0) * x + F0 * y = lerp(x, y, F0)
real VdotH = dot(V, H);
acc.x += weightOverPdf * pow(1 - VdotH, 5);
acc.y += weightOverPdf;
}
// for cloth Lambert we still use a Cosine importance sampling
ImportanceSampleLambert(u, localToWorld, L, NdotL, weightOverPdf);
if (NdotL > 0.0)
{
real clothLambert = ClothLambertNoPI(roughness);
acc.z += clothLambert * weightOverPdf;
}
}
acc /= sampleCount;
return acc;
}
#else
// Not supported due to lack of random library in GLES 2
#define IntegrateCharlieAndClothLambertFGD ERROR_ON_UNSUPPORTED_FUNCTION(IntegrateCharlieAndClothLambertFGD)
#endif
uint GetIBLRuntimeFilterSampleCount(uint mipLevel)

3
com.unity.render-pipelines.high-definition/HDRP/Editor/RenderPipeline/HDAssetFactory.cs


newAsset.skyboxCubemap = Shader.Find("Skybox/Cubemap");
// Material
newAsset.preIntegratedFGD = Load<Shader>(HDRenderPipelinePath + "Material/PreIntegratedFGD/PreIntegratedFGD.shader");
newAsset.preIntegratedFGD_GGXDisneyDiffuse = Load<Shader>(HDRenderPipelinePath + "Material/PreIntegratedFGD/PreIntegratedFGD_GGXDisneyDiffuse.shader");
newAsset.preIntegratedFGD_CharlieClothLambert = Load<Shader>(HDRenderPipelinePath + "Material/PreIntegratedFGD/PreIntegratedFGD_CharlieClothLambert.shader");
// Utilities / Core
newAsset.encodeBC6HCS = Load<ComputeShader>(CorePath + "CoreResources/EncodeBC6H.compute");

2
com.unity.render-pipelines.high-definition/HDRP/Material/Builtin/BuiltinData.cs


// LightTransportData
// This struct is use to store information for Enlighten/Progressive light mapper. both at runtime or off line.
//-----------------------------------------------------------------------------
[GenerateHLSL(PackingRules.Exact, false, true, 120)]
[GenerateHLSL(PackingRules.Exact, false, true, 150)]
public struct LightTransportData
{
[SurfaceDataAttributes("", false, true)]

4
com.unity.render-pipelines.high-definition/HDRP/Material/Builtin/BuiltinData.cs.hlsl


//
// UnityEngine.Experimental.Rendering.HDPipeline.Builtin+LightTransportData: static fields
//
#define DEBUGVIEW_BUILTIN_LIGHTTRANSPORTDATA_DIFFUSE_COLOR (120)
#define DEBUGVIEW_BUILTIN_LIGHTTRANSPORTDATA_EMISSIVE_COLOR (121)
#define DEBUGVIEW_BUILTIN_LIGHTTRANSPORTDATA_DIFFUSE_COLOR (150)
#define DEBUGVIEW_BUILTIN_LIGHTTRANSPORTDATA_EMISSIVE_COLOR (151)
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Builtin+BuiltinData
// PackingRules = Exact

2
com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.cs


public partial class Decal
{
// Main structure that store the user data (i.e user input of master node in material graph)
[GenerateHLSL(PackingRules.Exact, false, true, 10000)]
[GenerateHLSL(PackingRules.Exact, false, true, 200)]
public struct DecalSurfaceData
{
[SurfaceDataAttributes("Base Color", false, true)]

8
com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.cs.hlsl


//
// UnityEngine.Experimental.Rendering.HDPipeline.Decal+DecalSurfaceData: static fields
//
#define DEBUGVIEW_DECAL_DECALSURFACEDATA_BASE_COLOR (10000)
#define DEBUGVIEW_DECAL_DECALSURFACEDATA_NORMAL (10001)
#define DEBUGVIEW_DECAL_DECALSURFACEDATA_MASK (10002)
#define DEBUGVIEW_DECAL_DECALSURFACEDATA_HTILE_MASK (10003)
#define DEBUGVIEW_DECAL_DECALSURFACEDATA_BASE_COLOR (200)
#define DEBUGVIEW_DECAL_DECALSURFACEDATA_NORMAL (201)
#define DEBUGVIEW_DECAL_DECALSURFACEDATA_MASK (202)
#define DEBUGVIEW_DECAL_DECALSURFACEDATA_HTILE_MASK (203)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Decal+DBufferMaterial: static fields

10
com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.cs


// BSDFData
//-----------------------------------------------------------------------------
[GenerateHLSL(PackingRules.Exact, false, true, 1030)]
[GenerateHLSL(PackingRules.Exact, false, true, 1050)]
public struct BSDFData
{
public uint materialFeatures;

public override void Build(HDRenderPipelineAsset hdAsset)
{
PreIntegratedFGD.instance.Build();
PreIntegratedFGD.instance.Build(PreIntegratedFGD.FGDIndex.FGD_GGXAndDisneyDiffuse);
LTCAreaLight.instance.Build();
m_isInit = false;

{
PreIntegratedFGD.instance.Cleanup();
PreIntegratedFGD.instance.Cleanup(PreIntegratedFGD.FGDIndex.FGD_GGXAndDisneyDiffuse);
LTCAreaLight.instance.Cleanup();
m_isInit = false;

if (m_isInit)
return;
PreIntegratedFGD.instance.RenderInit(cmd);
PreIntegratedFGD.instance.RenderInit(PreIntegratedFGD.FGDIndex.FGD_GGXAndDisneyDiffuse, cmd);
m_isInit = true;
}

PreIntegratedFGD.instance.Bind();
PreIntegratedFGD.instance.Bind(PreIntegratedFGD.FGDIndex.FGD_GGXAndDisneyDiffuse);
LTCAreaLight.instance.Bind();
}
}

48
com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.cs.hlsl


//
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+BSDFData: static fields
//
#define DEBUGVIEW_LIT_BSDFDATA_MATERIAL_FEATURES (1030)
#define DEBUGVIEW_LIT_BSDFDATA_DIFFUSE_COLOR (1031)
#define DEBUGVIEW_LIT_BSDFDATA_FRESNEL0 (1032)
#define DEBUGVIEW_LIT_BSDFDATA_SPECULAR_OCCLUSION (1033)
#define DEBUGVIEW_LIT_BSDFDATA_NORMAL_WS (1034)
#define DEBUGVIEW_LIT_BSDFDATA_NORMAL_VIEW_SPACE (1035)
#define DEBUGVIEW_LIT_BSDFDATA_PERCEPTUAL_ROUGHNESS (1036)
#define DEBUGVIEW_LIT_BSDFDATA_COAT_MASK (1037)
#define DEBUGVIEW_LIT_BSDFDATA_DIFFUSION_PROFILE (1038)
#define DEBUGVIEW_LIT_BSDFDATA_SUBSURFACE_MASK (1039)
#define DEBUGVIEW_LIT_BSDFDATA_THICKNESS (1040)
#define DEBUGVIEW_LIT_BSDFDATA_USE_THICK_OBJECT_MODE (1041)
#define DEBUGVIEW_LIT_BSDFDATA_TRANSMITTANCE (1042)
#define DEBUGVIEW_LIT_BSDFDATA_TANGENT_WS (1043)
#define DEBUGVIEW_LIT_BSDFDATA_BITANGENT_WS (1044)
#define DEBUGVIEW_LIT_BSDFDATA_ROUGHNESS_T (1045)
#define DEBUGVIEW_LIT_BSDFDATA_ROUGHNESS_B (1046)
#define DEBUGVIEW_LIT_BSDFDATA_ANISOTROPY (1047)
#define DEBUGVIEW_LIT_BSDFDATA_IRIDESCENCE_THICKNESS (1048)
#define DEBUGVIEW_LIT_BSDFDATA_IRIDESCENCE_MASK (1049)
#define DEBUGVIEW_LIT_BSDFDATA_COAT_ROUGHNESS (1050)
#define DEBUGVIEW_LIT_BSDFDATA_IOR (1051)
#define DEBUGVIEW_LIT_BSDFDATA_ABSORPTION_COEFFICIENT (1052)
#define DEBUGVIEW_LIT_BSDFDATA_TRANSMITTANCE_MASK (1053)
#define DEBUGVIEW_LIT_BSDFDATA_MATERIAL_FEATURES (1050)
#define DEBUGVIEW_LIT_BSDFDATA_DIFFUSE_COLOR (1051)
#define DEBUGVIEW_LIT_BSDFDATA_FRESNEL0 (1052)
#define DEBUGVIEW_LIT_BSDFDATA_SPECULAR_OCCLUSION (1053)
#define DEBUGVIEW_LIT_BSDFDATA_NORMAL_WS (1054)
#define DEBUGVIEW_LIT_BSDFDATA_NORMAL_VIEW_SPACE (1055)
#define DEBUGVIEW_LIT_BSDFDATA_PERCEPTUAL_ROUGHNESS (1056)
#define DEBUGVIEW_LIT_BSDFDATA_COAT_MASK (1057)
#define DEBUGVIEW_LIT_BSDFDATA_DIFFUSION_PROFILE (1058)
#define DEBUGVIEW_LIT_BSDFDATA_SUBSURFACE_MASK (1059)
#define DEBUGVIEW_LIT_BSDFDATA_THICKNESS (1060)
#define DEBUGVIEW_LIT_BSDFDATA_USE_THICK_OBJECT_MODE (1061)
#define DEBUGVIEW_LIT_BSDFDATA_TRANSMITTANCE (1062)
#define DEBUGVIEW_LIT_BSDFDATA_TANGENT_WS (1063)
#define DEBUGVIEW_LIT_BSDFDATA_BITANGENT_WS (1064)
#define DEBUGVIEW_LIT_BSDFDATA_ROUGHNESS_T (1065)
#define DEBUGVIEW_LIT_BSDFDATA_ROUGHNESS_B (1066)
#define DEBUGVIEW_LIT_BSDFDATA_ANISOTROPY (1067)
#define DEBUGVIEW_LIT_BSDFDATA_IRIDESCENCE_THICKNESS (1068)
#define DEBUGVIEW_LIT_BSDFDATA_IRIDESCENCE_MASK (1069)
#define DEBUGVIEW_LIT_BSDFDATA_COAT_ROUGHNESS (1070)
#define DEBUGVIEW_LIT_BSDFDATA_IOR (1071)
#define DEBUGVIEW_LIT_BSDFDATA_ABSORPTION_COEFFICIENT (1072)
#define DEBUGVIEW_LIT_BSDFDATA_TRANSMITTANCE_MASK (1073)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+GBufferMaterial: static fields

10
com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.hlsl


out float3 diffuseLighting,
out float3 specularLighting)
{
float3 N = bsdfData.normalWS;
// Optimized math. Ref: PBR Diffuse Lighting for GGX + Smith Microsurfaces (slide 114).
float LdotV = dot(L, V);
float invLenLV = rsqrt(max(2.0 * LdotV + 2.0, FLT_EPS)); // invLenLV = rcp(length(L + V)), clamp to avoid rsqrt(0) = NaN
float NdotH = saturate((NdotL + preLightData.NdotV) * invLenLV); // Do not clamp NdotV here
float LdotH = saturate(invLenLV * LdotV + invLenLV);
float NdotV = ClampNdotV(preLightData.NdotV);
float LdotV, NdotH, LdotH, NdotV, invLenLV;
GetBSDFAngle(V, L, NdotL, preLightData.NdotV, LdotV, NdotH, LdotH, NdotV, invLenLV);
float3 F = F_Schlick(bsdfData.fresnel0, LdotH);
// Remark: Fresnel must be use with LdotH angle. But Fresnel for iridescence is expensive to compute at each light.

106
com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/PreIntegratedFGD.cs


}
}
bool m_isInit;
int m_refCounting;
public enum FGDIndex
{
FGD_GGXAndDisneyDiffuse = 0,
FGD_CharlieAndClothLambert = 1,
Count = 2
}
bool[] m_isInit = new bool[(int)FGDIndex.Count];
int[] m_refCounting = new int[(int)FGDIndex.Count];
// For image based lighting
Material m_PreIntegratedFGDMaterial;
RenderTexture m_PreIntegratedFGD;
Material[] m_PreIntegratedFGDMaterial = new Material[(int)FGDIndex.Count];
RenderTexture[] m_PreIntegratedFGD = new RenderTexture[(int)FGDIndex.Count];
{
m_isInit = false;
m_refCounting = 0;
{
for (int i = 0; i < (int)FGDIndex.Count; ++i)
{
m_isInit[i] = false;
m_refCounting[i] = 0;
}
public void Build()
public void Build(FGDIndex index)
Debug.Assert(m_refCounting >= 0);
Debug.Assert(index != FGDIndex.Count);
Debug.Assert(m_refCounting[(int)index] >= 0);
if (m_refCounting == 0)
if (m_refCounting[(int)index] == 0)
m_PreIntegratedFGDMaterial = CoreUtils.CreateEngineMaterial(hdrp.renderPipelineResources.preIntegratedFGD);
switch(index)
{
case FGDIndex.FGD_GGXAndDisneyDiffuse:
m_PreIntegratedFGDMaterial[(int)index] = CoreUtils.CreateEngineMaterial(hdrp.renderPipelineResources.preIntegratedFGD_GGXDisneyDiffuse);
m_PreIntegratedFGD[(int)index] = new RenderTexture(128, 128, 0, RenderTextureFormat.ARGB2101010, RenderTextureReadWrite.Linear);
m_PreIntegratedFGD[(int)index].hideFlags = HideFlags.HideAndDontSave;
m_PreIntegratedFGD[(int)index].filterMode = FilterMode.Bilinear;
m_PreIntegratedFGD[(int)index].wrapMode = TextureWrapMode.Clamp;
m_PreIntegratedFGD[(int)index].name = CoreUtils.GetRenderTargetAutoName(128, 128, 1, RenderTextureFormat.ARGB2101010, "preIntegratedFGD_GGXDisneyDiffuse");
m_PreIntegratedFGD[(int)index].Create();
break;
m_PreIntegratedFGD = new RenderTexture(128, 128, 0, RenderTextureFormat.ARGB2101010, RenderTextureReadWrite.Linear);
m_PreIntegratedFGD.hideFlags = HideFlags.HideAndDontSave;
m_PreIntegratedFGD.filterMode = FilterMode.Bilinear;
m_PreIntegratedFGD.wrapMode = TextureWrapMode.Clamp;
m_PreIntegratedFGD.hideFlags = HideFlags.DontSave;
m_PreIntegratedFGD.name = CoreUtils.GetRenderTargetAutoName(128, 128, 1, RenderTextureFormat.ARGB2101010, "PreIntegratedFGD");
m_PreIntegratedFGD.Create();
case FGDIndex.FGD_CharlieAndClothLambert:
m_PreIntegratedFGDMaterial[(int)index] = CoreUtils.CreateEngineMaterial(hdrp.renderPipelineResources.preIntegratedFGD_CharlieClothLambert);
m_PreIntegratedFGD[(int)index] = new RenderTexture(128, 128, 0, RenderTextureFormat.ARGB2101010, RenderTextureReadWrite.Linear);
m_PreIntegratedFGD[(int)index].hideFlags = HideFlags.HideAndDontSave;
m_PreIntegratedFGD[(int)index].filterMode = FilterMode.Bilinear;
m_PreIntegratedFGD[(int)index].wrapMode = TextureWrapMode.Clamp;
m_PreIntegratedFGD[(int)index].name = CoreUtils.GetRenderTargetAutoName(128, 128, 1, RenderTextureFormat.ARGB2101010, "preIntegratedFGD_CharlieClothLambert");
m_PreIntegratedFGD[(int)index].Create();
break;
m_isInit = false;
default:
break;
}
m_isInit[(int)index] = false;
m_refCounting++;
m_refCounting[(int)index]++;
public void RenderInit(CommandBuffer cmd)
public void RenderInit(FGDIndex index, CommandBuffer cmd)
if (m_isInit)
if (m_isInit[(int)index])
CoreUtils.DrawFullScreen(cmd, m_PreIntegratedFGDMaterial, new RenderTargetIdentifier(m_PreIntegratedFGD));
CoreUtils.DrawFullScreen(cmd, m_PreIntegratedFGDMaterial[(int)index], new RenderTargetIdentifier(m_PreIntegratedFGD[(int)index]));
m_isInit = true;
m_isInit[(int)index] = true;
public void Cleanup()
public void Cleanup(FGDIndex index)
m_refCounting--;
m_refCounting[(int)index]--;
if (m_refCounting == 0)
if (m_refCounting[(int)index] == 0)
CoreUtils.Destroy(m_PreIntegratedFGDMaterial);
CoreUtils.Destroy(m_PreIntegratedFGD);
CoreUtils.Destroy(m_PreIntegratedFGDMaterial[(int)index]);
CoreUtils.Destroy(m_PreIntegratedFGD[(int)index]);
m_isInit = false;
m_isInit[(int)index] = false;
Debug.Assert(m_refCounting >= 0);
Debug.Assert(m_refCounting[(int)index] >= 0);
public void Bind()
public void Bind(FGDIndex index)
Shader.SetGlobalTexture("_PreIntegratedFGD", m_PreIntegratedFGD);
switch (index)
{
case FGDIndex.FGD_GGXAndDisneyDiffuse:
Shader.SetGlobalTexture(HDShaderIDs._PreIntegratedFGD_GGXDisneyDiffuse, m_PreIntegratedFGD[(int)index]);
break;
case FGDIndex.FGD_CharlieAndClothLambert:
Shader.SetGlobalTexture(HDShaderIDs._PreIntegratedFGD_CharlieAndCloth, m_PreIntegratedFGD[(int)index]);
break;
default:
break;
}
}
}
}

17
com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/PreIntegratedFGD.hlsl


TEXTURE2D(_PreIntegratedFGD);
TEXTURE2D(_PreIntegratedFGD_GGXDisneyDiffuse);
// For image based lighting, a part of the BSDF is pre-integrated.
// This is done both for specular GGX height-correlated and DisneyDiffuse

float3 preFGD = SAMPLE_TEXTURE2D_LOD(_PreIntegratedFGD, s_linear_clamp_sampler, float2(NdotV, perceptualRoughness), 0).xyz;
float3 preFGD = SAMPLE_TEXTURE2D_LOD(_PreIntegratedFGD_GGXDisneyDiffuse, s_linear_clamp_sampler, float2(NdotV, perceptualRoughness), 0).xyz;
// Pre-integrate GGX FGD
// Integral{BSDF * <N,L> dw} =

reflectivity = preFGD.y;
}
TEXTURE2D(_PreIntegratedFGD_CharlieAndCloth);
void GetPreIntegratedFGDCharlieAndClothLambert(float NdotV, float perceptualRoughness, float3 fresnel0, out float3 CharlieSpecularFGD, out float clothLambertDiffuseFGD, out float reflectivity)
{
float3 preFGD = SAMPLE_TEXTURE2D_LOD(_PreIntegratedFGD_CharlieAndCloth, s_linear_clamp_sampler, float2(NdotV, perceptualRoughness), 0).xyz;
CharlieSpecularFGD = lerp(preFGD.xxx, preFGD.yyy, fresnel0);
// z = ClothLambert
clothLambertDiffuseFGD = preFGD.z;
reflectivity = preFGD.y;
}

4
com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/preIntegratedFGD_CharlieClothLambert.shader


Shader "Hidden/HDRenderPipeline/PreIntegratedFGD"
Shader "Hidden/HDRenderPipeline/preIntegratedFGD_CharlieClothLambert"
{
SubShader
{

float3 N = float3(0.0, 0.0, 1.0);
// Pre integrate GGX with smithJoint visibility as well as DisneyDiffuse
float4 preFGD = IntegrateGGXAndDisneyFGD(V, N, PerceptualRoughnessToRoughness(perceptualRoughness));
float4 preFGD = IntegrateCharlieAndClothLambertFGD(V, N, PerceptualRoughnessToRoughness(perceptualRoughness));
return float4(preFGD.xyz, 1.0);
}

12
com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.cs


//-----------------------------------------------------------------------------
// Main structure that store the user data (i.e user input of master node in material graph)
[GenerateHLSL(PackingRules.Exact, false, true, 1300)]
[GenerateHLSL(PackingRules.Exact, false, true, 1100)]
public struct SurfaceData
{
[SurfaceDataAttributes("Material Features")]

//-----------------------------------------------------------------------------
// BSDFData
//-----------------------------------------------------------------------------
[GenerateHLSL(PackingRules.Exact, false, true, 1400)]
[GenerateHLSL(PackingRules.Exact, false, true, 1150)]
public struct BSDFData
{
public uint materialFeatures;

public override void Build(HDRenderPipelineAsset hdAsset)
{
PreIntegratedFGD.instance.Build();
PreIntegratedFGD.instance.Build(PreIntegratedFGD.FGDIndex.FGD_GGXAndDisneyDiffuse);
//LTCAreaLight.instance.Build();
m_isInit = false;

{
PreIntegratedFGD.instance.Cleanup();
PreIntegratedFGD.instance.Cleanup(PreIntegratedFGD.FGDIndex.FGD_GGXAndDisneyDiffuse);
//LTCAreaLight.instance.Cleanup();
m_isInit = false;

if (m_isInit)
return;
PreIntegratedFGD.instance.RenderInit(cmd);
PreIntegratedFGD.instance.RenderInit(PreIntegratedFGD.FGDIndex.FGD_GGXAndDisneyDiffuse, cmd);
m_isInit = true;
}

PreIntegratedFGD.instance.Bind();
PreIntegratedFGD.instance.Bind(PreIntegratedFGD.FGDIndex.FGD_GGXAndDisneyDiffuse);
//LTCAreaLight.instance.Bind();
}
}

114
com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.cs.hlsl


//
// UnityEngine.Experimental.Rendering.HDPipeline.StackLit+SurfaceData: static fields
//
#define DEBUGVIEW_STACKLIT_SURFACEDATA_MATERIAL_FEATURES (1300)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_BASE_COLOR (1301)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_AMBIENT_OCCLUSION (1302)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_METALLIC (1303)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_IOR (1304)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_NORMAL (1305)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_NORMAL_VIEW_SPACE (1306)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_GEOMETRIC_NORMAL (1307)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_GEOMETRIC_NORMAL_VIEW_SPACE (1308)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_COAT_NORMAL (1309)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_COAT_NORMAL_VIEW_SPACE (1310)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_SMOOTHNESS_A (1311)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_SMOOTHNESS_B (1312)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_LOBE_MIXING (1313)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_TANGENT (1314)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_ANISOTROPY (1315)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_IRIDESCENCE_IOR (1316)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_IRIDESCENCE_THICKNESS (1317)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_COAT_SMOOTHNESS (1318)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_COAT_IOR (1319)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_COAT_THICKNESS (1320)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_COAT_EXTINCTION_COEFFICIENT (1321)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_DIFFUSION_PROFILE (1322)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_SUBSURFACE_MASK (1323)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_THICKNESS (1324)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_MATERIAL_FEATURES (1100)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_BASE_COLOR (1101)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_AMBIENT_OCCLUSION (1102)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_METALLIC (1103)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_IOR (1104)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_NORMAL (1105)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_NORMAL_VIEW_SPACE (1106)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_GEOMETRIC_NORMAL (1107)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_GEOMETRIC_NORMAL_VIEW_SPACE (1108)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_COAT_NORMAL (1109)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_COAT_NORMAL_VIEW_SPACE (1110)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_SMOOTHNESS_A (1111)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_SMOOTHNESS_B (1112)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_LOBE_MIXING (1113)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_TANGENT (1114)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_ANISOTROPY (1115)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_IRIDESCENCE_IOR (1116)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_IRIDESCENCE_THICKNESS (1117)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_COAT_SMOOTHNESS (1118)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_COAT_IOR (1119)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_COAT_THICKNESS (1120)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_COAT_EXTINCTION_COEFFICIENT (1121)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_DIFFUSION_PROFILE (1122)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_SUBSURFACE_MASK (1123)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_THICKNESS (1124)
#define DEBUGVIEW_STACKLIT_BSDFDATA_MATERIAL_FEATURES (1400)
#define DEBUGVIEW_STACKLIT_BSDFDATA_DIFFUSE_COLOR (1401)
#define DEBUGVIEW_STACKLIT_BSDFDATA_FRESNEL0 (1402)
#define DEBUGVIEW_STACKLIT_BSDFDATA_AMBIENT_OCCLUSION (1403)
#define DEBUGVIEW_STACKLIT_BSDFDATA_NORMAL_WS (1404)
#define DEBUGVIEW_STACKLIT_BSDFDATA_NORMAL_VIEW_SPACE (1405)
#define DEBUGVIEW_STACKLIT_BSDFDATA_GEOMETRIC_NORMAL (1406)
#define DEBUGVIEW_STACKLIT_BSDFDATA_GEOMETRIC_NORMAL_VIEW_SPACE (1407)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_NORMAL (1408)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_NORMAL_VIEW_SPACE (1409)
#define DEBUGVIEW_STACKLIT_BSDFDATA_PERCEPTUAL_ROUGHNESS_A (1410)
#define DEBUGVIEW_STACKLIT_BSDFDATA_PERCEPTUAL_ROUGHNESS_B (1411)
#define DEBUGVIEW_STACKLIT_BSDFDATA_LOBE_MIX (1412)
#define DEBUGVIEW_STACKLIT_BSDFDATA_TANGENT_WS (1413)
#define DEBUGVIEW_STACKLIT_BSDFDATA_BITANGENT_WS (1414)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ROUGHNESS_AT (1415)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ROUGHNESS_AB (1416)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ROUGHNESS_BT (1417)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ROUGHNESS_BB (1418)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ANISOTROPY (1419)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_ROUGHNESS (1420)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_PERCEPTUAL_ROUGHNESS (1421)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_IOR (1422)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_THICKNESS (1423)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_EXTINCTION (1424)
#define DEBUGVIEW_STACKLIT_BSDFDATA_IRIDESCENCE_IOR (1425)
#define DEBUGVIEW_STACKLIT_BSDFDATA_IRIDESCENCE_THICKNESS (1426)
#define DEBUGVIEW_STACKLIT_BSDFDATA_DIFFUSION_PROFILE (1427)
#define DEBUGVIEW_STACKLIT_BSDFDATA_SUBSURFACE_MASK (1428)
#define DEBUGVIEW_STACKLIT_BSDFDATA_THICKNESS (1429)
#define DEBUGVIEW_STACKLIT_BSDFDATA_USE_THICK_OBJECT_MODE (1430)
#define DEBUGVIEW_STACKLIT_BSDFDATA_TRANSMITTANCE (1431)
#define DEBUGVIEW_STACKLIT_BSDFDATA_MATERIAL_FEATURES (1150)
#define DEBUGVIEW_STACKLIT_BSDFDATA_DIFFUSE_COLOR (1151)
#define DEBUGVIEW_STACKLIT_BSDFDATA_FRESNEL0 (1152)
#define DEBUGVIEW_STACKLIT_BSDFDATA_AMBIENT_OCCLUSION (1153)
#define DEBUGVIEW_STACKLIT_BSDFDATA_NORMAL_WS (1154)
#define DEBUGVIEW_STACKLIT_BSDFDATA_NORMAL_VIEW_SPACE (1155)
#define DEBUGVIEW_STACKLIT_BSDFDATA_GEOMETRIC_NORMAL (1156)
#define DEBUGVIEW_STACKLIT_BSDFDATA_GEOMETRIC_NORMAL_VIEW_SPACE (1157)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_NORMAL (1158)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_NORMAL_VIEW_SPACE (1159)
#define DEBUGVIEW_STACKLIT_BSDFDATA_PERCEPTUAL_ROUGHNESS_A (1160)
#define DEBUGVIEW_STACKLIT_BSDFDATA_PERCEPTUAL_ROUGHNESS_B (1161)
#define DEBUGVIEW_STACKLIT_BSDFDATA_LOBE_MIX (1162)
#define DEBUGVIEW_STACKLIT_BSDFDATA_TANGENT_WS (1163)
#define DEBUGVIEW_STACKLIT_BSDFDATA_BITANGENT_WS (1164)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ROUGHNESS_AT (1165)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ROUGHNESS_AB (1166)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ROUGHNESS_BT (1167)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ROUGHNESS_BB (1168)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ANISOTROPY (1169)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_ROUGHNESS (1170)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_PERCEPTUAL_ROUGHNESS (1171)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_IOR (1172)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_THICKNESS (1173)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_EXTINCTION (1174)
#define DEBUGVIEW_STACKLIT_BSDFDATA_IRIDESCENCE_IOR (1175)
#define DEBUGVIEW_STACKLIT_BSDFDATA_IRIDESCENCE_THICKNESS (1176)
#define DEBUGVIEW_STACKLIT_BSDFDATA_DIFFUSION_PROFILE (1177)
#define DEBUGVIEW_STACKLIT_BSDFDATA_SUBSURFACE_MASK (1178)
#define DEBUGVIEW_STACKLIT_BSDFDATA_THICKNESS (1179)
#define DEBUGVIEW_STACKLIT_BSDFDATA_USE_THICK_OBJECT_MODE (1180)
#define DEBUGVIEW_STACKLIT_BSDFDATA_TRANSMITTANCE (1181)
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.StackLit+SurfaceData
// PackingRules = Exact

4
com.unity.render-pipelines.high-definition/HDRP/Material/Unlit/Unlit.cs


//-----------------------------------------------------------------------------
// Main structure that store the user data (i.e user input of master node in material graph)
[GenerateHLSL(PackingRules.Exact, false, true, 1100)]
[GenerateHLSL(PackingRules.Exact, false, true, 300)]
public struct SurfaceData
{
[SurfaceDataAttributes("Color", false, true)]

// BSDFData
//-----------------------------------------------------------------------------
[GenerateHLSL(PackingRules.Exact, false, true, 1130)]
[GenerateHLSL(PackingRules.Exact, false, true, 350)]
public struct BSDFData
{
[SurfaceDataAttributes("", false, true)]

4
com.unity.render-pipelines.high-definition/HDRP/Material/Unlit/Unlit.cs.hlsl


//
// UnityEngine.Experimental.Rendering.HDPipeline.Unlit+SurfaceData: static fields
//
#define DEBUGVIEW_UNLIT_SURFACEDATA_COLOR (1100)
#define DEBUGVIEW_UNLIT_SURFACEDATA_COLOR (300)
#define DEBUGVIEW_UNLIT_BSDFDATA_COLOR (1130)
#define DEBUGVIEW_UNLIT_BSDFDATA_COLOR (350)
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Unlit+SurfaceData
// PackingRules = Exact

5
com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDStringConstants.cs


public static readonly int g_TileListOffset = Shader.PropertyToID("g_TileListOffset");
public static readonly int _LtcData = Shader.PropertyToID("_LtcData");
public static readonly int _PreIntegratedFGD = Shader.PropertyToID("_PreIntegratedFGD");
public static readonly int _LtcGGXMatrix = Shader.PropertyToID("_LtcGGXMatrix");
public static readonly int _LtcDisneyDiffuseMatrix = Shader.PropertyToID("_LtcDisneyDiffuseMatrix");
public static readonly int _LtcMultiGGXFresnelDisneyDiffuse = Shader.PropertyToID("_LtcMultiGGXFresnelDisneyDiffuse");

public static readonly int _NumVisibleDensityVolumes = Shader.PropertyToID("_NumVisibleDensityVolumes");
public static readonly int _VolumeMaskAtlas = Shader.PropertyToID("_VolumeMaskAtlas");
public static readonly int _VolumeMaskDimensions = Shader.PropertyToID("_VolumeMaskDimensions");
// Preintegrated texture name
public static readonly int _PreIntegratedFGD_GGXDisneyDiffuse = Shader.PropertyToID("_PreIntegratedFGD_GGXDisneyDiffuse");
public static readonly int _PreIntegratedFGD_CharlieAndCloth = Shader.PropertyToID("_PreIntegratedFGD_CharlieAndCloth");
}
}

5
com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/HDRenderPipelineResources.asset


hdriSky: {fileID: 4800000, guid: 9bd32a6ece529fd4f9408b8d7e00c10d, type: 3}
proceduralSky: {fileID: 4800000, guid: ec63f47fd265df243a7b1d40f9ef7fe7, type: 3}
skyboxCubemap: {fileID: 103, guid: 0000000000000000f000000000000000, type: 0}
preIntegratedFGD: {fileID: 4800000, guid: 123f13d52852ef547b2962de4bd9eaad, type: 3}
preIntegratedFGD_GGXDisneyDiffuse: {fileID: 4800000, guid: 123f13d52852ef547b2962de4bd9eaad,
type: 3}
preIntegratedFGD_CharlieClothLambert: {fileID: 4800000, guid: 3b3bf235775cf8b4baae7f3306787ab0,
type: 3}
encodeBC6HCS: {fileID: 7200000, guid: aa922d239de60304f964e24488559eeb, type: 3}
cubeToPanoShader: {fileID: 4800000, guid: 595434cc3b6405246b6cd3086d0b6f7d, type: 3}
blitCubeTextureFace: {fileID: 4800000, guid: d850d0a2481878d4bbf17e5126b04163, type: 3}

3
com.unity.render-pipelines.high-definition/HDRP/RenderPipelineResources/RenderPipelineResources.cs


public Shader skyboxCubemap;
// Material
public Shader preIntegratedFGD;
public Shader preIntegratedFGD_GGXDisneyDiffuse;
public Shader preIntegratedFGD_CharlieClothLambert;
// Utilities / Core
public ComputeShader encodeBC6HCS;

9
com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/preIntegratedFGD_CharlieClothLambert.shader.meta


fileFormatVersion: 2
guid: 3b3bf235775cf8b4baae7f3306787ab0
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

59
com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/preIntegratedFGD_GGXDisneyDiffuse.shader


Shader "Hidden/HDRenderPipeline/preIntegratedFGD_GGXDisneyDiffuse"
{
SubShader
{
Tags{ "RenderPipeline" = "HDRenderPipeline" }
Pass
{
ZTest Always Cull Off ZWrite Off
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment Frag
#pragma target 4.5
#pragma only_renderers d3d11 ps4 xboxone vulkan metal switch
#include "CoreRP/ShaderLibrary/Common.hlsl"
#include "CoreRP/ShaderLibrary/ImageBasedLighting.hlsl"
#include "../../ShaderVariables.hlsl"
struct Attributes
{
uint vertexID : SV_VertexID;
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float2 texCoord : TEXCOORD0;
};
Varyings Vert(Attributes input)
{
Varyings output;
output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID);
output.texCoord = GetFullScreenTriangleTexCoord(input.vertexID);
return output;
}
float4 Frag(Varyings input) : SV_Target
{
// These coordinate sampling must match the decoding in GetPreIntegratedDFG in lit.hlsl, i.e here we use perceptualRoughness, must be the same in shader
float NdotV = input.texCoord.x;
float perceptualRoughness = input.texCoord.y;
float3 V = float3(sqrt(1 - NdotV * NdotV), 0, NdotV);
float3 N = float3(0.0, 0.0, 1.0);
// Pre integrate GGX with smithJoint visibility as well as DisneyDiffuse
float4 preFGD = IntegrateGGXAndDisneyDiffuseFGD(V, N, PerceptualRoughnessToRoughness(perceptualRoughness));
return float4(preFGD.xyz, 1.0);
}
ENDHLSL
}
}
Fallback Off
}

/com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/PreIntegratedFGD.shader.meta → /com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/preIntegratedFGD_GGXDisneyDiffuse.shader.meta

/com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/PreIntegratedFGD.shader → /com.unity.render-pipelines.high-definition/HDRP/Material/PreIntegratedFGD/preIntegratedFGD_CharlieClothLambert.shader

正在加载...
取消
保存