浏览代码

Add secondary lobe independent anisotropy control (also used for hazeExtent in the hazyGloss parametrization of dual specular lobes)

/StackLit2
Stephane Laroche 6 年前
当前提交
8e152582
共有 7 个文件被更改,包括 148 次插入90 次删除
  1. 36
      com.unity.render-pipelines.high-definition/HDRP/Editor/Material/StackLit/StackLitUI.cs
  2. 13
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.cs
  3. 76
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.cs.hlsl
  4. 38
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.hlsl
  5. 31
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.shader
  6. 9
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLitData.hlsl
  7. 35
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLitProperties.hlsl

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


// Anisotropy
protected const string k_EnableAnisotropy = "_EnableAnisotropy";
protected const string k_Anisotropy = "_Anisotropy";
protected const string k_AnisotropyMap = "_AnisotropyMap";
protected const string k_AnisotropyMapUV = "_AnisotropyMapUV";
protected const string k_AnisotropyA = "_AnisotropyA";
protected const string k_AnisotropyAMap = "_AnisotropyAMap";
protected const string k_AnisotropyAMapUV = "_AnisotropyAMapUV";
protected const string k_AnisotropyB = "_AnisotropyB";
protected const string k_AnisotropyBMap = "_AnisotropyBMap";
protected const string k_AnisotropyBMapUV = "_AnisotropyBMapUV";
// Iridescence
protected const string k_EnableIridescence = "_EnableIridescence";

var Metallic = new TextureProperty(this, k_MetallicMap, k_Metallic, "Metallic", "Metallic", false, false);
var DielectricIor = new Property(this, k_DielectricIor, "DieletricIor", "IOR use for dielectric material (i.e non metallic material)", false);
var SmoothnessA = new TextureProperty(this, k_SmoothnessAMap, k_SmoothnessA, "Smoothness", "Smoothness", false, false);
var AnisotropyA = new Property(this, k_AnisotropyA, "AnisotropyA", "Anisotropy of primary lobe of base layer", false, _ => EnableAnisotropy.BoolValue == true);
// TODO: Tangent map and rotation
var NormalMap = new TextureProperty(this, k_NormalMap, k_NormalScale, "Normal Map", "Normal Map", pairConstantWithTexture: true, isMandatory: false, isNormalMap: true, showScaleOffset: true, slaveTexOneLineProp: BentNormal.m_TextureProperty);
var AmbientOcclusion = new TextureProperty(this, k_AmbientOcclusionMap, k_AmbientOcclusion, "AmbientOcclusion", "AmbientOcclusion Map", false, false);
var SpecularColor = new TextureProperty(this, k_SpecularColorMap, k_SpecularColor, "Specular Color (f0)", "Specular Color (f0) (RGB)", true, false);

Metallic,
DielectricIor,
SmoothnessA,
AnisotropyA,
NormalMap,
BentNormal,
AmbientOcclusion,

SpecularColor,
EnergyConservingSpecularColor,
SmoothnessA,
AnisotropyA,
NormalMap,
BentNormal,
AmbientOcclusion,

DualSpecularLobeParametrization = new ComboProperty(this, k_DualSpecularLobeParametrization, "Dual Specular Lobe Parametrization", Enum.GetNames(typeof(StackLit.DualSpecularLobeParametrization)), false);
var SmoothnessB = new TextureProperty(this, k_SmoothnessBMap, k_SmoothnessB, "Smoothness B", "Smoothness B", false, false);
var AnisotropyB = new Property(this, k_AnisotropyB, "AnisotropyB", "Anisotropy of secondary lobe of base layer", false, _ => EnableAnisotropy.BoolValue == true);
//var LobeMix = new Property(this, k_LobeMix, "Lobe Mix", "Lobe Mix", false);
var LobeMix = new TextureProperty(this, k_LobeMixMap, k_LobeMix, "LobeMix", "LobeMix", false, false);
var Haziness = new TextureProperty(this, k_HazinessMap, k_Haziness, "Haziness", "Haziness", false, false);

{
DualSpecularLobeParametrization,
SmoothnessB,
AnisotropyB,
LobeMix,
}, _ => ( EnableDualSpecularLobe.BoolValue == true && !IsHazyGlossParametrizationUsed) );

CapHazinessWrtMetallic,
HazyGlossMaxDielectricF0UI,
HazeExtent,
AnisotropyB,
}, _ => (EnableDualSpecularLobe.BoolValue == true && IsHazyGlossParametrizationUsed) );
// All material properties

DualSpecularLobeDirectGroup,
DualSpecularLobeHazyGlossGroup,
new GroupProperty(this, "_Anisotropy", "Anisotropy", new BaseProperty[]
{
new Property(this, k_Anisotropy, "Anisotropy", "Anisotropy of base layer", false),
// TODO: Tangent map and rotation
}, _ => EnableAnisotropy.BoolValue == true),
//new GroupProperty(this, "_Anisotropy", "Anisotropy", new BaseProperty[]
//{
// new Property(this, k_AnisotropyA, "AnisotropyA", "Anisotropy of base layer", false),
// // TODO: Tangent map and rotation
//}, _ => EnableAnisotropy.BoolValue == true),
new GroupProperty(this, "_Coat", "Coat", new BaseProperty[]
{

TextureProperty.SetupTextureMaterialProperty(material, k_AmbientOcclusion);
TextureProperty.SetupTextureMaterialProperty(material, k_SubsurfaceMask);
TextureProperty.SetupTextureMaterialProperty(material, k_Thickness);
TextureProperty.SetupTextureMaterialProperty(material, k_Anisotropy);
TextureProperty.SetupTextureMaterialProperty(material, k_AnisotropyA);
TextureProperty.SetupTextureMaterialProperty(material, k_AnisotropyB);
TextureProperty.SetupTextureMaterialProperty(material, k_IridescenceThickness);
TextureProperty.SetupTextureMaterialProperty(material, k_IridescenceMask);
TextureProperty.SetupTextureMaterialProperty(material, k_CoatSmoothness);

TextureProperty.UVMapping hazeExtentMapUV = (dualSpecularLobeEnabled && hazyGlossEnabled) ? (TextureProperty.UVMapping)material.GetFloat(k_HazeExtentMapUV) : TextureProperty.UVMapping.UV0;
TextureProperty.UVMapping subsurfaceMaskMapUV = sssEnabled ? (TextureProperty.UVMapping)material.GetFloat(k_SubsurfaceMaskMapUV) : TextureProperty.UVMapping.UV0;
TextureProperty.UVMapping thicknessMapUV = sssEnabled || transmissionEnabled ? (TextureProperty.UVMapping)material.GetFloat(k_ThicknessMapUV) : TextureProperty.UVMapping.UV0;
TextureProperty.UVMapping anisotropyMapUV = anisotropyEnabled ? (TextureProperty.UVMapping)material.GetFloat(k_AnisotropyMapUV) : TextureProperty.UVMapping.UV0;
TextureProperty.UVMapping anisotropyAMapUV = anisotropyEnabled ? (TextureProperty.UVMapping)material.GetFloat(k_AnisotropyAMapUV) : TextureProperty.UVMapping.UV0;
TextureProperty.UVMapping anisotropyBMapUV = anisotropyEnabled ? (TextureProperty.UVMapping)material.GetFloat(k_AnisotropyBMapUV) : TextureProperty.UVMapping.UV0;
TextureProperty.UVMapping iridescenceThicknessMapUV = iridescenceEnabled ? (TextureProperty.UVMapping)material.GetFloat(k_IridescenceThicknessMapUV) : TextureProperty.UVMapping.UV0;
TextureProperty.UVMapping iridescenceMaskMapUV = iridescenceEnabled ? (TextureProperty.UVMapping)material.GetFloat(k_IridescenceMaskMapUV) : TextureProperty.UVMapping.UV0;
TextureProperty.UVMapping coatSmoothnessMapUV = coatEnabled ? (TextureProperty.UVMapping)material.GetFloat(k_CoatSmoothnessMapUV) : TextureProperty.UVMapping.UV0;

hazeExtentMapUV,
subsurfaceMaskMapUV,
thicknessMapUV,
anisotropyMapUV,
anisotropyAMapUV,
anisotropyBMapUV,
iridescenceThicknessMapUV,
iridescenceMaskMapUV,
coatSmoothnessMapUV,

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


[SurfaceDataAttributes("Haze Extent")]
public float hazeExtent;
[SurfaceDataAttributes("Hazy Gloss Max Dielectric f0 Value To Agree With Metallic")]
[SurfaceDataAttributes("Hazy Gloss Max Dielectric f0 When Using Metallic Input")]
public float hazyGlossMaxDielectricF0;
// Anisotropy

[SurfaceDataAttributes("Anisotropy")]
public float anisotropy; // anisotropic ratio(0->no isotropic; 1->full anisotropy in tangent direction, -1->full anisotropy in bitangent direction)
[SurfaceDataAttributes("AnisotropyA")]
public float anisotropyA; // anisotropic ratio(0->no isotropic; 1->full anisotropy in tangent direction, -1->full anisotropy in bitangent direction)
// Anisotropy for secondary specular lobe
[SurfaceDataAttributes("AnisotropyB")]
public float anisotropyB; // anisotropic ratio(0->no isotropic; 1->full anisotropy in tangent direction, -1->full anisotropy in bitangent direction)
// Iridescence
[SurfaceDataAttributes("IridescenceIor")]

public float roughnessAB;
public float roughnessBT;
public float roughnessBB;
public float anisotropy;
public float anisotropyA;
public float anisotropyB;
// Top interface and media (clearcoat)
public float coatRoughness;

76
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_HAZY_GLOSS_MAX_DIELECTRIC_F0_VALUE_TO_AGREE_WITH_METALLIC (1119)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_HAZY_GLOSS_MAX_DIELECTRIC_F0_WHEN_USING_METALLIC_INPUT (1119)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_ANISOTROPY (1121)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_IRIDESCENCE_IOR (1122)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_IRIDESCENCE_THICKNESS (1123)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_IRIDESCENCE_MASK (1124)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_COAT_SMOOTHNESS (1125)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_COAT_IOR (1126)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_COAT_THICKNESS (1127)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_COAT_EXTINCTION_COEFFICIENT (1128)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_DIFFUSION_PROFILE (1129)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_SUBSURFACE_MASK (1130)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_THICKNESS (1131)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_ANISOTROPY_A (1121)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_ANISOTROPY_B (1122)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_IRIDESCENCE_IOR (1123)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_IRIDESCENCE_THICKNESS (1124)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_IRIDESCENCE_MASK (1125)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_COAT_SMOOTHNESS (1126)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_COAT_IOR (1127)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_COAT_THICKNESS (1128)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_COAT_EXTINCTION_COEFFICIENT (1129)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_DIFFUSION_PROFILE (1130)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_SUBSURFACE_MASK (1131)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_THICKNESS (1132)
//
// UnityEngine.Experimental.Rendering.HDPipeline.StackLit+BSDFData: static fields

#define DEBUGVIEW_STACKLIT_BSDFDATA_ROUGHNESS_AB (1168)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ROUGHNESS_BT (1169)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ROUGHNESS_BB (1170)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ANISOTROPY (1171)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_ROUGHNESS (1172)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_PERCEPTUAL_ROUGHNESS (1173)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_IOR (1174)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_THICKNESS (1175)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_EXTINCTION (1176)
#define DEBUGVIEW_STACKLIT_BSDFDATA_IRIDESCENCE_IOR (1177)
#define DEBUGVIEW_STACKLIT_BSDFDATA_IRIDESCENCE_THICKNESS (1178)
#define DEBUGVIEW_STACKLIT_BSDFDATA_IRIDESCENCE_MASK (1179)
#define DEBUGVIEW_STACKLIT_BSDFDATA_DIFFUSION_PROFILE (1180)
#define DEBUGVIEW_STACKLIT_BSDFDATA_SUBSURFACE_MASK (1181)
#define DEBUGVIEW_STACKLIT_BSDFDATA_THICKNESS (1182)
#define DEBUGVIEW_STACKLIT_BSDFDATA_USE_THICK_OBJECT_MODE (1183)
#define DEBUGVIEW_STACKLIT_BSDFDATA_TRANSMITTANCE (1184)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ANISOTROPY_A (1171)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ANISOTROPY_B (1172)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_ROUGHNESS (1173)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_PERCEPTUAL_ROUGHNESS (1174)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_IOR (1175)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_THICKNESS (1176)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_EXTINCTION (1177)
#define DEBUGVIEW_STACKLIT_BSDFDATA_IRIDESCENCE_IOR (1178)
#define DEBUGVIEW_STACKLIT_BSDFDATA_IRIDESCENCE_THICKNESS (1179)
#define DEBUGVIEW_STACKLIT_BSDFDATA_IRIDESCENCE_MASK (1180)
#define DEBUGVIEW_STACKLIT_BSDFDATA_DIFFUSION_PROFILE (1181)
#define DEBUGVIEW_STACKLIT_BSDFDATA_SUBSURFACE_MASK (1182)
#define DEBUGVIEW_STACKLIT_BSDFDATA_THICKNESS (1183)
#define DEBUGVIEW_STACKLIT_BSDFDATA_USE_THICK_OBJECT_MODE (1184)
#define DEBUGVIEW_STACKLIT_BSDFDATA_TRANSMITTANCE (1185)
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.StackLit+SurfaceData
// PackingRules = Exact

float hazeExtent;
float hazyGlossMaxDielectricF0;
float3 tangentWS;
float anisotropy;
float anisotropyA;
float anisotropyB;
float iridescenceIor;
float iridescenceThickness;
float iridescenceMask;

float roughnessAB;
float roughnessBT;
float roughnessBB;
float anisotropy;
float anisotropyA;
float anisotropyB;
float coatRoughness;
float coatPerceptualRoughness;
float coatIor;

case DEBUGVIEW_STACKLIT_SURFACEDATA_HAZE_EXTENT:
result = surfacedata.hazeExtent.xxx;
break;
case DEBUGVIEW_STACKLIT_SURFACEDATA_HAZY_GLOSS_MAX_DIELECTRIC_F0_VALUE_TO_AGREE_WITH_METALLIC:
case DEBUGVIEW_STACKLIT_SURFACEDATA_HAZY_GLOSS_MAX_DIELECTRIC_F0_WHEN_USING_METALLIC_INPUT:
case DEBUGVIEW_STACKLIT_SURFACEDATA_ANISOTROPY:
result = surfacedata.anisotropy.xxx;
case DEBUGVIEW_STACKLIT_SURFACEDATA_ANISOTROPY_A:
result = surfacedata.anisotropyA.xxx;
break;
case DEBUGVIEW_STACKLIT_SURFACEDATA_ANISOTROPY_B:
result = surfacedata.anisotropyB.xxx;
break;
case DEBUGVIEW_STACKLIT_SURFACEDATA_IRIDESCENCE_IOR:
result = surfacedata.iridescenceIor.xxx;

case DEBUGVIEW_STACKLIT_BSDFDATA_ROUGHNESS_BB:
result = bsdfdata.roughnessBB.xxx;
break;
case DEBUGVIEW_STACKLIT_BSDFDATA_ANISOTROPY:
result = bsdfdata.anisotropy.xxx;
case DEBUGVIEW_STACKLIT_BSDFDATA_ANISOTROPY_A:
result = bsdfdata.anisotropyA.xxx;
break;
case DEBUGVIEW_STACKLIT_BSDFDATA_ANISOTROPY_B:
result = bsdfdata.anisotropyB.xxx;
break;
case DEBUGVIEW_STACKLIT_BSDFDATA_COAT_ROUGHNESS:
result = bsdfdata.coatRoughness.xxx;

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


}
// Assume bsdfData.normalWS is init
void FillMaterialAnisotropy(float anisotropy, float3 tangentWS, float3 bitangentWS, inout BSDFData bsdfData)
void FillMaterialAnisotropy(float anisotropyA, float anisotropyB, float3 tangentWS, float3 bitangentWS, inout BSDFData bsdfData)
bsdfData.anisotropy = anisotropy;
bsdfData.anisotropyA = anisotropyA;
bsdfData.anisotropyB = anisotropyB;
bsdfData.tangentWS = tangentWS;
bsdfData.bitangentWS = bitangentWS;
}

// bsdfData.roughnessBT
// bsdfData.roughnessBB
//
// TODOTODO: hazyGlossMaxf0 and secondary anisotropy
void HazeMapping(float3 fresnel0, float roughnessAT, float roughnessAB, float haziness, float hazeExtent, float hazeExtentAnisotropy /* TODOTODO */, float3 hazyGlossMaxf0, inout BSDFData bsdfData)
void HazeMapping(float3 fresnel0, float roughnessAT, float roughnessAB, float haziness, float hazeExtent, float hazeExtentAnisotropy, float3 hazyGlossMaxf0, inout BSDFData bsdfData)
{
float w = 10.0; // interpolation steepness weight (Bezier weight of central point)
bool useBezierToMapKh = true;

float2 alpha_n = float2(ClampRoughnessForAnalyticalLights(roughnessAT), ClampRoughnessForAnalyticalLights(roughnessAB));
float alpha_n_xy = alpha_n.x * alpha_n.y;
float beta_h = haziness;
float2 lambda_h; // TODOTODO: hazeExtent anisotropic
//ConvertValueAnisotropyToValueTB(hazeExtent, hazeExtentAnisotropy, lambda_h.x, lambda_h.y);
ConvertValueAnisotropyToValueTB(hazeExtent, 0.0, lambda_h.x, lambda_h.y);
float2 lambda_h;
ConvertValueAnisotropyToValueTB(hazeExtent, hazeExtentAnisotropy, lambda_h.x, lambda_h.y);
//ConvertValueAnisotropyToValueTB(hazeExtent, 0.0, lambda_h.x, lambda_h.y);
float2 alpha_w = saturate(alpha_n + lambda_h * sqrt(alpha_n_xy)); // wide lobe (haze) roughness
float alpha_w_xy = alpha_w.x * alpha_w.y;

if (HasFlag(surfaceData.materialFeatures, MATERIALFEATUREFLAGS_STACK_LIT_ANISOTROPY))
{
FillMaterialAnisotropy(surfaceData.anisotropy, surfaceData.tangentWS, cross(surfaceData.normalWS, surfaceData.tangentWS), bsdfData);
FillMaterialAnisotropy(surfaceData.anisotropyA, surfaceData.anisotropyB, surfaceData.tangentWS, cross(surfaceData.normalWS, surfaceData.tangentWS), bsdfData);
ConvertAnisotropyToRoughness(bsdfData.perceptualRoughnessA, bsdfData.anisotropy, bsdfData.roughnessAT, bsdfData.roughnessAB);
ConvertAnisotropyToRoughness(bsdfData.perceptualRoughnessB, bsdfData.anisotropy, bsdfData.roughnessBT, bsdfData.roughnessBB);
ConvertAnisotropyToRoughness(bsdfData.perceptualRoughnessA, bsdfData.anisotropyA, bsdfData.roughnessAT, bsdfData.roughnessAB);
ConvertAnisotropyToRoughness(bsdfData.perceptualRoughnessB, bsdfData.anisotropyB, bsdfData.roughnessBT, bsdfData.roughnessBB);
bsdfData.lobeMix = surfaceData.lobeMix;
// Note that if we're using the hazy gloss parametrization, these will all be changed again:

if (HasFlag(surfaceData.materialFeatures, MATERIALFEATUREFLAGS_STACK_LIT_HAZY_GLOSS))
{
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);
HazeMapping(bsdfData.fresnel0, bsdfData.roughnessAT, bsdfData.roughnessAB, surfaceData.haziness, surfaceData.hazeExtent, bsdfData.anisotropyB, hazyGlossMaxf0, bsdfData);
}
if (HasFlag(surfaceData.materialFeatures, MATERIALFEATUREFLAGS_STACK_LIT_IRIDESCENCE))

// analytical lights.
// --------------------------------------------------------------------------------
preLightData.iblAnisotropy[0] = bsdfData.anisotropy;
preLightData.iblAnisotropy[1] = bsdfData.anisotropy;
preLightData.iblAnisotropy[0] = bsdfData.anisotropyA;
preLightData.iblAnisotropy[1] = bsdfData.anisotropyB;
s_r12 = RoughnessToLinearVariance(PerceptualRoughnessToRoughness(bsdfData.perceptualRoughnessA));

// that destretching happens.
IF_DEBUG( if( _DebugAniso.x == 1) )
{
preLightData.iblAnisotropy[0] = GetModifiedAnisotropy(bsdfData.anisotropy, bsdfData.perceptualRoughnessA,
preLightData.iblAnisotropy[0] = GetModifiedAnisotropy(bsdfData.anisotropyA, bsdfData.perceptualRoughnessA,
preLightData.iblAnisotropy[1] = GetModifiedAnisotropy(bsdfData.anisotropy, bsdfData.perceptualRoughnessB,
preLightData.iblAnisotropy[1] = GetModifiedAnisotropy(bsdfData.anisotropyB, bsdfData.perceptualRoughnessB,
PerceptualRoughnessToRoughness(bsdfData.perceptualRoughnessB),
preLightData.iblPerceptualRoughness[BASE_LOBEB_IDX]);
}

// TODOANISOTROPY
ConvertRoughnessToAnisotropy(roughnessT, roughnessB, preLightData.iblAnisotropy[0]);
#else
preLightData.iblAnisotropy[0] = bsdfData.anisotropy;
preLightData.iblAnisotropy[0] = bsdfData.anisotropyA;
#endif
preLightData.iblPerceptualRoughness[BASE_LOBEA_IDX] = RoughnessToPerceptualRoughness((roughnessT + roughnessB)/2.0);

// TODOANISOTROPY
ConvertRoughnessToAnisotropy(roughnessT, roughnessB, preLightData.iblAnisotropy[1]);
#else
preLightData.iblAnisotropy[1] = bsdfData.anisotropy;
preLightData.iblAnisotropy[1] = bsdfData.anisotropyB;
#endif
preLightData.iblPerceptualRoughness[BASE_LOBEB_IDX] = RoughnessToPerceptualRoughness((roughnessT + roughnessB)/2.0);

// Also important: iblPerceptualRoughness[] is used for specular occlusion
preLightData.iblPerceptualRoughness[BASE_LOBEA_IDX] = bsdfData.perceptualRoughnessA;
preLightData.iblPerceptualRoughness[BASE_LOBEB_IDX] = bsdfData.perceptualRoughnessB;
preLightData.iblAnisotropy[0] = bsdfData.anisotropy;
preLightData.iblAnisotropy[1] = bsdfData.anisotropy;
preLightData.iblAnisotropy[0] = bsdfData.anisotropyA;
preLightData.iblAnisotropy[1] = bsdfData.anisotropyB;
float3 f0forCalculatingFGD = bsdfData.fresnel0;
if (HasFlag(bsdfData.materialFeatures, MATERIALFEATUREFLAGS_STACK_LIT_IRIDESCENCE))

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


// TODO: TangentMap, AnisotropyMap and CoatIorMap (SmoothnessMap ?)
[ToggleUI] _EnableAnisotropy("Enable Anisotropy", Float) = 0.0 // UI only
_Anisotropy("Anisotropy", Range(-1.0, 1.0)) = 0.0
_AnisotropyMap("Anisotropy Map", 2D) = "white" {}
_AnisotropyUseMap("Anisotropy Use Map", Float) = 0
_AnisotropyMapUV("Anisotropy Map UV", Float) = 0.0
_AnisotropyMapUVLocal("Anisotropy Map UV Local", Float) = 0.0
_AnisotropyMapChannel("Anisotropy Map Channel", Float) = 0.0
[HideInInspector] _AnisotropyMapChannelMask("Anisotropy Map Channel Mask", Vector) = (1, 0, 0, 0)
_AnisotropyMapRemap("Anisotropy Remap", Vector) = (0, 1, 0, 0)
[HideInInspector] _AnisotropyMapRange("Anisotropy Range", Vector) = (0, 1, 0, 0)
[HideInInspector] _AnisotropyAMapShow("AnisotropyA Map Show", Float) = 0
_AnisotropyA("AnisotropyA", Range(-1.0, 1.0)) = 0.0
_AnisotropyAMap("AnisotropyA Map", 2D) = "white" {}
_AnisotropyAUseMap("AnisotropyA Use Map", Float) = 0
_AnisotropyAMapUV("AnisotropyA Map UV", Float) = 0.0
_AnisotropyAMapUVLocal("AnisotropyA Map UV Local", Float) = 0.0
_AnisotropyAMapChannel("AnisotropyA Map Channel", Float) = 0.0
[HideInInspector] _AnisotropyAMapChannelMask("AnisotropyA Map Channel Mask", Vector) = (1, 0, 0, 0)
_AnisotropyAMapRemap("AnisotropyA Remap", Vector) = (0, 1, 0, 0)
[HideInInspector] _AnisotropyAMapRange("AnisotropyA Range", Vector) = (0, 1, 0, 0)
[HideInInspector] _AnisotropyBMapShow("AnisotropyB Map Show", Float) = 0
_AnisotropyB("AnisotropyB", Range(-1.0, 1.0)) = 0.0
_AnisotropyBMap("AnisotropyB Map", 2D) = "white" {}
_AnisotropyBUseMap("AnisotropyB Use Map", Float) = 0
_AnisotropyBMapUV("AnisotropyB Map UV", Float) = 0.0
_AnisotropyBMapUVLocal("AnisotropyB Map UV Local", Float) = 0.0
_AnisotropyBMapChannel("AnisotropyB Map Channel", Float) = 0.0
[HideInInspector] _AnisotropyBMapChannelMask("AnisotropyB Map Channel Mask", Vector) = (1, 0, 0, 0)
_AnisotropyBMapRemap("AnisotropyB Remap", Vector) = (0, 1, 0, 0)
[HideInInspector] _AnisotropyBMapRange("AnisotropyB Range", Vector) = (0, 1, 0, 0)
[ToggleUI] _EnableCoat("Enable Coat", Float) = 0.0 // UI only
[HideInInspector] _CoatSmoothnessMapShow("CoatSmoothness Show", Float) = 0

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


#endif // _MATERIAL_FEATURE_DUAL_SPECULAR_LOBE
surfaceData.anisotropyA = 0.0;
surfaceData.anisotropyB = 0.0;
surfaceData.anisotropy = _Anisotropy; // In all cases we must multiply anisotropy with the map
#else
surfaceData.anisotropy = 0.0;
surfaceData.anisotropyA = _AnisotropyA; // In all cases we must multiply anisotropy with the map
#ifdef _MATERIAL_FEATURE_DUAL_SPECULAR_LOBE
surfaceData.anisotropyB = _AnisotropyB;
#endif // _MATERIAL_FEATURE_ANISOTROPY
surfaceData.tangentWS = normalize(input.worldToTangent[0].xyz); // The tangent is not normalize in worldToTangent for mikkt. TODO: Check if it expected that we normalize with Morten. Tag: SURFACE_GRADIENT
float4 coatGradient = float4(0.0, 0.0, 0.0, 1.0f);

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


TEXTURE2D(_HazeExtentMap);
SAMPLER(sampler_HazeExtentMap);
TEXTURE2D(_AnisotropyMap);
SAMPLER(sampler_AnisotropyMap);
TEXTURE2D(_AnisotropyAMap);
SAMPLER(sampler_AnisotropyAMap);
TEXTURE2D(_AnisotropyBMap);
SAMPLER(sampler_AnisotropyBMap);
TEXTURE2D(_CoatSmoothnessMap);
SAMPLER(sampler_CoatSmoothnessMap);

float4 _HazeExtentMapRange;
float _HazeExtentMapRangeScale;
float _Anisotropy;
float _AnisotropyUseMap;
float _AnisotropyMapUV;
float _AnisotropyMapUVLocal;
float4 _AnisotropyMap_ST;
float4 _AnisotropyMap_TexelSize;
float4 _AnisotropyMap_MipInfo;
float4 _AnisotropyMapChannelMask;
float4 _AnisotropyMapRange;
float _AnisotropyA;
float _AnisotropyAUseMap;
float _AnisotropyAMapUV;
float _AnisotropyAMapUVLocal;
float4 _AnisotropyAMap_ST;
float4 _AnisotropyAMap_TexelSize;
float4 _AnisotropyAMap_MipInfo;
float4 _AnisotropyAMapChannelMask;
float4 _AnisotropyAMapRange;
float _AnisotropyB;
float _AnisotropyBUseMap;
float _AnisotropyBMapUV;
float _AnisotropyBMapUVLocal;
float4 _AnisotropyBMap_ST;
float4 _AnisotropyBMap_TexelSize;
float4 _AnisotropyBMap_MipInfo;
float4 _AnisotropyBMapChannelMask;
float4 _AnisotropyBMapRange;
float _CoatSmoothness;
float _CoatSmoothnessUseMap;

正在加载...
取消
保存