浏览代码

Merge pull request #1298 from Unity-Technologies/Clean-UI-for-StackLit

Clean ui for stacklit - coat smoothness
/main
GitHub 7 年前
当前提交
66bad7b7
共有 5 个文件被更改,包括 30 次插入17 次删除
  1. 33
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/StackLit/StackLitUI.cs
  2. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLit.cs
  3. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLit.shader
  4. 8
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLitData.hlsl
  5. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/StackLit/StackLitProperties.hlsl

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


protected const string k_DielectricIor = "_DielectricIor";
protected const string k_Smoothness1 = "_SmoothnessA";
protected const string k_Smoothness1Map = "_SmoothnessAMap";
protected const string k_Smoothness1MapUV = "_SmoothnessAMapUV";
protected const string k_SmoothnessA = "_SmoothnessA";
protected const string k_SmoothnessAMap = "_SmoothnessAMap";
protected const string k_SmoothnessAMapUV = "_SmoothnessAMapUV";
protected const string k_NormalMap = "_NormalMap";
protected const string k_NormalMapUV = "_NormalMapUV";

// Coat
protected const string k_EnableCoat = "_EnableCoat";
protected const string k_CoatSmoothness = "_CoatSmoothness";
protected const string k_CoatSmoothnessMap = "_CoatSmoothnessMap";
protected const string k_CoatSmoothnessMapUV = "_CoatSmoothnessMapUV";
protected const string k_CoatIor = "_CoatIor";
protected const string k_CoatThickness = "_CoatThickness";
protected const string k_CoatExtinction = "_CoatExtinction";

// Second Lobe.
protected const string k_EnableDualSpecularLobe = "_EnableDualSpecularLobe";
protected const string k_Smoothness2 = "_SmoothnessB";
protected const string k_Smoothness2Map = "_SmoothnessBMap";
protected const string k_Smoothness2MapUV = "_SmoothnessBMapUV";
protected const string k_SmoothnessB = "_SmoothnessB";
protected const string k_SmoothnessBMap = "_SmoothnessBMap";
protected const string k_SmoothnessBMapUV = "_SmoothnessBMapUV";
protected const string k_LobeMix = "_LobeMix";

new TextureProperty(this, k_BaseColorMap, k_BaseColor, "Base Color + Opacity", "Albedo (RGB) and Opacity (A)", true, false),
new TextureProperty(this, k_MetallicMap, k_Metallic, "Metallic", "Metallic", false, false),
new Property(this, k_DielectricIor, "DieletricIor", "IOR use for dielectric material (i.e non metallic material)", false),
new TextureProperty(this, k_Smoothness1Map, k_Smoothness1, "Smoothness", "Smoothness", false, false),
new TextureProperty(this, k_SmoothnessAMap, k_SmoothnessA, "Smoothness", "Smoothness", false, false),
new TextureProperty(this, k_NormalMap, k_NormalScale, "Normal", "Normal Map", false, false, true),
new TextureProperty(this, k_AmbientOcclusionMap, k_AmbientOcclusion, "AmbientOcclusion", "AmbientOcclusion Map", false, false),
}),

new TextureProperty(this, k_Smoothness2Map, k_Smoothness2, "Smoothness2", "Smoothness2", false, false),
new TextureProperty(this, k_SmoothnessBMap, k_SmoothnessB, "Smoothness B", "Smoothness B", false, false),
new Property(this, k_LobeMix, "Lobe Mix", "Lobe Mix", false),
}, _ => EnableDualSpecularLobe.BoolValue == true),

new GroupProperty(this, "_Coat", "Coat", new BaseProperty[]
{
new Property(this, "_CoatSmoothness", "Coat Smoothness", "Top layer smoothness", false),
new TextureProperty(this, k_CoatSmoothnessMap, k_CoatSmoothness, "Coat smoothness", "Coat smoothness", false),
new Property(this, "_CoatIor", "Coat IOR", "Index of refraction", false),
new Property(this, "_CoatThickness", "Coat Thickness", "Coat thickness", false),
new Property(this, "_CoatExtinction", "Coat Absorption", "Coat absorption tint (the thicker the coat, the more that color is removed)", false),

//TODO: disable DBUFFER
SetupTextureMaterialProperty(material, k_Metallic);
SetupTextureMaterialProperty(material, k_Smoothness1);
SetupTextureMaterialProperty(material, k_Smoothness2);
SetupTextureMaterialProperty(material, k_SmoothnessA);
SetupTextureMaterialProperty(material, k_SmoothnessB);
SetupTextureMaterialProperty(material, k_CoatSmoothness);
// Check if we are using specific UVs.
TextureProperty.UVMapping[] uvIndices = new[]

(TextureProperty.UVMapping) material.GetFloat(k_NormalMapUV),
(TextureProperty.UVMapping) material.GetFloat(k_Smoothness1MapUV),
(TextureProperty.UVMapping) material.GetFloat(k_Smoothness2MapUV),
(TextureProperty.UVMapping) material.GetFloat(k_SmoothnessAMapUV),
(TextureProperty.UVMapping) material.GetFloat(k_SmoothnessBMapUV),
(TextureProperty.UVMapping) material.GetFloat(k_AmbientOcclusionMapUV),
(TextureProperty.UVMapping) material.GetFloat(k_EmissiveColorMapUV),
(TextureProperty.UVMapping) material.GetFloat(k_SubsurfaceMaskMapUV),

(TextureProperty.UVMapping) material.GetFloat(k_CoatSmoothnessMapUV),
};
// Set keyword for mapping

bool sssEnabled = material.HasProperty(k_EnableSubsurfaceScattering) && material.GetFloat(k_EnableSubsurfaceScattering) > 0.0f;
CoreUtils.SetKeyword(material, "_MATERIAL_FEATURE_SUBSURFACE_SCATTERING", sssEnabled);
bool coatEnabled = material.HasProperty(k_EnableCoat) && material.GetFloat(k_EnableCoat) > 0.0f;
CoreUtils.SetKeyword(material, "_MATERIAL_FEATURE_COAT", coatEnabled);
// TEMP - Remove once dev is finish
bool debugEnabled = material.HasProperty("_DebugEnable") && material.GetFloat("_DebugEnable") > 0.0f;

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


public float iridescenceThickness;
// Top interface and media (clearcoat)
[SurfaceDataAttributes("Coat Roughness")]
[SurfaceDataAttributes("Coat Smoothness")]
public float coatPerceptualSmoothness;
[SurfaceDataAttributes("Coat IOR")]
public float coatIor;

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


[HideInInspector] _AnisotropyRange("Anisotropy Range", Vector) = (0, 1, 0, 0)
[ToggleUI] _EnableCoat("Enable Coat", Float) = 0.0 // UI only
[HideInInspector] _CoatSmoothnessMapShow("CoatSmoothness Show", Float) = 0
_CoatSmoothness("CoatSmoothness", Range(0.0, 1.0)) = 1.0
_CoatSmoothnessMap("CoatSmoothness Map", 2D) = "white" {}
_CoatSmoothnessUseMap("CoatSmoothness Use Map", Float) = 0

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


#ifdef _MATERIAL_FEATURE_COAT
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_STACK_LIT_COAT;
surfaceData.coatPerceptualSmoothness = _CoatSmoothness;
surfaceData.coatPerceptualSmoothness = dot(SAMPLE_TEXTURE2D_SCALE_BIAS(_CoatSmoothnessMap), _CoatSmoothnessMapChannelMask);
surfaceData.coatPerceptualSmoothness = lerp(_CoatSmoothnessRange.x, _CoatSmoothnessRange.y, surfaceData.coatPerceptualSmoothness);
surfaceData.coatPerceptualSmoothness = lerp(_CoatSmoothness, surfaceData.coatPerceptualSmoothness, _CoatSmoothnessUseMap);
surfaceData.coatIor = _CoatIor;
surfaceData.coatThickness = _CoatThickness;
surfaceData.coatExtinction = _CoatExtinction; // in thickness^-1 units

#ifdef _MATERIAL_FEATURE_IRIDESCENCE
surfaceData.materialFeatures |= MATERIALFEATUREFLAGS_STACK_LIT_IRIDESCENCE;
surfaceData.iridescenceIor = _IridescenceIor;
surfaceData.iridescenceThickness = dot(SAMPLE_TEXTURE2D_SCALE_BIAS(iridescenceThicknessMap), iridescenceThicknessMapChannelMask);
surfaceData.iridescenceThickness = lerp(iridescenceThicknessRange.x, iridescenceThicknessRange.y, surfaceData.iridescenceThickness);
surfaceData.iridescenceThickness = dot(SAMPLE_TEXTURE2D_SCALE_BIAS(_IridescenceThicknessMap), _IridescenceThicknessMapChannelMask);
surfaceData.iridescenceThickness = lerp(_IridescenceThicknessRange.x, _IridescenceThicknessRange.y, surfaceData.iridescenceThickness);
surfaceData.iridescenceThickness = lerp(_IridescenceThickness, surfaceData.iridescenceThickness, _IridescenceThicknessUseMap);
#else
surfaceData.iridescenceIor = 1.0;

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


TEXTURE2D(_AnisotropyMap);
SAMPLER(sampler_AnisotropyMap);
TEXTURE2D(_CoatSmoothnessMap);
SAMPLER(sampler_CoatSmoothnessMap);
TEXTURE2D(_IridescenceThicknessMap);
SAMPLER(sampler_IridescenceThicknessMap);

正在加载...
取消
保存