浏览代码

Implement vertically layered BSDF model with anisotropy.

/main
Stephane Laroche 6 年前
当前提交
e5b6c4fb
共有 11 个文件被更改,包括 1180 次插入82 次删除
  1. 18
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/BSDF.hlsl
  2. 7
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/CommonMaterial.hlsl
  3. 55
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/StackLit/StackLitUI.cs
  4. 10
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VolumetricLighting.cs.hlsl
  5. 17
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl
  6. 44
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLit.cs
  7. 81
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLit.cs.hlsl
  8. 970
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLit.hlsl
  9. 15
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLit.shader
  10. 39
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLitData.hlsl
  11. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLitProperties.hlsl

18
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/BSDF.hlsl


// Conversion FO/IOR
//-----------------------------------------------------------------------------
TEMPLATE_2_REAL(IorToFresnel0, transmittedIor, incidentIor, return Sq((transmittedIor - incidentIor) / (transmittedIor + incidentIor)) )
real IorToFresnel0(real transmittedIor, real incidentIor = 1.0)
real IorToFresnel0(real transmittedIor)
return Sq((transmittedIor - incidentIor) / (transmittedIor + incidentIor));
return IorToFresnel0(transmittedIor, 1.0);
// Note: Don't handle the case fresnel0 == 1
real Fresnel0ToIor(real fresnel0)
{
real sqrtF0 = sqrt(fresnel0);
return (1.0 + sqrtF0) / (1.0 - sqrtF0);
}
// Note: We don't handle the case fresnel0 == 1
//real Fresnel0ToIor(real fresnel0)
//{
// real sqrtF0 = sqrt(fresnel0);
// return (1.0 + sqrtF0) / (1.0 - sqrtF0);
//}
TEMPLATE_1_REAL(Fresnel0ToIor, fresnel0, return ((1.0 + sqrt(fresnel0)) / (1.0 - sqrt(fresnel0))) )
// This function is a coarse approximation of computing fresnel0 for a different top than air (here clear coat of IOR 1.5) when we only have fresnel0 with air interface
// This function is equivalent to IorToFresnel0(Fresnel0ToIor(fresnel0), 1.5)

7
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/CommonMaterial.hlsl


roughnessB = ClampRoughnessForAnalyticalLights(roughnessB);
}
// Same as ConvertAnisotropyToClampRoughness, but without anisotropy.
void ConvertPerceptualRoughnessToClampRoughness(real perceptualRoughness, out real roughness)
{
roughness = PerceptualRoughnessToRoughness(perceptualRoughness);
roughness = ClampRoughnessForAnalyticalLights(roughness);
}
// Use with stack BRDF (clear coat / coat)
real RoughnessToVariance(real roughness)
{

55
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/StackLit/StackLitUI.cs


public static GUIContent maskMapASText = new GUIContent("Primary mask map - M(R), AO(G), D(B), S1(A)", "Primary mask map");
public static GUIContent maskMapBSText = new GUIContent("Secondary mask Map - (R), (G), (B), S2(A)", "Secondary mask map");
public static GUIContent anisotropyText = new GUIContent("Anisotropy", "Anisotropy scale factor");
public static GUIContent coatEnableText = new GUIContent("Clear Coat Enable", "Clear Coat Enable");
public static GUIContent coatSmoothnessText = new GUIContent("Clear Coat Smoothness", "Clear Coat Smoothness");
public static GUIContent coatIorText = new GUIContent("Clear Coat IOR", "Clear Coat IOR");
public static GUIContent coatThicknessText = new GUIContent("Clear Coat Thickness", "Clear Coat Thickness");
public static GUIContent coatExtinctionText = new GUIContent("Clear Coat Extinction", "Clear Coat Beer-Lambert Extinction");
// Emissive
public static string emissiveLabelText = "Emissive Inputs";

protected MaterialProperty normalMap = null;
protected const string kNormalMap = "_NormalMap";
// Anisotropy
protected MaterialProperty anisotropy = null;
protected const string kAnisotropy = "_Anisotropy";
// Clear Coat
protected MaterialProperty coatEnable = null;
protected const string kCoatEnable = "_CoatEnable";
protected MaterialProperty coatSmoothness = null;
protected const string kCoatSmoothness = "_CoatSmoothness";
protected MaterialProperty coatIor = null;
protected const string kCoatIor = "_CoatIor";
protected MaterialProperty coatThickness = null;
protected const string kCoatThickness = "_CoatThickness";
protected MaterialProperty coatExtinction = null;
protected const string kCoatExtinction = "_CoatExtinction";
protected MaterialProperty emissiveColor = null;
protected const string kEmissiveColor = "_EmissiveColor";
protected MaterialProperty emissiveColorMap = null;

normalMap = FindProperty(kNormalMap, props);
normalScale = FindProperty(kNormalScale, props);
anisotropy = FindProperty(kAnisotropy, props);
// Clear Coat
coatEnable = FindProperty(kCoatEnable, props);
coatSmoothness = FindProperty(kCoatSmoothness, props);
coatIor = FindProperty(kCoatIor, props);
coatThickness = FindProperty(kCoatThickness, props);
coatExtinction = FindProperty(kCoatExtinction, props);
emissiveColor = FindProperty(kEmissiveColor, props);
emissiveColorMap = FindProperty(kEmissiveColorMap, props);
emissiveIntensity = FindProperty(kEmissiveIntensity, props);

// Normal map:
m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, normalMap, normalScale);
m_MaterialEditor.ShaderProperty(anisotropy, Styles.anisotropyText);
// Clear Coat
m_MaterialEditor.ShaderProperty(coatEnable, Styles.coatEnableText);
m_MaterialEditor.ShaderProperty(coatSmoothness, Styles.coatSmoothnessText);
m_MaterialEditor.ShaderProperty(coatIor, Styles.coatIorText);
m_MaterialEditor.ShaderProperty(coatThickness, Styles.coatThicknessText);
m_MaterialEditor.ShaderProperty(coatExtinction, Styles.coatExtinctionText);
// UV Mapping:
EditorGUILayout.Space();

}
CoreUtils.SetKeyword(material, "_EMISSIVE_COLOR_MAP", material.GetTexture(kEmissiveColorMap));
bool clearCoatEnabled = material.HasProperty(kCoatEnable) && (material.GetFloat(kCoatEnable) > 0.0f);
bool anisotropyEnabled = material.HasProperty(kAnisotropy) && (material.GetFloat(kAnisotropy) != 0.0f);
// TODO: When we have a map, also test for map for enable. (This scheme doesn't allow enabling from
// neutral value though, better to still have flag and uncheck it in UI code when reach neutral
// value and re-enable otherwise).
// Note that we don't use the materialId (cf Lit.shader) mechanism in the UI
CoreUtils.SetKeyword(material, "_MATERIAL_FEATURE_ANISOTROPY", anisotropyEnabled);
CoreUtils.SetKeyword(material, "_MATERIAL_FEATURE_CLEAR_COAT", clearCoatEnabled);
}
}
} // namespace UnityEditor

10
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VolumetricLighting.cs.hlsl


#ifndef VOLUMETRICLIGHTING_CS_HLSL
#define VOLUMETRICLIGHTING_CS_HLSL
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.DensityVolumeProperties
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.DensityVolumeData
struct DensityVolumeProperties
struct DensityVolumeData
{
float3 scattering;
float extinction;

// Accessors for UnityEngine.Experimental.Rendering.HDPipeline.DensityVolumeProperties
// Accessors for UnityEngine.Experimental.Rendering.HDPipeline.DensityVolumeData
float3 GetScattering(DensityVolumeProperties value)
float3 GetScattering(DensityVolumeData value)
float GetExtinction(DensityVolumeProperties value)
float GetExtinction(DensityVolumeData value)
{
return value.extinction;
}

17
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl


// * the auto-thickness mode uses the baked (textured) thickness to compute transmission from
// indirect lighting and non-shadow-casting lights; for shadowed lights, it calculates
// the thickness using the distance to the closest occluder sampled from the shadow map.
// If the distance is large, it may indicate that the closest occluder is not the back face of
// the current object. That's not a problem, since large thickness will result in low intensity.
// If the distance is large, it may indicate that the closest occluder is not a (back) face of
// the current object and thus shouldn't theorically be considered as defining its thickness
// (as long as the volume defined by the mesh is closed and well-behaved with no self-intersection).
// That's not a problem here however since large thickness will result in low intensity.
bool useThinObjectMode = IsBitSet(asuint(_TransmissionFlags), diffusionProfile);
bsdfData.materialFeatures |= useThinObjectMode ? 0 : MATERIAL_FEATURE_FLAGS_TRANSMISSION_MODE_MIXED_THICKNESS;

// Note: Reuse thickness of transmission's property set
FillMaterialTransparencyData( surfaceData.baseColor, surfaceData.metallic, surfaceData.ior, surfaceData.transmittanceColor, surfaceData.atDistance,
surfaceData.thickness, surfaceData.transmittanceMask, bsdfData);
//slnote: bugbug fresnel0 will be overwritten if clear_coat in GetPreLightData even if we don't
// evaluate its reflections in EvaluateBSDF_Env ! (see also FillMaterialTransparencyData)
#endif
ApplyDebugToBSDFData(bsdfData);

// Clear coat
float coatPartLambdaV;
float3 coatIblR;
float coatIblF; // Fresnel term for view vector
float coatIblF; // Fresnel term for view vector:
float3x3 ltcTransformCoat; // Inverse transformation for GGX (4x VGPRs)
float ltcMagnitudeCoatFresnel;

}
}
// slnote: bugbug fresnel0 will be overwritten if clear_coat in GetPreLightData even if we don't
// evaluate its reflections in EvaluateBSDF_Env! (see also FillMaterialTransparencyData: we expect
// the calculated fresnel0 from IOR there to take over for transparency / refractions.)
// We modify the bsdfData.fresnel0 here for clearCoat
if (HasFeatureFlag(bsdfData.materialFeatures, MATERIALFEATUREFLAGS_LIT_CLEAR_COAT))
{

preLightData.coatPartLambdaV = GetSmithJointGGXPartLambdaV(NdotV, CLEAR_COAT_ROUGHNESS);
preLightData.coatIblR = reflect(-V, N);
preLightData.coatIblF = F_Schlick(CLEAR_COAT_F0, NdotV) * bsdfData.coatMask;
preLightData.coatIblF = F_Schlick(CLEAR_COAT_F0, NdotV) * bsdfData.coatMask; // slnote: apparently we do that so we don't have another FGD fetch for clearcoat
}
float3 iblN, iblR;

44
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLit.cs


using System;
using UnityEngine.Rendering;
//using System.Runtime.InteropServices;
namespace UnityEngine.Experimental.Rendering.HDPipeline
{

public enum MaterialFeatureFlags
{
LitStandard = 1 << 0
LitStandard = 1 << 0,
LitAnisotropy = 1 << 4,
LitClearCoat = 1 << 6
};
//-----------------------------------------------------------------------------

[SurfaceDataAttributes("Material Features")]
public uint materialFeatures;
// Standard
// Bottom interface (2 lobes BSDF)
// Standard parametrization
[SurfaceDataAttributes("Base Color", false, true)]
public Vector3 baseColor;

[SurfaceDataAttributes("Metallic")]
public float metallic;
// Anisotropic
[SurfaceDataAttributes("Tangent", true)]
public Vector3 tangentWS;
[SurfaceDataAttributes("Anisotropy")]
public float anisotropy; // anisotropic ratio(0->no isotropic; 1->full anisotropy in tangent direction, -1->full anisotropy in bitangent direction)
// Top interface and media (clearcoat)
[SurfaceDataAttributes("Coat Roughness")]
public float coatPerceptualSmoothness;
[SurfaceDataAttributes("Coat IOR")]
public float coatIor;
[SurfaceDataAttributes("Coat Thickness")]
public float coatThickness;
[SurfaceDataAttributes("Coat Extinction Coefficient")]
public Vector3 coatExtinction;
};
//-----------------------------------------------------------------------------

{
public uint materialFeatures;
// Bottom interface (2 lobes BSDF)
// Standard parametrization
[SurfaceDataAttributes("", false, true)]
public Vector3 diffuseColor;
public Vector3 fresnel0;

public float perceptualRoughnessA;
public float perceptualRoughnessB;
public float lobeMix;
// Anisotropic
[SurfaceDataAttributes("", true)]
public Vector3 tangentWS;
[SurfaceDataAttributes("", true)]
public Vector3 bitangentWS;
public float coatRoughness;
// Top interface and media (clearcoat)
public float coatPerceptualRoughness;
public float coatIor;
public float coatThickness;
public Vector3 coatExtinction;
//could use something like that:
//[MarshalAs(UnmanagedType.ByValArray, SizeConst=5)]
//public float[] test;
};

81
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLit.cs.hlsl


// UnityEngine.Experimental.Rendering.HDPipeline.StackLit+MaterialFeatureFlags: static fields
//
#define MATERIALFEATUREFLAGS_LIT_STANDARD (1)
#define MATERIALFEATUREFLAGS_LIT_ANISOTROPY (16)
#define MATERIALFEATUREFLAGS_LIT_CLEAR_COAT (64)
//
// UnityEngine.Experimental.Rendering.HDPipeline.StackLit+SurfaceData: static fields

#define DEBUGVIEW_STACKLIT_SURFACEDATA_SMOOTHNESS_B (1305)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_LOBE_MIXING (1306)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_METALLIC (1307)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_TANGENT (1308)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_ANISOTROPY (1309)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_CLEAR_COAT_ROUGHNESS (1310)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_CLEAR_COAT_IOR (1311)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_CLEAR_COAT_THICKNESS (1312)
#define DEBUGVIEW_STACKLIT_SURFACEDATA_CLEAR_COAT_EXTINCTION_COEFFICIENT (1313)
//
// UnityEngine.Experimental.Rendering.HDPipeline.StackLit+BSDFData: static fields

#define DEBUGVIEW_STACKLIT_BSDFDATA_NORMAL_VIEW_SPACE (1404)
#define DEBUGVIEW_STACKLIT_BSDFDATA_PERCEPTUAL_ROUGHNESS_A (1405)
#define DEBUGVIEW_STACKLIT_BSDFDATA_PERCEPTUAL_ROUGHNESS_B (1406)
#define DEBUGVIEW_STACKLIT_BSDFDATA_LOBE_MIXING (1407)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ROUGHNESS_AT (1408)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ROUGHNESS_AB (1409)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ROUGHNESS_BT (1410)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ROUGHNESS_BB (1411)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ANISOTROPY (1412)
#define DEBUGVIEW_STACKLIT_BSDFDATA_LOBE_MIX (1407)
#define DEBUGVIEW_STACKLIT_BSDFDATA_TANGENT_WS (1408)
#define DEBUGVIEW_STACKLIT_BSDFDATA_BITANGENT_WS (1409)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ROUGHNESS_AT (1410)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ROUGHNESS_AB (1411)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ROUGHNESS_BT (1412)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ROUGHNESS_BB (1413)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_ROUGHNESS (1414)
#define DEBUGVIEW_STACKLIT_BSDFDATA_ANISOTROPY (1415)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_PERCEPTUAL_ROUGHNESS (1416)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_IOR (1417)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_THICKNESS (1418)
#define DEBUGVIEW_STACKLIT_BSDFDATA_COAT_EXTINCTION (1419)
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.StackLit+SurfaceData
// PackingRules = Exact

float perceptualSmoothnessB;
float lobeMix;
float metallic;
float3 tangentWS;
float anisotropy;
float coatPerceptualSmoothness;
float coatIor;
float coatThickness;
float3 coatExtinction;
};
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.StackLit+BSDFData

float perceptualRoughnessA;
float perceptualRoughnessB;
float lobeMix;
float3 tangentWS;
float3 bitangentWS;
float coatRoughness;
float coatPerceptualRoughness;
float coatIor;
float coatThickness;
float3 coatExtinction;
};
//

case DEBUGVIEW_STACKLIT_SURFACEDATA_METALLIC:
result = surfacedata.metallic.xxx;
break;
case DEBUGVIEW_STACKLIT_SURFACEDATA_TANGENT:
result = surfacedata.tangentWS * 0.5 + 0.5;
break;
case DEBUGVIEW_STACKLIT_SURFACEDATA_ANISOTROPY:
result = surfacedata.anisotropy.xxx;
break;
case DEBUGVIEW_STACKLIT_SURFACEDATA_CLEAR_COAT_ROUGHNESS:
result = surfacedata.coatPerceptualSmoothness.xxx;
break;
case DEBUGVIEW_STACKLIT_SURFACEDATA_CLEAR_COAT_IOR:
result = surfacedata.coatIor.xxx;
break;
case DEBUGVIEW_STACKLIT_SURFACEDATA_CLEAR_COAT_THICKNESS:
result = surfacedata.coatThickness.xxx;
break;
case DEBUGVIEW_STACKLIT_SURFACEDATA_CLEAR_COAT_EXTINCTION_COEFFICIENT:
result = surfacedata.coatExtinction;
break;
}
}

case DEBUGVIEW_STACKLIT_BSDFDATA_PERCEPTUAL_ROUGHNESS_B:
result = bsdfdata.perceptualRoughnessB.xxx;
break;
case DEBUGVIEW_STACKLIT_BSDFDATA_LOBE_MIXING:
case DEBUGVIEW_STACKLIT_BSDFDATA_LOBE_MIX:
case DEBUGVIEW_STACKLIT_BSDFDATA_TANGENT_WS:
result = bsdfdata.tangentWS * 0.5 + 0.5;
break;
case DEBUGVIEW_STACKLIT_BSDFDATA_BITANGENT_WS:
result = bsdfdata.bitangentWS * 0.5 + 0.5;
break;
case DEBUGVIEW_STACKLIT_BSDFDATA_ROUGHNESS_AT:
result = bsdfdata.roughnessAT.xxx;
break;

case DEBUGVIEW_STACKLIT_BSDFDATA_ROUGHNESS_BB:
result = bsdfdata.roughnessBB.xxx;
break;
case DEBUGVIEW_STACKLIT_BSDFDATA_COAT_ROUGHNESS:
result = bsdfdata.coatRoughness.xxx;
break;
break;
case DEBUGVIEW_STACKLIT_BSDFDATA_COAT_PERCEPTUAL_ROUGHNESS:
result = bsdfdata.coatPerceptualRoughness.xxx;
break;
case DEBUGVIEW_STACKLIT_BSDFDATA_COAT_IOR:
result = bsdfdata.coatIor.xxx;
break;
case DEBUGVIEW_STACKLIT_BSDFDATA_COAT_THICKNESS:
result = bsdfdata.coatThickness.xxx;
break;
case DEBUGVIEW_STACKLIT_BSDFDATA_COAT_EXTINCTION:
result = bsdfdata.coatExtinction;
break;
}
}

970
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLit.hlsl
文件差异内容过多而无法显示
查看文件

15
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLit.shader


_MaskMapA("MaskMapA", 2D) = "white" {}
_MaskMapB("MaskMapB", 2D) = "white" {}
// TODO: TangentMap, AnisotropyMap and CoatIorMap (SmoothnessMap ?)
_Anisotropy("Anisotropy", Range(-1.0, 1.0)) = 0.0
[ToggleUI] _CoatEnable("Coat Enable", Float) = 0.0 // UI only
_CoatSmoothness("Coat Smoothness", Range(0.0, 1.0)) = 1.0
_CoatIor("Coat IOR", Range(1.0, 2.0)) = 1.5
_CoatThickness("Coat Thickness", Range(0.0, 0.99)) = 0.0
_CoatExtinction("Coat Extinction Coefficient", Color) = (1,1,1,1) // in thickness^-1 units
_NormalMap("NormalMap", 2D) = "bump" {} // Tangent space normal map
_NormalScale("_NormalScale", Range(0.0, 2.0)) = 1

#pragma shader_feature _ _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_PRE_MULTIPLY
#pragma shader_feature _BLENDMODE_PRESERVE_SPECULAR_LIGHTING // easily handled in material.hlsl, so adding this already.
#pragma shader_feature _ENABLE_FOG_ON_TRANSPARENT
// MaterialFeature are used as shader feature to allow compiler to optimize properly
#pragma shader_feature _MATERIAL_FEATURE_ANISOTROPY
#pragma shader_feature _MATERIAL_FEATURE_CLEAR_COAT
//enable GPU instancing support
#pragma multi_compile_instancing

39
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLitData.hlsl


float3 detailNormalTS = float3(0.0, 0.0, 0.0);
float detailMask = 0.0;
//surfaceData.normalWS = float3(0.0, 0.0, 0.0);
normalTS = GetNormalTS(input, layerTexCoord, detailNormalTS, detailMask);
//TODO: bentNormalTS

#else
surfaceData.perceptualSmoothnessB = _SmoothnessB;
#endif
// TODOSTACKLIT: lobe weighting
surfaceData.lobeMix = _LobeMix;
// MaskMapA is RGBA: Metallic, Ambient Occlusion (Optional), detail Mask (Optional), Smoothness

surfaceData.metallic = 1.0;
#endif
surfaceData.metallic *= _Metallic;
// These static material feature allow compile time optimization
// TODO: As we add features, or-set the flags eg MATERIALFEATUREFLAGS_LIT_* with #ifdef

#ifdef _MATERIAL_FEATURE_ANISOTROPY
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_ANISOTROPY;
#endif
#ifdef _MATERIAL_FEATURE_CLEAR_COAT
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_LIT_CLEAR_COAT;
#endif
// -------------------------------------------------------------
// Feature dependent data
// -------------------------------------------------------------
// TODO: #ifdef _TANGENTMAP, object space, etc.
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
// TODO: #ifdef _ANISOTROPYMAP
surfaceData.anisotropy = 1.0;
#ifdef _MATERIAL_FEATURE_ANISOTROPY
surfaceData.anisotropy *= _Anisotropy;
#endif
#ifdef _MATERIAL_FEATURE_CLEAR_COAT
surfaceData.coatPerceptualSmoothness = _CoatSmoothness;
surfaceData.coatIor = _CoatIor;
surfaceData.coatThickness = _CoatThickness;
surfaceData.coatExtinction = _CoatExtinction; // in thickness^-1 units
#else
surfaceData.coatPerceptualSmoothness = 0.0;
surfaceData.coatIor = 1.0;
surfaceData.coatThickness = 0.0;
surfaceData.coatExtinction = float3(1.0, 1.0, 1.0);
#endif
// -------------------------------------------------------------
// Surface Data Part 2 (outsite GetSurfaceData( ) in Lit shader):
// -------------------------------------------------------------

builtinData.opacity = alpha;
// TODO:
builtinData.bakeDiffuseLighting = float3(0.0, 0.0, 0.0);
// Emissive Intensity is only use here, but is part of BuiltinData to enforce UI parameters as we want the users to fill one color and one intensity

builtinData.emissiveColor *= SAMPLE_TEXTURE2D(_EmissiveColorMap, sampler_EmissiveColorMap, TRANSFORM_TEX(input.texCoord0, _EmissiveColorMap)).rgb;
#endif
// TODO:
builtinData.velocity = float2(0.0, 0.0);

6
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLitProperties.hlsl


float _SmoothnessBRemapMax;
float _LobeMix;
float _Anisotropy;
float _CoatSmoothness;
float _CoatIor;
float _CoatThickness;
float4 _CoatExtinction;
float _NormalScale;
float4 _UVMappingMask;

正在加载...
取消
保存