浏览代码

Merge pull request #531 from EvgeniiG/Unity-2017.3

Add a thickness remap for the thickness map (on the material itself)
/Yibing-Project-2
GitHub 7 年前
当前提交
ffcd395f
共有 8 个文件被更改,包括 38 次插入4 次删除
  1. 5
      ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
  2. 5
      ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader
  3. 21
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/LitUI.cs
  4. 1
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader
  5. 6
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitDataIndividualLayer.hlsl
  6. 1
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitProperties.hlsl
  7. 1
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.shader
  8. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/SubsurfaceScatteringSettings.cs

5
ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader


_ThicknessMap2("Thickness Map", 2D) = "white" {}
_ThicknessMap3("Thickness Map", 2D) = "white" {}
_ThicknessRemap0("Thickness Remap", Vector) = (0, 1, 0, 0)
_ThicknessRemap1("Thickness Remap", Vector) = (0, 1, 0, 0)
_ThicknessRemap2("Thickness Remap", Vector) = (0, 1, 0, 0)
_ThicknessRemap3("Thickness Remap", Vector) = (0, 1, 0, 0)
// All the following properties exist only in layered lit material
// Layer blending options

5
ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader


_ThicknessMap2("Thickness Map", 2D) = "white" {}
_ThicknessMap3("Thickness Map", 2D) = "white" {}
_ThicknessRemap0("Thickness Remap", Vector) = (0, 1, 0, 0)
_ThicknessRemap1("Thickness Remap", Vector) = (0, 1, 0, 0)
_ThicknessRemap2("Thickness Remap", Vector) = (0, 1, 0, 0)
_ThicknessRemap3("Thickness Remap", Vector) = (0, 1, 0, 0)
// All the following properties exist only in layered lit material
// Layer blending options

21
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/LitUI.cs


public static GUIContent subsurfaceRadiusMapText = new GUIContent("Subsurface radius map (R)", "Determines the range of the blur.");
public static GUIContent thicknessText = new GUIContent("Thickness", "If subsurface scattering is enabled, low values allow some light to be transmitted through the object.");
public static GUIContent thicknessMapText = new GUIContent("Thickness map (R)", "If subsurface scattering is enabled, low values allow some light to be transmitted through the object.");
public static GUIContent thicknessRemapText = new GUIContent("Thickness Remap", "Remaps values of the thickness map from [0, 1] to the specified range.");
// Clear Coat
public static GUIContent coatCoverageText = new GUIContent("Coat Coverage", "Percentage of clear coat coverage");

protected const string kThickness = "_Thickness";
protected MaterialProperty[] thicknessMap = new MaterialProperty[kMaxLayerCount];
protected const string kThicknessMap = "_ThicknessMap";
protected MaterialProperty[] thicknessRemap = new MaterialProperty[kMaxLayerCount];
protected const string kThicknessRemap = "_ThicknessRemap";
protected MaterialProperty[] UVDetail = new MaterialProperty[kMaxLayerCount];
protected const string kUVDetail = "_UVDetail";

subsurfaceRadiusMap[i] = FindProperty(string.Format("{0}{1}", kSubsurfaceRadiusMap, m_PropertySuffixes[i]), props);
thickness[i] = FindProperty(string.Format("{0}{1}", kThickness, m_PropertySuffixes[i]), props);
thicknessMap[i] = FindProperty(string.Format("{0}{1}", kThicknessMap, m_PropertySuffixes[i]), props);
thicknessRemap[i] = FindProperty(string.Format("{0}{1}", kThicknessRemap, m_PropertySuffixes[i]), props);
// Details
UVDetail[i] = FindProperty(string.Format("{0}{1}", kUVDetail, m_PropertySuffixes[i]), props);

m_MaterialEditor.ShaderProperty(subsurfaceRadius[layerIndex], Styles.subsurfaceRadiusText);
m_MaterialEditor.TexturePropertySingleLine(Styles.subsurfaceRadiusMapText, subsurfaceRadiusMap[layerIndex]);
m_MaterialEditor.ShaderProperty(thickness[layerIndex], Styles.thicknessText);
if (thicknessMap[layerIndex].textureValue != null)
{
// Display the remap of texture values.
Vector2 remap = thicknessRemap[layerIndex].vectorValue;
EditorGUI.BeginChangeCheck();
EditorGUILayout.MinMaxSlider(Styles.thicknessRemapText, ref remap.x, ref remap.y, 0.0f, 1.0f);
if (EditorGUI.EndChangeCheck())
{
thicknessRemap[layerIndex].vectorValue = remap;
}
}
else
{
// Allow the user to set the constant value of thickness if no thickness map is provided.
m_MaterialEditor.ShaderProperty(thickness[layerIndex], Styles.thicknessText);
}
}
protected void ShaderClearCoatInputGUI()

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


_SubsurfaceRadiusMap("Subsurface Radius Map", 2D) = "white" {}
_Thickness("Thickness", Range(0.0, 1.0)) = 1.0
_ThicknessMap("Thickness Map", 2D) = "white" {}
_ThicknessRemap("Thickness Remap", Vector) = (0, 1, 0, 0)
_CoatCoverage("Coat Coverage", Range(0.0, 1.0)) = 1.0
_CoatIOR("Coat IOR", Range(0.0, 1.0)) = 0.5

6
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitDataIndividualLayer.hlsl


surfaceData.subsurfaceProfile = ADD_IDX(_SubsurfaceProfile);
surfaceData.subsurfaceRadius = ADD_IDX(_SubsurfaceRadius);
surfaceData.thickness = ADD_IDX(_Thickness);
#ifdef _SUBSURFACE_RADIUS_MAP_IDX
surfaceData.subsurfaceRadius *= SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_SubsurfaceRadiusMap), SAMPLER_SUBSURFACE_RADIUSMAP_IDX, ADD_IDX(layerTexCoord.base)).r;

surfaceData.thickness *= SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_ThicknessMap), SAMPLER_THICKNESSMAP_IDX, ADD_IDX(layerTexCoord.base)).r;
surfaceData.thickness = SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_ThicknessMap), SAMPLER_THICKNESSMAP_IDX, ADD_IDX(layerTexCoord.base)).r;
surfaceData.thickness = ADD_IDX(_ThicknessRemap).x + ADD_IDX(_ThicknessRemap).y * surfaceData.thickness;
#else
surfaceData.thickness = ADD_IDX(_Thickness);
#endif
// This part of the code is not used in case of layered shader but we keep the same macro system for simplicity

1
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitProperties.hlsl


int _SubsurfaceProfile;
float _SubsurfaceRadius;
float _Thickness;
float4 _ThicknessRemap;
float _CoatCoverage;
float _CoatIOR;

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


_SubsurfaceRadiusMap("Subsurface Radius Map", 2D) = "white" {}
_Thickness("Thickness", Range(0.0, 1.0)) = 1.0
_ThicknessMap("Thickness Map", 2D) = "white" {}
_ThicknessRemap("Thickness Remap", Vector) = (0, 1, 0, 0)
_CoatCoverage("Coat Coverage", Range(0.0, 1.0)) = 1.0
_CoatIOR("Coat IOR", Range(0.0, 1.0)) = 0.5

2
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/SubsurfaceScatteringSettings.cs


ValidateArray(ref halfRcpVariancesAndWeights, SssConstants.SSS_N_PROFILES * 2);
ValidateArray(ref filterKernelsBasic, SssConstants.SSS_N_PROFILES * SssConstants.SSS_BASIC_N_SAMPLES);
Debug.Assert(SssConstants.SSS_NEUTRAL_PROFILE_ID < 16, "Transmission flags (32-bit integer) cannot support more than 16 profiles.");
Debug.Assert(SssConstants.SSS_NEUTRAL_PROFILE_ID < 16, "Transmission flags (32-bit integer) cannot support more than 16 profiles (2 bits per profile).");
UpdateCache();
}

正在加载...
取消
保存