浏览代码

Add energy conservation specular color

/main
sebastienlagarde 7 年前
当前提交
e9ba97a3
共有 5 个文件被更改,包括 22 次插入2 次删除
  1. 14
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Lit/LitUI.cs
  2. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.shader
  3. 5
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/LitDataIndividualLayer.hlsl
  4. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/LitProperties.hlsl
  5. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/LitTessellation.shader

14
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Lit/LitUI.cs


public static GUIContent coatMaskText = new GUIContent("Coat Mask", "Attenuate the coating effect (similar to change to IOR of 1");
// Specular color
public static GUIContent energyConservingSpecularColorText = new GUIContent("Energy Conserving Specular Color", "Enable energy conservation when using Specular Color mode (i.e high Specular Color mean lower Diffuse Color");
public static GUIContent specularColorText = new GUIContent("Specular Color", "Specular color (RGB)");
// Specular occlusion

protected MaterialProperty[] detailSmoothnessScale = new MaterialProperty[kMaxLayerCount];
protected const string kDetailSmoothnessScale = "_DetailSmoothnessScale";
protected MaterialProperty energyConservingSpecularColor = null;
protected const string kEnergyConservingSpecularColor = "_EnergyConservingSpecularColor";
protected MaterialProperty specularColor = null;
protected const string kSpecularColor = "_SpecularColor";
protected MaterialProperty specularColorMap = null;

// The next properties are only supported for regular Lit shader (not layered ones) because it's complicated to blend those parameters if they are different on a per layer basis.
// Specular Color
energyConservingSpecularColor = FindProperty(kEnergyConservingSpecularColor, props);
specularColor = FindProperty(kSpecularColor, props);
specularColorMap = FindProperty(kSpecularColorMap, props);

// We reuse thickness from SSS
}
protected void ShaderSpecularColorInputGUI(Material material)
{
m_MaterialEditor.TexturePropertySingleLine(Styles.specularColorText, specularColorMap, specularColor);
EditorGUI.indentLevel++;
m_MaterialEditor.ShaderProperty(energyConservingSpecularColor, Styles.energyConservingSpecularColorText);
EditorGUI.indentLevel--;
}
protected void ShaderSSSInputGUI(Material material, int layerIndex)
{
var hdPipeline = RenderPipelineManager.currentPipeline as HDRenderPipeline;

ShaderAnisoInputGUI();
break;
case BaseLitGUI.MaterialId.LitSpecular:
m_MaterialEditor.TexturePropertySingleLine(Styles.specularColorText, specularColorMap, specularColor);
ShaderSpecularColorInputGUI(material);
break;
case BaseLitGUI.MaterialId.LitClearCoat:
ShaderClearCoatInputGUI();

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


_CoatMask("Coat Mask", Range(0.0, 1.0)) = 1.0
[ToggleUI] _EnergyConservingSpecularColor("_EnergyConservingSpecularColor", Float) = 1.0
_SpecularColor("SpecularColor", Color) = (1, 1, 1, 1)
_SpecularColorMap("SpecularColorMap", 2D) = "white" {}

5
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/LitDataIndividualLayer.hlsl


#ifdef _SPECULARCOLORMAP
surfaceData.specularColor *= SAMPLE_UVMAPPING_TEXTURE2D(_SpecularColorMap, sampler_SpecularColorMap, layerTexCoord.base).rgb;
#endif
#ifdef _MATERIAL_FEATURE_SPECULAR_COLOR
// Require to have setup baseColor
// Reproduce the energy conservation done in legacy Unity. Not ideal but better for compatibility and users can unchek it
surfaceData.baseColor *= _EnergyConservingSpecularColor > 0.0 ? (1.0 - Max3(surfaceData.specularColor.r, surfaceData.specularColor.g, surfaceData.specularColor.b)) : 1.0;
#endif
#if HAS_REFRACTION
surfaceData.ior = _IOR;

3
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/LitProperties.hlsl


float _CoatMask;
float4 _SpecularColor;
float4 _SpecularColor;
float _EnergyConservingSpecularColor;
float _TexWorldScale;
float _InvTilingScale;

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/LitTessellation.shader


_CoatMask("Coat Mask", Range(0.0, 1.0)) = 1.0
[ToggleUI] _EnergyConservingSpecularColor("_EnergyConservingSpecularColor", Float) = 1.0
_SpecularColor("SpecularColor", Color) = (1, 1, 1, 1)
_SpecularColorMap("SpecularColorMap", 2D) = "white" {}

正在加载...
取消
保存