浏览代码

Rename 'ThicknessMap' to 'ThicknessRemap' to avoid confusion

/Branch_Batching2
Evgenii Golubev 8 年前
当前提交
c74a3040
共有 4 个文件被更改,包括 36 次插入36 次删除
  1. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  2. 10
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl
  3. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/Resources/DrawTransmittanceGraph.shader
  4. 56
      Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/SubsurfaceScatteringParameters.cs

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


// Broadcast SSS parameters to all shaders.
Shader.SetGlobalInt("_TransmissionFlags", sssParameters.transmissionFlags);
Shader.SetGlobalFloatArray("_ThicknessMaps", sssParameters.thicknessMaps);
Shader.SetGlobalFloatArray("_ThicknessRemaps", sssParameters.thicknessRemaps);
Shader.SetGlobalVectorArray("_HalfRcpVariancesAndLerpWeights", sssParameters.halfRcpVariancesAndLerpWeights);
if (sssParameters.enableSSS)

10
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl


// SSS parameters
#define N_PROFILES 8
uint _TransmissionFlags; // One bit per profile; 1 = enabled
float _ThicknessMaps[N_PROFILES][2]; // Remap: 0 = start, 1 = end - start
float _ThicknessRemaps[N_PROFILES][2]; // Remap: 0 = start, 1 = end - start
float4 _HalfRcpVariancesAndLerpWeights[N_PROFILES][2]; // 2x Gaussians per color channel, A is the the associated interpolation weight
//-----------------------------------------------------------------------------

bsdfData.fresnel0 = 0.028; // TODO take from subsurfaceProfile
bsdfData.subsurfaceProfile = surfaceData.subsurfaceProfile;
bsdfData.subsurfaceRadius = 0.01 * surfaceData.subsurfaceRadius;
bsdfData.thickness = 0.01 * (_ThicknessMaps[bsdfData.subsurfaceProfile][0]
+ _ThicknessMaps[bsdfData.subsurfaceProfile][1] * surfaceData.thickness);
bsdfData.thickness = 0.01 * (_ThicknessRemaps[bsdfData.subsurfaceProfile][0] +
_ThicknessRemaps[bsdfData.subsurfaceProfile][1] * surfaceData.thickness);
bsdfData.enableTransmission = (1 << bsdfData.subsurfaceProfile) & _TransmissionFlags;
if (bsdfData.enableTransmission)
{

bsdfData.fresnel0 = 0.028; // TODO take from subsurfaceProfile
bsdfData.subsurfaceProfile = 8.00 * inGBuffer2.a;
bsdfData.subsurfaceRadius = 0.01 * inGBuffer2.r;
bsdfData.thickness = 0.01 * (_ThicknessMaps[bsdfData.subsurfaceProfile][0]
+ _ThicknessMaps[bsdfData.subsurfaceProfile][1] * inGBuffer2.g);
bsdfData.thickness = 0.01 * (_ThicknessRemaps[bsdfData.subsurfaceProfile][0] +
_ThicknessRemaps[bsdfData.subsurfaceProfile][1] * inGBuffer2.g);
bsdfData.enableTransmission = (1 << bsdfData.subsurfaceProfile) & _TransmissionFlags;
if (bsdfData.enableTransmission)
{

4
Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/Resources/DrawTransmittanceGraph.shader


// Inputs & outputs
//-------------------------------------------------------------------------------------
float4 _StdDev1, _StdDev2, _ThicknessMap;
float4 _StdDev1, _StdDev2, _ThicknessRemap;
float _LerpWeight; // See 'SubsurfaceScatteringParameters'
//-------------------------------------------------------------------------------------

float4 Frag(Varyings input) : SV_Target
{
float thickness = _ThicknessMap.x + input.texcoord.x * (_ThicknessMap.y - _ThicknessMap.x);
float thickness = _ThicknessRemap.x + input.texcoord.x * (_ThicknessRemap.y - _ThicknessRemap.x);
float t2 = thickness * thickness;
float3 var1 = _StdDev1.rgb * _StdDev1.rgb;

56
Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/SubsurfaceScatteringParameters.cs


[SerializeField]
public bool enableTransmission;
[SerializeField]
public Vector2 thicknessMap;
public Vector2 thicknessRemap;
[SerializeField] [HideInInspector]
Vector4[] m_FilterKernel;
[SerializeField] [HideInInspector]

stdDev2 = new Color(0.6f, 0.6f, 0.6f, 0.0f);
lerpWeight = 0.5f;
enableTransmission = false;
thicknessMap = new Vector2(0, 3);
thicknessRemap = new Vector2(0, 3);
UpdateKernelAndVarianceData();
}

[SerializeField]
SubsurfaceScatteringProfile[] m_Profiles;
[SerializeField]
float[] m_ThicknessMaps;
float[] m_ThicknessRemaps;
[SerializeField]
Vector4[] m_HalfRcpVariancesAndLerpWeights;
[SerializeField]

get { return m_TransmissionFlags; }
}
// Supplies '_ThicknessMaps' to Lit.hlsl.
public float[] thicknessMaps
// Supplies '_ThicknessRemaps' to Lit.hlsl.
public float[] thicknessRemaps
get { return m_ThicknessMaps; }
get { return m_ThicknessRemaps; }
}
// Supplies '_HalfRcpVariancesAndLerpWeights' to Lit.hlsl.

m_NumProfiles = m_Profiles.Length;
m_TransmissionFlags = 0;
if (m_ThicknessMaps == null)
if (m_ThicknessRemaps == null)
m_ThicknessMaps = new float[maxNumProfiles * 2];
m_ThicknessRemaps = new float[maxNumProfiles * 2];
}
if (m_HalfRcpVariancesAndLerpWeights == null)

m_Profiles[i].lerpWeight = Mathf.Clamp01(m_Profiles[i].lerpWeight);
m_Profiles[i].thicknessMap.x = Mathf.Clamp(m_Profiles[i].thicknessMap.x, 0, m_Profiles[i].thicknessMap.y);
m_Profiles[i].thicknessMap.y = Mathf.Max(m_Profiles[i].thicknessMap.x, m_Profiles[i].thicknessMap.y);
m_Profiles[i].thicknessRemap.x = Mathf.Clamp(m_Profiles[i].thicknessRemap.x, 0, m_Profiles[i].thicknessRemap.y);
m_Profiles[i].thicknessRemap.y = Mathf.Max(m_Profiles[i].thicknessRemap.x, m_Profiles[i].thicknessRemap.y);
m_Profiles[i].UpdateKernelAndVarianceData();
}

{
m_ThicknessMaps[2 * i] = m_Profiles[i].thicknessMap.x;
m_ThicknessMaps[2 * i + 1] = m_Profiles[i].thicknessMap.y - m_Profiles[i].thicknessMap.x;
m_ThicknessRemaps[2 * i] = m_Profiles[i].thicknessRemap.x;
m_ThicknessRemaps[2 * i + 1] = m_Profiles[i].thicknessRemap.y - m_Profiles[i].thicknessRemap.x;
m_HalfRcpWeightedVariances[i] = m_Profiles[i].halfRcpWeightedVariances;
m_HalfRcpWeightedVariances[i] = m_Profiles[i].halfRcpWeightedVariances;
for (int j = 0, n = SubsurfaceScatteringProfile.numSamples; j < n; j++)
{

public readonly GUIContent profileStdDev2 = new GUIContent("Standard deviation #2", "Determines the shape of the 2nd Gaussian filter. Increases the strength and the radius of the blur of the corresponding color channel.");
public readonly GUIContent profileLerpWeight = new GUIContent("Filter interpolation", "Controls linear interpolation between the two Gaussian filters.");
public readonly GUIContent profileTransmission = new GUIContent("Enable transmission", "Toggles simulation of light passing through thin objects. Depends on the thickness of the material.");
public readonly GUIContent profileThicknessScale = new GUIContent("Thickness map", "Remaps the thickness parameter from [0, 1] to the desired range.");
public readonly GUIContent profileThicknessRemap = new GUIContent("Thickness remap", "Remaps the thickness parameter from [0, 1] to the desired range.");
public readonly GUIStyle centeredMiniBoldLabel = new GUIStyle (GUI.skin.label);
}

{
EditorGUI.indentLevel++;
SerializedProperty profileStdDev1 = profile.FindPropertyRelative("stdDev1");
SerializedProperty profileStdDev2 = profile.FindPropertyRelative("stdDev2");
SerializedProperty profileLerpWeight = profile.FindPropertyRelative("lerpWeight");
SerializedProperty profileTransmission = profile.FindPropertyRelative("enableTransmission");
SerializedProperty profileThicknessMap = profile.FindPropertyRelative("thicknessMap");
SerializedProperty profileStdDev1 = profile.FindPropertyRelative("stdDev1");
SerializedProperty profileStdDev2 = profile.FindPropertyRelative("stdDev2");
SerializedProperty profileLerpWeight = profile.FindPropertyRelative("lerpWeight");
SerializedProperty profileTransmission = profile.FindPropertyRelative("enableTransmission");
SerializedProperty profileThicknessRemap = profile.FindPropertyRelative("thicknessRemap");
EditorGUILayout.PropertyField(profileStdDev1, styles.profileStdDev1);
EditorGUILayout.PropertyField(profileStdDev2, styles.profileStdDev2);

Vector2 thicknessMap = profileThicknessMap.vector2Value;
EditorGUILayout.LabelField("Min thickness: ", thicknessMap.x.ToString());
EditorGUILayout.LabelField("Max thickness: ", thicknessMap.y.ToString());
EditorGUILayout.MinMaxSlider(styles.profileThicknessScale, ref thicknessMap.x, ref thicknessMap.y, 0, 10);
profileThicknessMap.vector2Value = thicknessMap;
Vector2 thicknessRemap = profileThicknessRemap.vector2Value;
EditorGUILayout.LabelField("Min thickness: ", thicknessRemap.x.ToString());
EditorGUILayout.LabelField("Max thickness: ", thicknessRemap.y.ToString());
EditorGUILayout.MinMaxSlider(styles.profileThicknessRemap, ref thicknessRemap.x, ref thicknessRemap.y, 0, 10);
profileThicknessRemap.vector2Value = thicknessRemap;
EditorGUILayout.Space();
EditorGUILayout.LabelField(styles.profilePreview0, styles.centeredMiniBoldLabel);

EditorGUILayout.Space();
// Draw the transmittance graph.
m_TransmittanceMaterial.SetColor("_StdDev1", profileStdDev1.colorValue);
m_TransmittanceMaterial.SetColor("_StdDev2", profileStdDev2.colorValue);
m_TransmittanceMaterial.SetFloat("_LerpWeight", profileLerpWeight.floatValue);
m_TransmittanceMaterial.SetVector("_ThicknessMap", profileThicknessMap.vector2Value);
m_TransmittanceMaterial.SetColor("_StdDev1", profileStdDev1.colorValue);
m_TransmittanceMaterial.SetColor("_StdDev2", profileStdDev2.colorValue);
m_TransmittanceMaterial.SetFloat("_LerpWeight", profileLerpWeight.floatValue);
m_TransmittanceMaterial.SetVector("_ThicknessRemap", profileThicknessRemap.vector2Value);
EditorGUI.DrawPreviewTexture(GUILayoutUtility.GetRect(16, 16), m_TransmittanceImages[i], m_TransmittanceMaterial, ScaleMode.ScaleToFit, 16.0f);
EditorGUILayout.Space();

正在加载...
取消
保存