public const int numSamples = 7 ; // Must be an odd number
[SerializeField, ColorUsage(false, true, 0.05f, 2.0f, 1.0f, 1.0f)]
public Color stdDev1 ;
public Color stdDev1 ;
public Color stdDev2 ;
public Color stdDev2 ;
public float lerpWeight ;
public float lerpWeight ;
public bool enableTransmission ;
public bool enableTransmission ;
public float thicknessScale ;
public Vector2 thicknessRemap ;
Vector4 [ ] m_FilterKernel ;
Vector4 [ ] m_FilterKernel ;
Vector3 [ ] m_HalfRcpVariances ;
Vector3 [ ] m_HalfRcpVariances ;
Vector4 m_HalfRcpWeightedVariances ;
Vector4 m_HalfRcpWeightedVariances ;
// --- Public Methods ---
stdDev2 = new Color ( 0.6f , 0.6f , 0.6f , 0.0f ) ;
lerpWeight = 0.5f ;
enableTransmission = false ;
thicknessScale = 3.0f ;
thicknessRemap = new Vector2 ( 0 , 3 ) ;
UpdateKernelAndVarianceData ( ) ;
}
[SerializeField]
SubsurfaceScatteringProfile [ ] m_Profiles ;
[SerializeField]
float [ ] m_ThicknessScale s ;
float [ ] m_ThicknessRemap s ;
[SerializeField]
Vector4 [ ] m_HalfRcpVariancesAndLerpWeights ;
[SerializeField]
get { return m_TransmissionFlags ; }
}
// Supplies '_ThicknessScale s' to Lit.hlsl.
public float [ ] thicknessScale s
// Supplies '_ThicknessRemap s' to Lit.hlsl.
public float [ ] thicknessRemap s
get { return m_ThicknessScale s ; }
get { return m_ThicknessRemap s ; }
}
// Supplies '_HalfRcpVariancesAndLerpWeights' to Lit.hlsl.
Array . Resize ( ref m_Profiles , maxNumProfiles ) ;
}
m_NumProfiles = m_Profiles . Length ;
m_NumProfiles = m_Profiles . Length ;
if ( m_ThicknessScale s = = null )
if ( m_ThicknessRemap s = = null )
m_ThicknessScale s = new float [ maxNumProfiles ] ;
m_ThicknessRemap s = new float [ maxNumProfiles * 2 ] ;
}
if ( m_HalfRcpVariancesAndLerpWeights = = null )
m_Profiles [ i ] . lerpWeight = Mathf . Clamp01 ( m_Profiles [ i ] . lerpWeight ) ;
m_Profiles [ i ] . thicknessScale = Mathf . Max ( 0.0f , m_Profiles [ i ] . thicknessScale ) ;
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_ThicknessScales [ i ] = m_Profiles [ i ] . thicknessScale ;
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 scale" , "Linearly scales the object thickness which affects the amount of transmitted lighting ." ) ;
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 ) ;
}
if ( s_Styles = = null )
{
s_Styles = new Styles ( ) ;
s_Styles . centeredMiniBoldLabel . alignment = TextAnchor . MiddleCenter ;
s_Styles . centeredMiniBoldLabel . fontSize = 1 0 ;
s_Styles . centeredMiniBoldLabel . fontStyle = FontStyle . Bold ;
s_Styles . centeredMiniBoldLabel . alignment = TextAnchor . MiddleCenter ;
s_Styles . centeredMiniBoldLabel . fontSize = 1 0 ;
s_Styles . centeredMiniBoldLabel . fontStyle = FontStyle . Bold ;
return s_Styles ;
}
}
SerializedProperty profileStdDev2 = profile . FindPropertyRelative ( "stdDev2" ) ;
SerializedProperty profileLerpWeight = profile . FindPropertyRelative ( "lerpWeight" ) ;
SerializedProperty profileTransmission = profile . FindPropertyRelative ( "enableTransmission" ) ;
SerializedProperty profileThicknessScale = profile . FindPropertyRelative ( "thicknessScale" ) ;
SerializedProperty profileThicknessRemap = profile . FindPropertyRelative ( "thicknessRemap" ) ;
EditorGUILayout . PropertyField ( profileStdDev1 , styles . profileStdDev1 ) ;
EditorGUILayout . PropertyField ( profileStdDev2 , styles . profileStdDev2 ) ;
EditorGUILayout . PropertyField ( profileLerpWeight , styles . profileLerpWeight ) ;
EditorGUILayout . PropertyField ( profileTransmission , styles . profileTransmission ) ;
EditorGUILayout . PropertyField ( profileStdDev1 , styles . profileStdDev1 ) ;
EditorGUILayout . PropertyField ( profileStdDev2 , styles . profileStdDev2 ) ;
EditorGUILayout . PropertyField ( profileLerpWeight , styles . profileLerpWeight ) ;
EditorGUILayout . PropertyField ( profileTransmission , styles . profileTransmission ) ;
EditorGUILayout . PropertyField ( profileThicknessScale , styles . profileThicknessScale ) ;
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 , 1 0 ) ;
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 . SetFloat ( "_ThicknessScale" , profileThicknessScale . float Value ) ;
m_TransmittanceMaterial . SetColor ( "_StdDev1" , profileStdDev1 . colorValue ) ;
m_TransmittanceMaterial . SetColor ( "_StdDev2" , profileStdDev2 . colorValue ) ;
m_TransmittanceMaterial . SetFloat ( "_LerpWeight" , profileLerpWeight . floatValue ) ;
m_TransmittanceMaterial . SetVector ( "_ThicknessRemap" , profileThicknessRemap . vector2 Value ) ;
EditorGUI . DrawPreviewTexture ( GUILayoutUtility . GetRect ( 1 6 , 1 6 ) , m_TransmittanceImages [ i ] , m_TransmittanceMaterial , ScaleMode . ScaleToFit , 1 6.0f ) ;
EditorGUILayout . Space ( ) ;