浏览代码

Update UI for diffusion profile + convert fresnel0 to IOR in UI

/main
Sebastien Lagarde 7 年前
当前提交
926a5691
共有 6 个文件被更改,包括 42 次插入26 次删除
  1. 1
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/CommonMaterial.hlsl
  2. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/DiffusionProfile/DiffusionProfileSettingsEditor.Styles.cs
  3. 16
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/DiffusionProfile/DiffusionProfileSettingsEditor.cs
  4. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/DiffusionProfile/DiffusionProfileSettings.cs
  5. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/DiffusionProfile/DiffusionProfileSettings.cs.hlsl
  6. 30
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/Default Diffusion Profile Settings.asset

1
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/CommonMaterial.hlsl


}
// Assume air interface for top
// Note: Don't handle the case fresnel0 == 1
real Fresnel0ToIor(real fresnel0)
{
real sqrtF0 = sqrt(fresnel0);

6
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/DiffusionProfile/DiffusionProfileSettingsEditor.Styles.cs


public readonly GUIContent profileMinMaxThickness = new GUIContent("Min-Max Thickness (mm)", "Shows the values of the thickness remap below (in millimeters).");
public readonly GUIContent profileThicknessRemap = new GUIContent("Thickness Remap (mm)", "Remaps the thickness parameter from [0, 1] to the desired range (in millimeters).");
public readonly GUIContent profileWorldScale = new GUIContent("World Scale", "Size of the world unit in meters.");
public readonly GUIContent profileFresnel0 = new GUIContent("Specular", "Fraction of light reflected at the normal angle of incidence. Typical skin value is 0.028");
public readonly GUIContent profileIor = new GUIContent("Index of Refraction", "Index of refraction. 1.4 for skin. 1.5 for most other material.");
// Jimenez SSS Model
public readonly GUIContent profileScatterDistance1 = new GUIContent("Scattering Distance #1", "The radius (in centimeters) of the 1st Gaussian filter, one per color channel. Alpha is ignored. The blur is energy-preserving, so a wide filter results in a large area with small contributions of individual samples. Smaller values increase the sharpness.");
public readonly GUIContent profileScatterDistance2 = new GUIContent("Scattering Distance #2", "The radius (in centimeters) of the 2nd Gaussian filter, one per color channel. Alpha is ignored. The blur is energy-preserving, so a wide filter results in a large area with small contributions of individual samples. Smaller values increase the sharpness.");

public readonly GUIContent SubsurfaceScatteringLabel = new GUIContent("Subsurface Scattering only");
public readonly GUIContent TransmissionLabel = new GUIContent("Transmission only");
public Styles()
{

16
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/DiffusionProfile/DiffusionProfileSettingsEditor.cs


internal SerializedProperty transmissionMode;
internal SerializedProperty thicknessRemap;
internal SerializedProperty worldScale;
internal SerializedProperty fresnel0;
internal SerializedProperty ior;
// Old SSS Model >>>
internal SerializedProperty scatterDistance1;

transmissionMode = rp.Find(x => x.transmissionMode),
thicknessRemap = rp.Find(x => x.thicknessRemap),
worldScale = rp.Find(x => x.worldScale),
fresnel0 = rp.Find(x => x.fresnel0),
ior = rp.Find(x => x.ior),
scatterDistance1 = rp.Find(x => x.scatterDistance1),
scatterDistance2 = rp.Find(x => x.scatterDistance2),

EditorGUILayout.PropertyField(profile.lerpWeight, s_Styles.profileLerpWeight);
}
EditorGUILayout.PropertyField(profile.worldScale, s_Styles.profileWorldScale);
EditorGUILayout.Space();
EditorGUILayout.LabelField(s_Styles.SubsurfaceScatteringLabel, EditorStyles.boldLabel);
EditorGUILayout.Slider(profile.ior, 1.0f, 2.0f, s_Styles.profileIor);
EditorGUILayout.Space();
EditorGUILayout.LabelField(s_Styles.TransmissionLabel, EditorStyles.boldLabel);
profile.transmissionMode.intValue = EditorGUILayout.Popup(s_Styles.profileTransmissionMode, profile.transmissionMode.intValue, s_Styles.transmissionModeOptions);
EditorGUILayout.PropertyField(profile.transmissionTint, s_Styles.profileTransmissionTint);

profile.thicknessRemap.vector2Value = thicknessRemap;
EditorGUILayout.PropertyField(profile.worldScale, s_Styles.profileWorldScale);
EditorGUILayout.Slider(profile.fresnel0, 0.0f, 0.1f, s_Styles.profileFresnel0);
EditorGUILayout.Space();
EditorGUILayout.LabelField(s_Styles.profilePreview0, s_Styles.centeredMiniBoldLabel);

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/DiffusionProfile/DiffusionProfileSettings.cs


public TransmissionMode transmissionMode;
public Vector2 thicknessRemap; // X = min, Y = max (in millimeters)
public float worldScale; // Size of the world unit in meters
public float fresnel0; // Fresnel0, 0.028 for skin
public float ior; // 1.4 for skin (mean ~0.028)
// Old SSS Model >>>
[ColorUsage(false, true)]

transmissionMode = TransmissionMode.None;
thicknessRemap = new Vector2(0f, 5f);
worldScale = 1f;
fresnel0 = 0.028f; // TYpical value for skin specular reflectance
ior = 1.4f; // TYpical value for skin specular reflectance
// Old SSS Model >>>
scatterDistance1 = new Color(0.3f, 0.3f, 0.3f, 0f);

thicknessRemap.y = Mathf.Max(thicknessRemap.y, 0f);
thicknessRemap.x = Mathf.Clamp(thicknessRemap.x, 0f, thicknessRemap.y);
worldScale = Mathf.Max(worldScale, 0.001f);
fresnel0 = Mathf.Clamp(fresnel0, 0.0f, 0.1f);
ior = Mathf.Clamp(ior, 1.0f, 2.0f);
// Old SSS Model >>>
scatterDistance1 = new Color

worldScales[i] = new Vector4(profiles[p].worldScale, 1.0f / profiles[p].worldScale, 0f, 0f);
shapeParams[i] = profiles[p].shapeParam;
shapeParams[i].w = profiles[p].maxRadius;
transmissionTintsAndFresnel0[i] = new Vector4(profiles[p].transmissionTint.r * 0.25f, profiles[p].transmissionTint.g * 0.25f, profiles[p].transmissionTint.b * 0.25f, profiles[p].fresnel0); // Premultiplied
// Convert ior to fresnel0
float fresnel0 = (profiles[p].ior - 1.0f) / (profiles[p].ior + 1.0f);
fresnel0 *= fresnel0; // square
transmissionTintsAndFresnel0[i] = new Vector4(profiles[p].transmissionTint.r * 0.25f, profiles[p].transmissionTint.g * 0.25f, profiles[p].transmissionTint.b * 0.25f, fresnel0); // Premultiplied
for (int j = 0, n = DiffusionProfileConstants.SSS_N_SAMPLES_NEAR_FIELD; j < n; j++)
{

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/DiffusionProfile/DiffusionProfileSettings.cs.hlsl


// This file was automatically generated. Please don't edit by hand.
//
#ifndef SUBSURFACESCATTERINGSETTINGS_CS_HLSL
#define SUBSURFACESCATTERINGSETTINGS_CS_HLSL
#ifndef DIFFUSIONPROFILESETTINGS_CS_HLSL
#define DIFFUSIONPROFILESETTINGS_CS_HLSL
//
// UnityEngine.Experimental.Rendering.HDPipeline.DiffusionProfileConstants: static fields
//

30
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/Default Diffusion Profile Settings.asset


transmissionMode: 2
thicknessRemap: {x: 0, y: 8.152544}
worldScale: 1
fresnel0: 0
ior: 1.4
scatterDistance1: {r: 0.3019608, g: 0.20000002, b: 0.20000002, a: 0}
scatterDistance2: {r: 0.6, g: 0.20000002, b: 0.20000002, a: 0}
lerpWeight: 0.5

transmissionMode: 1
thicknessRemap: {x: 0, y: 0.2873168}
worldScale: 1
fresnel0: 0
ior: 1.4
scatterDistance1: {r: 0.3, g: 0.3, b: 0.3, a: 0}
scatterDistance2: {r: 0.5, g: 0.5, b: 0.5, a: 0}
lerpWeight: 0.5

transmissionMode: 0
thicknessRemap: {x: 0, y: 5}
worldScale: 1
fresnel0: 0
ior: 1.4
scatterDistance1: {r: 0.3, g: 0.3, b: 0.3, a: 0}
scatterDistance2: {r: 0.5, g: 0.5, b: 0.5, a: 0}
lerpWeight: 1

transmissionMode: 0
thicknessRemap: {x: 0, y: 5}
worldScale: 1
fresnel0: 0
ior: 1.4
scatterDistance1: {r: 0.3, g: 0.3, b: 0.3, a: 0}
scatterDistance2: {r: 0.5, g: 0.5, b: 0.5, a: 0}
lerpWeight: 1

transmissionMode: 0
thicknessRemap: {x: 0, y: 5}
worldScale: 1
fresnel0: 0
ior: 1.4
scatterDistance1: {r: 0.3, g: 0.3, b: 0.3, a: 0}
scatterDistance2: {r: 0.5, g: 0.5, b: 0.5, a: 0}
lerpWeight: 1

transmissionMode: 0
thicknessRemap: {x: 0, y: 5}
worldScale: 1
fresnel0: 0
ior: 1.4
scatterDistance1: {r: 0.3, g: 0.3, b: 0.3, a: 0}
scatterDistance2: {r: 0.5, g: 0.5, b: 0.5, a: 0}
lerpWeight: 1

transmissionMode: 0
thicknessRemap: {x: 0, y: 5}
worldScale: 1
fresnel0: 0
ior: 1.4
scatterDistance1: {r: 0.3, g: 0.3, b: 0.3, a: 0}
scatterDistance2: {r: 0.5, g: 0.5, b: 0.5, a: 0}
lerpWeight: 1

transmissionMode: 0
thicknessRemap: {x: 0, y: 5}
worldScale: 1
fresnel0: 0
ior: 1.4
scatterDistance1: {r: 0.3, g: 0.3, b: 0.3, a: 0}
scatterDistance2: {r: 0.5, g: 0.5, b: 0.5, a: 0}
lerpWeight: 1

transmissionMode: 0
thicknessRemap: {x: 0, y: 5}
worldScale: 1
fresnel0: 0
ior: 1.4
scatterDistance1: {r: 0.3, g: 0.3, b: 0.3, a: 0}
scatterDistance2: {r: 0.5, g: 0.5, b: 0.5, a: 0}
lerpWeight: 1

transmissionMode: 0
thicknessRemap: {x: 0, y: 5}
worldScale: 1
fresnel0: 0
ior: 1.4
scatterDistance1: {r: 0.3, g: 0.3, b: 0.3, a: 0}
scatterDistance2: {r: 0.5, g: 0.5, b: 0.5, a: 0}
lerpWeight: 1

transmissionMode: 0
thicknessRemap: {x: 0, y: 5}
worldScale: 1
fresnel0: 0
ior: 1.4
scatterDistance1: {r: 0.3, g: 0.3, b: 0.3, a: 0}
scatterDistance2: {r: 0.5, g: 0.5, b: 0.5, a: 0}
lerpWeight: 1

transmissionMode: 0
thicknessRemap: {x: 0, y: 5}
worldScale: 1
fresnel0: 0
ior: 1.4
scatterDistance1: {r: 0.3, g: 0.3, b: 0.3, a: 0}
scatterDistance2: {r: 0.5, g: 0.5, b: 0.5, a: 0}
lerpWeight: 1

transmissionMode: 0
thicknessRemap: {x: 0, y: 5}
worldScale: 1
fresnel0: 0
ior: 1.4
scatterDistance1: {r: 0.3, g: 0.3, b: 0.3, a: 0}
scatterDistance2: {r: 0.5, g: 0.5, b: 0.5, a: 0}
lerpWeight: 1

transmissionMode: 0
thicknessRemap: {x: 0, y: 5}
worldScale: 1
fresnel0: 0
ior: 1.4
scatterDistance1: {r: 0.3, g: 0.3, b: 0.3, a: 0}
scatterDistance2: {r: 0.5, g: 0.5, b: 0.5, a: 0}
lerpWeight: 1

transmissionMode: 0
thicknessRemap: {x: 0, y: 5}
worldScale: 1
fresnel0: 0
ior: 1.4
scatterDistance1: {r: 0.3, g: 0.3, b: 0.3, a: 0}
scatterDistance2: {r: 0.5, g: 0.5, b: 0.5, a: 0}
lerpWeight: 1
正在加载...
取消
保存