Skip to content

Commit 149264b

Browse files
authored
Merge pull request #190 from EvgeniiG/master
Specify SSS profiles as assets in the material UI
2 parents 65740d6 + 9b70960 commit 149264b

13 files changed

Lines changed: 379 additions & 176 deletions
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &11400000
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 0
6+
m_PrefabParentObject: {fileID: 0}
7+
m_PrefabInternal: {fileID: 0}
8+
m_GameObject: {fileID: 0}
9+
m_Enabled: 1
10+
m_EditorHideFlags: 0
11+
m_Script: {fileID: 11500000, guid: a6e7465350bf0d248b4799d98e18cd24, type: 3}
12+
m_Name: Default SSS Profile
13+
m_EditorClassIdentifier:
14+
stdDev1: {r: 0.3, g: 0.3, b: 0.3, a: 0}
15+
stdDev2: {r: 0.6, g: 0.6, b: 0.6, a: 0}
16+
lerpWeight: 0.5
17+
enableTransmission: 0
18+
thicknessRemap: {x: 0, y: 1}
19+
settingsIndex: 0
20+
m_FilterKernel:
21+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.7609476}
22+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.49358216}
23+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.33642715}
24+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.21256521}
25+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.10326859}
26+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.000000048879357}
27+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: 0.10326859}
28+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: 0.21256521}
29+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: 0.33642715}
30+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: 0.4935822}
31+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: 0.7609475}
32+
m_HalfRcpVariances:
33+
- {x: 5.5555553, y: 5.5555553, z: 5.5555553}
34+
- {x: 1.3888888, y: 1.3888888, z: 1.3888888}
35+
m_HalfRcpWeightedVariances: {x: 2.4691355, y: 2.4691355, z: 2.4691355, w: 2.4691355}

Assets/ScriptableRenderPipeline/HDRenderPipeline/Default SSS Profile.asset.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs

Lines changed: 6 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,12 @@ private class Styles
3232
public readonly GUIContent shadowsAtlasWidth = new GUIContent("Atlas width");
3333
public readonly GUIContent shadowsAtlasHeight = new GUIContent("Atlas height");
3434

35-
// Subsurface Scaterring Settings
36-
public readonly GUIContent[] sssProfiles = new GUIContent[SubsurfaceScatteringSettings.maxNumProfiles] { new GUIContent("Profile #0"), new GUIContent("Profile #1"), new GUIContent("Profile #2"), new GUIContent("Profile #3"), new GUIContent("Profile #4"), new GUIContent("Profile #5"), new GUIContent("Profile #6"), new GUIContent("Profile #7") };
37-
public readonly GUIContent sssProfilePreview0 = new GUIContent("Profile preview");
38-
public readonly GUIContent sssProfilePreview1 = new GUIContent("Shows the fraction of light scattered from the source as radius increases to 1.");
39-
public readonly GUIContent sssProfilePreview2 = new GUIContent("Note that the intensity of the region in the center may be clamped.");
40-
public readonly GUIContent sssTransmittancePreview0 = new GUIContent("Transmittance preview");
41-
public readonly GUIContent sssTransmittancePreview1 = new GUIContent("Shows the fraction of light passing through the object as thickness increases to 1.");
42-
public readonly GUIContent sssNumProfiles = new GUIContent("Number of profiles");
43-
public readonly GUIContent sssProfileStdDev1 = new GUIContent("Standard deviation #1", "Determines the shape of the 1st Gaussian filter. Increases the strength and the radius of the blur of the corresponding color channel.");
44-
public readonly GUIContent sssProfileStdDev2 = 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.");
45-
public readonly GUIContent sssProfileLerpWeight = new GUIContent("Filter interpolation", "Controls linear interpolation between the two Gaussian filters.");
46-
public readonly GUIContent sssProfileTransmission = new GUIContent("Enable transmission", "Toggles simulation of light passing through thin objects. Depends on the thickness of the material.");
47-
public readonly GUIContent sssProfileThicknessRemap = new GUIContent("Thickness remap", "Remaps the thickness parameter from [0, 1] to the desired range.");
48-
public readonly GUIContent sssTexturingMode = new GUIContent("Texturing mode", "Specifies when the diffuse texture should be applied.");
35+
// Subsurface Scattering Settings
36+
public readonly GUIContent[] sssProfiles = new GUIContent[SubsurfaceScatteringSettings.maxNumProfiles] { new GUIContent("Profile #0"), new GUIContent("Profile #1"), new GUIContent("Profile #2"), new GUIContent("Profile #3"), new GUIContent("Profile #4"), new GUIContent("Profile #5"), new GUIContent("Profile #6"), new GUIContent("Profile #7") };
37+
public readonly GUIContent sssNumProfiles = new GUIContent("Number of profiles");
38+
public readonly GUIContent sssTexturingMode = new GUIContent("Texturing mode", "Specifies when the diffuse texture should be applied.");
4939
public readonly GUIContent[] sssTexturingModeOptions = new GUIContent[3] { new GUIContent("Pre-scatter", "Before the blurring pass. Effectively results in the diffuse texture getting blurred together with the lighting."), new GUIContent("Post-scatter", "After the blurring pass. Effectively preserves the sharpness of the diffuse texture."), new GUIContent("Pre- and post-scatter", "Both before and after the blurring pass.") };
5040

51-
public readonly GUIStyle centeredMiniBoldLabel = new GUIStyle(GUI.skin.label);
52-
5341
// Tile pass Settings
5442
public readonly GUIContent tileLightLoopSettings = new GUIContent("Tile Light Loop Settings");
5543
public readonly string[] tileLightLoopDebugTileFlagStrings = new string[] { "Punctual Light", "Area Light", "Env Light"};
@@ -91,13 +79,6 @@ private class Styles
9179
public readonly GUIContent lightingDebugAlbedo = new GUIContent("Lighting Debug Albedo");
9280
public readonly GUIContent lightingDisplaySkyReflection = new GUIContent("Display Sky Reflection");
9381
public readonly GUIContent lightingDisplaySkyReflectionMipmap = new GUIContent("Reflection Mipmap");
94-
95-
public Styles()
96-
{
97-
centeredMiniBoldLabel.alignment = TextAnchor.MiddleCenter;
98-
centeredMiniBoldLabel.fontSize = 10;
99-
centeredMiniBoldLabel.fontStyle = FontStyle.Bold;
100-
}
10182
}
10283

10384
private static Styles s_Styles = null;
@@ -147,10 +128,6 @@ private static Styles styles
147128
SerializedProperty m_Profiles = null;
148129
SerializedProperty m_NumProfiles = null;
149130

150-
// Subsurface Scattering internal data
151-
private Material m_ProfileMaterial, m_TransmittanceMaterial;
152-
private RenderTexture[] m_ProfileImages, m_TransmittanceImages;
153-
154131
private void InitializeProperties()
155132
{
156133
// Global debug
@@ -185,22 +162,8 @@ private void InitializeProperties()
185162

186163
// Subsurface Scattering Settings
187164
m_TexturingMode = FindProperty(x => x.sssSettings.texturingMode);
188-
m_Profiles = FindProperty(x => x.sssSettings.profiles);
189-
m_NumProfiles = m_Profiles.FindPropertyRelative("Array.size");
190-
}
191-
192-
void InitializeSSS()
193-
{
194-
m_ProfileMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/DrawGaussianProfile");
195-
m_TransmittanceMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/DrawTransmittanceGraph");
196-
m_ProfileImages = new RenderTexture[SubsurfaceScatteringSettings.maxNumProfiles];
197-
m_TransmittanceImages = new RenderTexture[SubsurfaceScatteringSettings.maxNumProfiles];
198-
199-
for (int i = 0; i < SubsurfaceScatteringSettings.maxNumProfiles; i++)
200-
{
201-
m_ProfileImages[i] = new RenderTexture(256, 256, 0, RenderTextureFormat.DefaultHDR);
202-
m_TransmittanceImages[i] = new RenderTexture(16, 256, 0, RenderTextureFormat.DefaultHDR);
203-
}
165+
m_Profiles = FindProperty(x => x.sssSettings.profiles);
166+
m_NumProfiles = m_Profiles.FindPropertyRelative("Array.size");
204167
}
205168

206169
SerializedProperty FindProperty<TValue>(Expression<Func<HDRenderPipeline, TValue>> expr)
@@ -383,56 +346,6 @@ private void SssSettingsUI(HDRenderPipeline pipe)
383346
{
384347
SerializedProperty profile = m_Profiles.GetArrayElementAtIndex(i);
385348
EditorGUILayout.PropertyField(profile, styles.sssProfiles[i]);
386-
387-
if (profile.isExpanded)
388-
{
389-
EditorGUI.indentLevel++;
390-
391-
SerializedProperty profileStdDev1 = profile.FindPropertyRelative("stdDev1");
392-
SerializedProperty profileStdDev2 = profile.FindPropertyRelative("stdDev2");
393-
SerializedProperty profileLerpWeight = profile.FindPropertyRelative("lerpWeight");
394-
SerializedProperty profileTransmission = profile.FindPropertyRelative("enableTransmission");
395-
SerializedProperty profileThicknessRemap = profile.FindPropertyRelative("thicknessRemap");
396-
397-
EditorGUILayout.PropertyField(profileStdDev1, styles.sssProfileStdDev1);
398-
EditorGUILayout.PropertyField(profileStdDev2, styles.sssProfileStdDev2);
399-
EditorGUILayout.PropertyField(profileLerpWeight, styles.sssProfileLerpWeight);
400-
EditorGUILayout.PropertyField(profileTransmission, styles.sssProfileTransmission);
401-
402-
Vector2 thicknessRemap = profileThicknessRemap.vector2Value;
403-
EditorGUILayout.LabelField("Min thickness: ", thicknessRemap.x.ToString());
404-
EditorGUILayout.LabelField("Max thickness: ", thicknessRemap.y.ToString());
405-
EditorGUILayout.MinMaxSlider(styles.sssProfileThicknessRemap, ref thicknessRemap.x, ref thicknessRemap.y, 0, 10);
406-
profileThicknessRemap.vector2Value = thicknessRemap;
407-
408-
EditorGUILayout.Space();
409-
EditorGUILayout.LabelField(styles.sssProfilePreview0, styles.centeredMiniBoldLabel);
410-
EditorGUILayout.LabelField(styles.sssProfilePreview1, EditorStyles.centeredGreyMiniLabel);
411-
EditorGUILayout.LabelField(styles.sssProfilePreview2, EditorStyles.centeredGreyMiniLabel);
412-
EditorGUILayout.Space();
413-
414-
// Draw the profile.
415-
m_ProfileMaterial.SetColor("_StdDev1", profileStdDev1.colorValue);
416-
m_ProfileMaterial.SetColor("_StdDev2", profileStdDev2.colorValue);
417-
m_ProfileMaterial.SetFloat("_LerpWeight", profileLerpWeight.floatValue);
418-
EditorGUI.DrawPreviewTexture(GUILayoutUtility.GetRect(256, 256), m_ProfileImages[i], m_ProfileMaterial, ScaleMode.ScaleToFit, 1.0f);
419-
420-
EditorGUILayout.Space();
421-
EditorGUILayout.LabelField(styles.sssTransmittancePreview0, styles.centeredMiniBoldLabel);
422-
EditorGUILayout.LabelField(styles.sssTransmittancePreview1, EditorStyles.centeredGreyMiniLabel);
423-
EditorGUILayout.Space();
424-
425-
// Draw the transmittance graph.
426-
m_TransmittanceMaterial.SetColor("_StdDev1", profileStdDev1.colorValue);
427-
m_TransmittanceMaterial.SetColor("_StdDev2", profileStdDev2.colorValue);
428-
m_TransmittanceMaterial.SetFloat("_LerpWeight", profileLerpWeight.floatValue);
429-
m_TransmittanceMaterial.SetVector("_ThicknessRemap", profileThicknessRemap.vector2Value);
430-
EditorGUI.DrawPreviewTexture(GUILayoutUtility.GetRect(16, 16), m_TransmittanceImages[i], m_TransmittanceMaterial, ScaleMode.ScaleToFit, 16.0f);
431-
432-
EditorGUILayout.Space();
433-
434-
EditorGUI.indentLevel--;
435-
}
436349
}
437350

438351
EditorGUI.indentLevel--;
@@ -605,7 +518,6 @@ private void TextureSettingsUI(HDRenderPipeline renderContext)
605518
public void OnEnable()
606519
{
607520
InitializeProperties();
608-
InitializeSSS();
609521
}
610522

611523
public override void OnInspectorGUI()

Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.asset

Lines changed: 50 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ MonoBehaviour:
1515
type: 2}
1616
globalDebugSettings:
1717
debugOverlayRatio: 0.33
18-
displayMaterialDebug: 0
19-
displayRenderingDebug: 0
18+
displayMaterialDebug: 1
19+
displayRenderingDebug: 1
2020
displayLightingDebug: 0
2121
materialDebugSettings:
2222
debugViewMaterial: 0
@@ -28,6 +28,8 @@ MonoBehaviour:
2828
overrideSmoothness: 0
2929
overrideSmoothnessValue: 0.5
3030
debugLightingAlbedo: {r: 0.5, g: 0.5, b: 0.5, a: 1}
31+
displaySkyReflection: 0
32+
skyReflectionMipmap: 0
3133
renderingDebugSettings:
3234
displayOpaqueObjects: 1
3335
displayTransparentObjects: 1
@@ -38,30 +40,15 @@ MonoBehaviour:
3840
useDepthPrepass: 0
3941
sssSettings:
4042
numProfiles: 1
43+
texturingMode: 0
4144
transmissionFlags: 0
4245
profiles:
43-
- stdDev1: {r: 0.3, g: 0.3, b: 0.3, a: 0}
44-
stdDev2: {r: 0.6, g: 0.6, b: 0.6, a: 0}
45-
lerpWeight: 0.5
46-
enableTransmission: 0
47-
thicknessRemap: {x: 0, y: 3}
48-
m_FilterKernel:
49-
- {x: 0.14285715, y: 0.14285715, z: 0.14285715, w: -0.6594821}
50-
- {x: 0.14285715, y: 0.14285715, z: 0.14285715, w: -0.3561445}
51-
- {x: 0.14285715, y: 0.14285715, z: 0.14285715, w: -0.16454786}
52-
- {x: 0.14285715, y: 0.14285715, z: 0.14285715, w: -0.000000048879357}
53-
- {x: 0.14285715, y: 0.14285715, z: 0.14285715, w: 0.16454786}
54-
- {x: 0.14285715, y: 0.14285715, z: 0.14285715, w: 0.35614443}
55-
- {x: 0.14285715, y: 0.14285715, z: 0.14285715, w: 0.659482}
56-
m_HalfRcpVariances:
57-
- {x: 5.5555553, y: 5.5555553, z: 5.5555553}
58-
- {x: 1.3888888, y: 1.3888888, z: 1.3888888}
59-
m_HalfRcpWeightedVariances: {x: 2.4691355, y: 2.4691355, z: 2.4691355, w: 2.4691355}
46+
- {fileID: 11400000, guid: 09521380d86baee43bf09b32473ea5f3, type: 2}
6047
thicknessRemaps:
6148
- 0
62-
- 3
63-
- 0
49+
- 1
6450
- 0
51+
- 1
6552
- 0
6653
- 0
6754
- 0
@@ -77,8 +64,8 @@ MonoBehaviour:
7764
halfRcpVariancesAndLerpWeights:
7865
- {x: 5.5555553, y: 5.5555553, z: 5.5555553, w: 0.5}
7966
- {x: 1.3888888, y: 1.3888888, z: 1.3888888, w: 0.5}
80-
- {x: 0, y: 0, z: 0, w: 0}
81-
- {x: 0, y: 0, z: 0, w: 0}
67+
- {x: 5.5555553, y: 5.5555553, z: 5.5555553, w: 0.5}
68+
- {x: 1.3888888, y: 1.3888888, z: 1.3888888, w: 0.5}
8269
- {x: 0, y: 0, z: 0, w: 0}
8370
- {x: 0, y: 0, z: 0, w: 0}
8471
- {x: 0, y: 0, z: 0, w: 0}
@@ -93,21 +80,53 @@ MonoBehaviour:
9380
- {x: 0, y: 0, z: 0, w: 0}
9481
halfRcpWeightedVariances:
9582
- {x: 2.4691355, y: 2.4691355, z: 2.4691355, w: 2.4691355}
96-
- {x: 0, y: 0, z: 0, w: 0}
83+
- {x: 2.4691355, y: 2.4691355, z: 2.4691355, w: 2.4691355}
9784
- {x: 0, y: 0, z: 0, w: 0}
9885
- {x: 0, y: 0, z: 0, w: 0}
9986
- {x: 0, y: 0, z: 0, w: 0}
10087
- {x: 0, y: 0, z: 0, w: 0}
10188
- {x: 0, y: 0, z: 0, w: 0}
10289
- {x: 0, y: 0, z: 0, w: 0}
10390
filterKernels:
104-
- {x: 0.14285715, y: 0.14285715, z: 0.14285715, w: -0.6594821}
105-
- {x: 0.14285715, y: 0.14285715, z: 0.14285715, w: -0.3561445}
106-
- {x: 0.14285715, y: 0.14285715, z: 0.14285715, w: -0.16454786}
107-
- {x: 0.14285715, y: 0.14285715, z: 0.14285715, w: -0.000000048879357}
108-
- {x: 0.14285715, y: 0.14285715, z: 0.14285715, w: 0.16454786}
109-
- {x: 0.14285715, y: 0.14285715, z: 0.14285715, w: 0.35614443}
110-
- {x: 0.14285715, y: 0.14285715, z: 0.14285715, w: 0.659482}
91+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.7609476}
92+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.49358216}
93+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.33642715}
94+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.21256521}
95+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.10326859}
96+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.000000048879357}
97+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: 0.10326859}
98+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: 0.21256521}
99+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: 0.33642715}
100+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: 0.4935822}
101+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: 0.7609475}
102+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.7609476}
103+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.49358216}
104+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.33642715}
105+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.21256521}
106+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.10326859}
107+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: -0.000000048879357}
108+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: 0.10326859}
109+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: 0.21256521}
110+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: 0.33642715}
111+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: 0.4935822}
112+
- {x: 0.09090909, y: 0.09090909, z: 0.09090909, w: 0.7609475}
113+
- {x: 0, y: 0, z: 0, w: 0}
114+
- {x: 0, y: 0, z: 0, w: 0}
115+
- {x: 0, y: 0, z: 0, w: 0}
116+
- {x: 0, y: 0, z: 0, w: 0}
117+
- {x: 0, y: 0, z: 0, w: 0}
118+
- {x: 0, y: 0, z: 0, w: 0}
119+
- {x: 0, y: 0, z: 0, w: 0}
120+
- {x: 0, y: 0, z: 0, w: 0}
121+
- {x: 0, y: 0, z: 0, w: 0}
122+
- {x: 0, y: 0, z: 0, w: 0}
123+
- {x: 0, y: 0, z: 0, w: 0}
124+
- {x: 0, y: 0, z: 0, w: 0}
125+
- {x: 0, y: 0, z: 0, w: 0}
126+
- {x: 0, y: 0, z: 0, w: 0}
127+
- {x: 0, y: 0, z: 0, w: 0}
128+
- {x: 0, y: 0, z: 0, w: 0}
129+
- {x: 0, y: 0, z: 0, w: 0}
111130
- {x: 0, y: 0, z: 0, w: 0}
112131
- {x: 0, y: 0, z: 0, w: 0}
113132
- {x: 0, y: 0, z: 0, w: 0}

Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ protected override IRenderPipeline InternalCreatePipeline()
8080
public SubsurfaceScatteringSettings sssSettings = new SubsurfaceScatteringSettings();
8181

8282
[SerializeField]
83-
ShadowSettings m_ShadowSettings = ShadowSettings.Default;
84-
[SerializeField] TextureSettings m_TextureSettings = TextureSettings.Default;
83+
ShadowSettings m_ShadowSettings = ShadowSettings.Default;
84+
[SerializeField]
85+
TextureSettings m_TextureSettings = TextureSettings.Default;
8586

8687
public ShadowSettings shadowSettings { get { return m_ShadowSettings; } }
8788
public TextureSettings textureSettings { get { return m_TextureSettings; } set { m_TextureSettings = value; } }
@@ -117,7 +118,7 @@ public SkySettings skySettingsToUse
117118
return m_SkySettings;
118119
}
119120
}
120-
121+
121122
public void ApplyDebugSettings()
122123
{
123124
m_ShadowSettings.enabled = globalDebugSettings.lightingDebugSettings.enableShadows;
@@ -275,6 +276,10 @@ private GlobalDebugSettings globalDebugSettings
275276
get { return m_Owner.globalDebugSettings; }
276277
}
277278

279+
public SubsurfaceScatteringSettings sssSettings
280+
{
281+
get { return m_Owner.sssSettings; }
282+
}
278283
public HDRenderPipelineInstance(HDRenderPipeline owner)
279284
{
280285
m_Owner = owner;

0 commit comments

Comments
 (0)