浏览代码

Add a UIBufferedProperty and implement a limiting option for hazy gloss parametrization's output f0 for dielectrics when metallic input is used.

Also move static property forwarding setup functions in BaseMaterialUI.
/StackLit2
Stephane Laroche 6 年前
当前提交
09d96a6f
共有 8 个文件被更改,包括 272 次插入101 次删除
  1. 170
      com.unity.render-pipelines.high-definition/HDRP/Editor/Material/StackLit/BaseMaterialUI.cs
  2. 140
      com.unity.render-pipelines.high-definition/HDRP/Editor/Material/StackLit/StackLitUI.cs
  3. 4
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.cs
  4. 8
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.cs.hlsl
  5. 36
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.hlsl
  6. 2
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.shader
  7. 11
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLitData.hlsl
  8. 2
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLitProperties.hlsl

170
com.unity.render-pipelines.high-definition/HDRP/Editor/Material/StackLit/BaseMaterialUI.cs


}
}
public class UIBufferedProperty : Property
{
public string RealPropertyName;
public MaterialProperty m_RealMaterialProperty = null;
public new bool IsValid
{
get { return (m_MaterialProperty != null) && (m_RealMaterialProperty != null); }
}
public UIBufferedProperty(BaseMaterialGUI parent, string propertyName, string guiText, bool isMandatory = true, Func<object, bool> isVisible = null)
: this(parent, propertyName, guiText, string.Empty, isMandatory, isVisible)
{
}
public UIBufferedProperty(BaseMaterialGUI parent, string propertyName, string guiText, string toolTip, bool isMandatory = true, Func<object, bool> isVisible = null)
: base(parent, propertyName + "UIBuffer", guiText, toolTip, isMandatory, isVisible)
{
RealPropertyName = propertyName;
}
public override void OnFindProperty(MaterialProperty[] props)
{
base.OnFindProperty(props);
m_RealMaterialProperty = ShaderGUI.FindProperty(RealPropertyName, props, IsMandatory);
}
public override void OnGUI()
{
if (IsValid)
{
base.OnGUI();
}
}
internal override string ToShaderPropertiesStringInternal()
{
if (IsValid
&& (IsVisible == null || IsVisible(this)))
{
switch (m_MaterialProperty.type)
{
case MaterialProperty.PropType.Color:
return base.ToShaderPropertiesStringInternal() + "\n" + string.Format("[HideInInspector] {0}(\"{1}\", Color) = (1, 1, 1, 1)", RealPropertyName, PropertyText);
case MaterialProperty.PropType.Vector:
return base.ToShaderPropertiesStringInternal() + "\n" + string.Format("[HideInInspector] {0}(\"{1}\", Vector) = (0, 0, 0, 0)", RealPropertyName, PropertyText);
case MaterialProperty.PropType.Float:
return base.ToShaderPropertiesStringInternal() + "\n" + string.Format("[HideInInspector] {0}(\"{1}\", Float) = 0.0", RealPropertyName, PropertyText);
case MaterialProperty.PropType.Range:
return base.ToShaderPropertiesStringInternal() + "\n" + string.Format("[HideInInspector] {0}(\"{1}\", Range({2:0.0###}, {3:0.0###})) = 0", RealPropertyName, PropertyText, m_MaterialProperty.rangeLimits.x, m_MaterialProperty.rangeLimits.y);
case MaterialProperty.PropType.Texture:
return base.ToShaderPropertiesStringInternal() + "\n" + string.Format("[HideInInspector] {0}(\"{1}\", 2D) = \"white\" {{}}", RealPropertyName, PropertyText);
default:
// Unknown type... default to outputting a float.
return base.ToShaderPropertiesStringInternal() + "\n" + string.Format("[HideInInspector] {0}(\"{1}\", Float) = 0.0", RealPropertyName, PropertyText);
}
}
else
{
// Material property is not loaded, default to outputting a float.
return base.ToShaderPropertiesStringInternal() + "\n" + string.Format("{0}(\"{1}\", Float) = 0.0", PropertyName, PropertyText);
}
}
public static void SetupUIBufferedMaterialProperty(Material material, string basePropertyName, MaterialProperty.PropType propType)
{
string uibufferPropertyName = basePropertyName + "UIBuffer";
if (material.HasProperty(basePropertyName) && material.HasProperty(uibufferPropertyName))
{
switch(propType)
{
case MaterialProperty.PropType.Color:
material.SetColor(basePropertyName, material.GetColor(uibufferPropertyName));
break;
case MaterialProperty.PropType.Vector:
material.SetVector(basePropertyName, material.GetVector(uibufferPropertyName));
break;
case MaterialProperty.PropType.Float:
material.SetFloat(basePropertyName, material.GetFloat(uibufferPropertyName));
break;
case MaterialProperty.PropType.Texture:
material.SetTexture(basePropertyName, material.GetTexture(uibufferPropertyName));
break;
default:
// Unknown / not implemented
break;
}
}
}
}
public class DiffusionProfileProperty : Property
{
public DiffusionProfileProperty(BaseMaterialGUI parent, string propertyName, string guiText, string toolTip, bool isMandatory = true, Func<object, bool> isVisible = null)

"[HideInInspector] {0}Range(\"{1} Range\", Vector) = (0, 1, 0, 0)\n",
m_ConstantPropertyName, constantName, PropertyName);
}
public static void SetupTextureMaterialProperty(Material material, string basePropertyName)
{
// TODO: Caution this can generate a lot of garbage collection call ?
string useMapPropertyName = basePropertyName + "UseMap";
string mapPropertyName = basePropertyName + "Map";
string remapPropertyName = basePropertyName + "MapRemap";
string invertPropertyName = basePropertyName + "MapRemapInverted";
string rangePropertyName = basePropertyName + "MapRange";
string channelPropertyName = basePropertyName + "MapChannel";
string channelMaskPropertyName = basePropertyName + "MapChannelMask";
if (material.GetTexture(mapPropertyName))
{
if (material.HasProperty(remapPropertyName) && material.HasProperty(rangePropertyName))
{
Vector4 rangeVector = material.GetVector(remapPropertyName);
if (material.HasProperty(invertPropertyName) && material.GetFloat(invertPropertyName) > 0.0f)
{
float s = rangeVector.x;
rangeVector.x = rangeVector.y;
rangeVector.y = s;
}
material.SetVector(rangePropertyName, rangeVector);
}
if (material.HasProperty(useMapPropertyName))
{
material.SetFloat(useMapPropertyName, 1.0f);
}
if (material.HasProperty(channelPropertyName))
{
int channel = (int)material.GetFloat(channelPropertyName);
switch (channel)
{
case 0:
material.SetVector(channelMaskPropertyName, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
break;
case 1:
material.SetVector(channelMaskPropertyName, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
break;
case 2:
material.SetVector(channelMaskPropertyName, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
break;
case 3:
material.SetVector(channelMaskPropertyName, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
break;
}
}
}
else
{
if (material.HasProperty(useMapPropertyName))
{
material.SetFloat(useMapPropertyName, 0.0f);
}
if (material.HasProperty(rangePropertyName))
{
material.SetVector(rangePropertyName, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
}
if (material.HasProperty(channelPropertyName))
{
material.SetVector(channelMaskPropertyName, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
}
}
}
}
#endregion
}

140
com.unity.render-pipelines.high-definition/HDRP/Editor/Material/StackLit/StackLitUI.cs


protected const string k_HazeExtentMapUV = "_HazeExtentMapUV";
protected const string k_CapHazinessWrtMetallic = "_CapHazinessWrtMetallic";
protected const string k_HazyGlossMaxDielectricF0 = "_HazyGlossMaxDielectricF0"; // only valid if above option enabled and we have a basecolor + metallic input parametrization
// Anisotropy
protected const string k_EnableAnisotropy = "_EnableAnisotropy";

private ComboProperty BaseParametrization;
private ComboProperty DualSpecularLobeParametrization;
private Property CapHazinessWrtMetallic;
private bool IsCapDielectricUsed
{
get { return (IsMetallicParametrizationUsed) && (CapHazinessWrtMetallic.IsValid && CapHazinessWrtMetallic.BoolValue == true); }
}
public StackLitGUI()
{
_baseMaterialProperties = new GroupProperty(this, "_BaseMaterial", new BaseProperty[]

var Haziness = new TextureProperty(this, k_HazinessMap, k_Haziness, "Haziness", "Haziness", false, false);
var HazeExtent = new TextureProperty(this, k_HazeExtentMap, k_HazeExtent, "Haze Extent", "Haze Extent", false, false);
var CapHazinessWrtMetallic = new Property(this, k_CapHazinessWrtMetallic, "Cap Haziness Wrt Metallic", "Cap Haziness To Agree With Metallic", false,
CapHazinessWrtMetallic = new Property(this, k_CapHazinessWrtMetallic, "Cap Haziness Wrt Metallic", "Cap Haziness To Agree With Metallic", false,
var HazyGlossMaxDielectricF0UI = new UIBufferedProperty(this, k_HazyGlossMaxDielectricF0, "Maximum Dielectric Specular Color", "Cap Dielectrics To This Maximum Dielectric Specular Color", false,
_ => (IsCapDielectricUsed));
var HazyGlossMaxDielectricF0 = new Property(this, k_HazyGlossMaxDielectricF0, "Maximum Dielectric Specular Color", "Cap Dielectrics To This Maximum Dielectric Specular Color", true);
// ...this later property is always used by the shader when IsMetallicParametrizationUsed and IsHazyGlossParametrizationUsed, but since these are dynamic,
// we always make the base property mandatory.
var DualSpecularLobeDirectGroup = new GroupProperty(this, "_DualSpecularLobe", "Dual Specular Lobe (Direct Control Mode)", new BaseProperty[]
{
DualSpecularLobeParametrization,

DualSpecularLobeParametrization,
Haziness,
CapHazinessWrtMetallic,
HazyGlossMaxDielectricF0UI,
HazeExtent,
}, _ => (EnableDualSpecularLobe.BoolValue == true && IsHazyGlossParametrizationUsed) );

SetupMaterialKeywordsAndPass(material);
}
protected static void SetupTextureMaterialProperty(Material material, string basePropertyName)
{
// TODO: Caution this can generate a lot of garbage collection call ?
string useMapPropertyName = basePropertyName + "UseMap";
string mapPropertyName = basePropertyName + "Map";
string remapPropertyName = basePropertyName + "MapRemap";
string invertPropertyName = basePropertyName + "MapRemapInverted";
string rangePropertyName = basePropertyName + "MapRange";
string channelPropertyName = basePropertyName + "MapChannel";
string channelMaskPropertyName = basePropertyName + "MapChannelMask";
if (material.GetTexture(mapPropertyName))
{
if (material.HasProperty(remapPropertyName) && material.HasProperty(rangePropertyName))
{
Vector4 rangeVector = material.GetVector(remapPropertyName);
if (material.HasProperty(invertPropertyName) && material.GetFloat(invertPropertyName) > 0.0f)
{
float s = rangeVector.x;
rangeVector.x = rangeVector.y;
rangeVector.y = s;
}
material.SetVector(rangePropertyName, rangeVector);
}
if (material.HasProperty(useMapPropertyName))
{
material.SetFloat(useMapPropertyName, 1.0f);
}
if (material.HasProperty(channelPropertyName))
{
int channel = (int)material.GetFloat(channelPropertyName);
switch (channel)
{
case 0:
material.SetVector(channelMaskPropertyName, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
break;
case 1:
material.SetVector(channelMaskPropertyName, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
break;
case 2:
material.SetVector(channelMaskPropertyName, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
break;
case 3:
material.SetVector(channelMaskPropertyName, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
break;
}
}
}
else
{
if (material.HasProperty(useMapPropertyName))
{
material.SetFloat(useMapPropertyName, 0.0f);
}
if (material.HasProperty(rangePropertyName))
{
material.SetVector(rangePropertyName, new Vector4(0.0f, 1.0f, 0.0f, 0.0f));
}
if (material.HasProperty(channelPropertyName))
{
material.SetVector(channelMaskPropertyName, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
}
}
}
// All Setup Keyword functions must be static. It allow to create script to automatically update the shaders with a script if code change
public static void SetupMaterialKeywordsAndPass(Material material)
{

//TODO: disable DBUFFER
SetupTextureMaterialProperty(material, k_Metallic);
SetupTextureMaterialProperty(material, k_SmoothnessA);
SetupTextureMaterialProperty(material, k_SmoothnessB);
SetupTextureMaterialProperty(material, k_LobeMix);
SetupTextureMaterialProperty(material, k_Haziness);
SetupTextureMaterialProperty(material, k_HazeExtent);
SetupTextureMaterialProperty(material, k_AmbientOcclusion);
SetupTextureMaterialProperty(material, k_SubsurfaceMask);
SetupTextureMaterialProperty(material, k_Thickness);
SetupTextureMaterialProperty(material, k_Anisotropy);
SetupTextureMaterialProperty(material, k_IridescenceThickness);
SetupTextureMaterialProperty(material, k_IridescenceMask);
SetupTextureMaterialProperty(material, k_CoatSmoothness);
TextureProperty.SetupTextureMaterialProperty(material, k_Metallic);
TextureProperty.SetupTextureMaterialProperty(material, k_SmoothnessA);
TextureProperty.SetupTextureMaterialProperty(material, k_SmoothnessB);
TextureProperty.SetupTextureMaterialProperty(material, k_LobeMix);
TextureProperty.SetupTextureMaterialProperty(material, k_Haziness);
TextureProperty.SetupTextureMaterialProperty(material, k_HazeExtent);
TextureProperty.SetupTextureMaterialProperty(material, k_AmbientOcclusion);
TextureProperty.SetupTextureMaterialProperty(material, k_SubsurfaceMask);
TextureProperty.SetupTextureMaterialProperty(material, k_Thickness);
TextureProperty.SetupTextureMaterialProperty(material, k_Anisotropy);
TextureProperty.SetupTextureMaterialProperty(material, k_IridescenceThickness);
TextureProperty.SetupTextureMaterialProperty(material, k_IridescenceMask);
TextureProperty.SetupTextureMaterialProperty(material, k_CoatSmoothness);
SetupTextureMaterialProperty(material, k_DetailMask);
SetupTextureMaterialProperty(material, k_DetailSmoothness);
TextureProperty.SetupTextureMaterialProperty(material, k_DetailMask);
TextureProperty.SetupTextureMaterialProperty(material, k_DetailSmoothness);
bool detailsEnabled = material.HasProperty(k_EnableDetails) && material.GetFloat(k_EnableDetails) > 0.0f;

bool hazyGlossEnabled = dualSpecularLobeEnabled && material.HasProperty(k_DualSpecularLobeParametrization)
&& ((StackLit.DualSpecularLobeParametrization)material.GetFloat(k_DualSpecularLobeParametrization) == StackLit.DualSpecularLobeParametrization.HazyGloss);
CoreUtils.SetKeyword(material, "_MATERIAL_FEATURE_HAZY_GLOSS", hazyGlossEnabled);
// This is not a keyword but we validate an input here that act as one:
// HazyGlossMaxDielectricF0
bool hazyGloosMaxDielectricF0Required = hazyGlossEnabled && (specularColorEnabled == false);
bool hazyGlossUseMaxDielectricF0 = hazyGloosMaxDielectricF0Required
&& material.HasProperty(k_CapHazinessWrtMetallic) && material.GetFloat(k_CapHazinessWrtMetallic) > 0.0f;
if (hazyGloosMaxDielectricF0Required)
{
if (hazyGlossUseMaxDielectricF0 == false)
{
// In that case, the shader expects k_HazyGlossMaxDielectricF0 so we don't pre-check material.HasProperty(k_HazyGlossMaxDielectricF0),
// it is considered mandatory.
// The use of the option is nevertheless disabled, so we need to make sure the value (again that is used anyway in StackLitData)
// will be set to its neutral input:
material.SetFloat(k_HazyGlossMaxDielectricF0, 1.0f);
}
else
{
// In that case, the UI is supposed to have a valid UI value, forward it to the shader-used value:
UIBufferedProperty.SetupUIBufferedMaterialProperty(material, k_HazyGlossMaxDielectricF0, MaterialProperty.PropType.Float);
}
}
bool anisotropyEnabled = material.HasProperty(k_EnableAnisotropy) && material.GetFloat(k_EnableAnisotropy) > 0.0f;
CoreUtils.SetKeyword(material, "_MATERIAL_FEATURE_ANISOTROPY", anisotropyEnabled);

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


[SurfaceDataAttributes("Haze Extent")]
public float hazeExtent;
[SurfaceDataAttributes("Cap Haziness To Agree With Metallic")]
public bool capHazinessWrtMetallic;
[SurfaceDataAttributes("Hazy Gloss Max Dielectric f0 Value To Agree With Metallic")]
public float hazyGlossMaxDielectricF0;
// Anisotropy
[SurfaceDataAttributes("Tangent", true)]

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


#define DEBUGVIEW_STACKLIT_SURFACEDATA_LOBE_MIXING (1116)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_HAZINESS (1117)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_HAZE_EXTENT (1118)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_CAP_HAZINESS_TO_AGREE_WITH_METALLIC (1119)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_HAZY_GLOSS_MAX_DIELECTRIC_F0_VALUE_TO_AGREE_WITH_METALLIC (1119)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_TANGENT (1120)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_ANISOTROPY (1121)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_IRIDESCENCE_IOR (1122)

float lobeMix;
float haziness;
float hazeExtent;
bool capHazinessWrtMetallic;
float hazyGlossMaxDielectricF0;
float3 tangentWS;
float anisotropy;
float iridescenceIor;

case DEBUGVIEW_STACKLIT_SURFACEDATA_HAZE_EXTENT:
result = surfacedata.hazeExtent.xxx;
break;
case DEBUGVIEW_STACKLIT_SURFACEDATA_CAP_HAZINESS_TO_AGREE_WITH_METALLIC:
result = (surfacedata.capHazinessWrtMetallic) ? float3(1.0, 1.0, 1.0) : float3(0.0, 0.0, 0.0);
case DEBUGVIEW_STACKLIT_SURFACEDATA_HAZY_GLOSS_MAX_DIELECTRIC_F0_VALUE_TO_AGREE_WITH_METALLIC:
result = surfacedata.hazyGlossMaxDielectricF0.xxx;
break;
case DEBUGVIEW_STACKLIT_SURFACEDATA_TANGENT:
result = surfacedata.tangentWS * 0.5 + 0.5;

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


// bsdfData.roughnessBT
// bsdfData.roughnessBB
//
// TODOTODO: capHazinessWrtMetallic and secondary anisotropy
// TODOTODO: hazyGlossMaxf0 and secondary anisotropy
void HazeMapping(float3 fresnel0, float roughnessAT, float roughnessAB, float haziness, float hazeExtent, float hazeExtentAnisotropy /* TODOTODO */, inout BSDFData bsdfData)
void HazeMapping(float3 fresnel0, float roughnessAT, float roughnessAB, float haziness, float hazeExtent, float hazeExtentAnisotropy /* TODOTODO */, float3 hazyGlossMaxf0, inout BSDFData bsdfData)
float2 alpha_n = float2(roughnessAT, roughnessAB);
// We can use clamping of roughnessA here to avoid a "p == 0/0" case if roughnessA == 0.
// Also note that if hazeExtent == 0, p will == 1, which will end up posing lobeMix = haziness.
// Thus, we could also test (alpha_w_xy <= FLT_EPS) below (it will be such if hazeExtent == 0 or rouhnessA == 0)
// to directly return lobeMix = haziness.
//
// But since hazeExtent is variable, this doesn't yield the same limit behaviour for a general hazeExtent though:
// Clamping roughness will allow p to approach a non unit (p != 1) value as input roughness goes to 0 and
// hazeExtent is non null, while using (alpha_w_xy <= FLT_EPS) makes us use the limit of p = 1 as soon as
// alpha_w_xy is small enough.
// The general limit of p = alpha_n/[alpha_n(1+lambda_h)] is 1/(1+lambda_h) for all paths where alpha_n > 0.
// So both methods are arbitrary since whatever clamp value we use as eps in max(roughness, eps) for clamping
// will determine at what value of "hazeExtent" there's a rapid change (high sensitivity) of p when roughness is
// close to 0. (With the (alpha_w_xy <= FLT_EPS), there is also such a point).
// We choose to streamline with just clamp, and arbitrarily with the value used when clamping for analytical lights.
//float2 alpha_n = float2(roughnessAT, roughnessAB);
float2 alpha_n = float2(ClampRoughnessForAnalyticalLights(roughnessAT), ClampRoughnessForAnalyticalLights(roughnessAB));
float2 lambda_h; // hazeExtent anisotropic
float2 lambda_h; // TODOTODO: hazeExtent anisotropic
float alpha_w_xy = alpha_w.x * alpha_w.y;
float p = alpha_n_xy/(alpha_w.x * alpha_w.y); // peak ratio formula at theta_d = 0 (ie p is in the paper := P(0))
float p = alpha_n_xy/alpha_w_xy; // peak ratio formula at theta_d = 0 (ie p is in the paper := P(0))
float r_c_max = Max3(r_c.r, r_c.g, r_c.b);
float k_h_max = 0.0;

bsdfData.lobeMix = 0.0;
}
//else if (alpha_w_xy <= FLT_EPS) { bsdfData.lobeMix = beta_h; }
else
{
if (useBezierToMapKh)

float3 chromaVec = r_c/r_c_max;
bsdfData.fresnel0 = r_max*chromaVec;
bsdfData.fresnel0 = min(bsdfData.fresnel0, hazyGlossMaxf0);
float anisotropyB; // TODOTODO
// For IBL, convert back to the scalar roughness + anisotropy parametrization for the
// secondary lobe:
float anisotropyB;
float roughnessB;
ConvertRoughnessToAnisotropy(alpha_w.x, alpha_w.y, anisotropyB);
ConvertRoughnessTAndAnisotropyToRoughness(alpha_w.x, anisotropyB, roughnessB);

//
if (HasFlag(surfaceData.materialFeatures, MATERIALFEATUREFLAGS_STACK_LIT_HAZY_GLOSS))
{
HazeMapping(bsdfData.fresnel0, bsdfData.roughnessAT, bsdfData.roughnessAB, surfaceData.haziness, surfaceData.hazeExtent, bsdfData.anisotropy /* TODOTODO */, bsdfData);
float3 hazyGlossMaxf0 = ComputeFresnel0(float3(1.0, 1.0, 1.0), surfaceData.metallic, surfaceData.hazyGlossMaxDielectricF0);
HazeMapping(bsdfData.fresnel0, bsdfData.roughnessAT, bsdfData.roughnessAB, surfaceData.haziness, surfaceData.hazeExtent, bsdfData.anisotropy /* TODOTODO */, hazyGlossMaxf0, bsdfData);
}
if (HasFlag(surfaceData.materialFeatures, MATERIALFEATUREFLAGS_STACK_LIT_IRIDESCENCE))

2
com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.shader


[HideInInspector] _HazinessMapRange("Haziness Range", Vector) = (0, 1, 0, 0)
[ToggleUI] _CapHazinessWrtMetallic("Cap Haziness Wrt Metallic", Float) = 0.0
_HazyGlossMaxDielectricF0UIBuffer("Hazy Gloss Max Dielectric F0 When Using Metallic Parametrization", Range(0.0, 1.0)) = 1.0
[HideInInspector] _HazyGlossMaxDielectricF0("Hazy Gloss Max Dielectric F0 When Using Metallic Parametrization", Range(0.0, 1.0)) = 1.0
[HideInInspector] _HazeExtentMapShow("HazeExtent Map Show", Float) = 0
_HazeExtentMapRangeScale("HazeExtent Range Scale", Float) = 8.0

11
com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLitData.hlsl


surfaceData.perceptualSmoothnessB = 1.0;
surfaceData.haziness = 0.0;
surfaceData.hazeExtent = 0.0;
surfaceData.capHazinessWrtMetallic = false;
surfaceData.hazyGlossMaxDielectricF0 = 1.0;
#ifdef _MATERIAL_FEATURE_DUAL_SPECULAR_LOBE
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_STACK_LIT_DUAL_SPECULAR_LOBE;

surfaceData.hazeExtent = lerp(_HazeExtent, surfaceData.hazeExtent, _HazeExtentUseMap);
surfaceData.hazeExtent *= _HazeExtentMapRangeScale;
#ifndef _MATERIAL_FEATURE_SPECULAR_COLOR
// base parametrization is baseColor + metallic, check option regarding how high can hazeExtent go:
surfaceData.capHazinessWrtMetallic = (_CapHazinessWrtMetallic == 1.0);
// base parametrization is baseColor + metallic, use value / option regarding how high can hazeExtent and f0 go:
// If metallic parametrization is actually used, set the cap to be enforced later by the hazy gloss mapping,
// it will be adjusted according to the metallic value such that
// hazyGlossMaxf0 = ComputeFresnel0(1.0, surfaceData.metallic, surfaceData.hazyGlossMaxDielectricF0);
surfaceData.hazyGlossMaxDielectricF0 = _HazyGlossMaxDielectricF0;
#else
surfaceData.hazyGlossMaxDielectricF0 = 1.0;
#endif
#else // else not def _MATERIAL_FEATURE_HAZY_GLOSS

2
com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLitProperties.hlsl


float4 _HazinessMapChannelMask;
float4 _HazinessMapRange;
float _CapHazinessWrtMetallic;
float _HazyGlossMaxDielectricF0;
float _HazeExtent;
float _HazeExtentUseMap;

正在加载...
取消
保存