浏览代码

Change selection of SSS method from dynamic to static

/main
sebastienlagarde 7 年前
当前提交
87474f24
共有 11 个文件被更改,包括 17 次插入31 次删除
  1. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/SubsurfaceScattering/SubsurfaceScatteringSettingsEditor.Styles.cs
  2. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/SubsurfaceScattering/SubsurfaceScatteringSettingsEditor.cs
  3. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs
  4. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs
  5. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl
  6. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/SubsurfaceScattering/SubsurfaceScattering.hlsl
  7. 7
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs
  8. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/SubsurfaceScattering/SubsurfaceScatteringSettings.cs
  9. 10
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/SceneSettings/Resources/DrawTransmittanceGraph.shader
  10. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderConfig.cs
  11. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderConfig.cs.hlsl

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/SubsurfaceScattering/SubsurfaceScatteringSettingsEditor.Styles.cs


// TODO: missing tooltips
sealed class Styles
{
public readonly GUIContent useDisneySSS = new GUIContent("Use Disney SSS");
public readonly GUIContent profilePreview0 = new GUIContent("Profile Preview");
public readonly GUIContent profilePreview1 = new GUIContent("Shows the fraction of light scattered from the source (center).");
public readonly GUIContent profilePreview2 = new GUIContent("The distance to the boundary of the image corresponds to the Max Radius.");

6
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/SubsurfaceScattering/SubsurfaceScatteringSettingsEditor.cs


}
}
SerializedProperty m_UseDisneySSS;
List<Profile> m_Profiles;
Material m_ProfileMaterial;

int count = SssConstants.SSS_N_PROFILES - 1;
m_Profiles = new List<Profile>();
m_UseDisneySSS = properties.Find(x => x.useDisneySSS);
var serializedProfiles = properties.Find(x => x.profiles);
for (int i = 0; i < count; i++)

serializedObject.Update();
EditorGUILayout.PropertyField(m_UseDisneySSS, s_Styles.useDisneySSS);
bool useDisneySSS = m_UseDisneySSS.boolValue;
bool useDisneySSS = ShaderConfig.k_UseDisneySSS == 1;
for (int i = 0; i < m_Profiles.Count; i++)
{

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


void Resize(HDCamera hdCamera)
{
var camera = hdCamera.camera;
// TODO: Detect if renderdoc just load and force a resize in this case, as often renderdoc require to realloc resource.
// TODO: This is the wrong way to handle resize/allocation. We can have several different camera here, mean that the loop on camera will allocate and deallocate

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs


public static readonly int _SkyTexture = Shader.PropertyToID("_SkyTexture");
public static readonly int _SkyTextureMipCount = Shader.PropertyToID("_SkyTextureMipCount");
public static readonly int _UseDisneySSS = Shader.PropertyToID("_UseDisneySSS");
public static readonly int _EnableSSSAndTransmission = Shader.PropertyToID("_EnableSSSAndTransmission");
public static readonly int _TexturingModeFlags = Shader.PropertyToID("_TexturingModeFlags");
public static readonly int _TransmissionFlags = Shader.PropertyToID("_TransmissionFlags");

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl


bsdfData.thickness = _ThicknessRemaps[subsurfaceProfile].x + _ThicknessRemaps[subsurfaceProfile].y * thickness;
bsdfData.useThickObjectMode = transmissionMode != SSS_TRSM_MODE_THIN;
if (_UseDisneySSS != 0)
{
#if SHADEROPTIONS_USE_DISNEY_SSS
}
else
{
#else
bsdfData.transmittance = ComputeTransmittanceJimenez(_HalfRcpVariancesAndWeights[subsurfaceProfile][0].rgb,
_HalfRcpVariancesAndWeights[subsurfaceProfile][0].a,
_HalfRcpVariancesAndWeights[subsurfaceProfile][1].rgb,

}
#endif
}
}

float3 boxOuterDistance = lightData.influenceExtents;
float projectionDistance = BoxRayIntersectSimple(positionLS, dirLS, -boxOuterDistance, boxOuterDistance);
projectionDistance = max(projectionDistance, lightData.minProjectionDistance); // Setup projection to infinite if requested (mean no projection shape)
// No need to normalize for fetching cubemap
// We can reuse dist calculate in LS directly in WS as there is no scaling. Also the offset is already include in lightData.positionWS
R = (positionWS + projectionDistance * R) - lightData.positionWS;

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/SubsurfaceScattering/SubsurfaceScattering.hlsl


float _TexturingModeFlags; // 1 bit/profile; 0 = PreAndPostScatter, 1 = PostScatter
float _TransmissionFlags; // 2 bit/profile; 0 = inf. thick, 1 = thin, 2 = regular
// Old SSS Model >>>
uint _UseDisneySSS;
float4 _HalfRcpVariancesAndWeights[SSS_N_PROFILES][2]; // 2x Gaussians in RGB, A is interpolation weights
// <<< Old SSS Model
// Use float4 to avoid any packing issue between compute and pixel shaders

7
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs


{
// Broadcast SSS parameters to all shaders.
cmd.SetGlobalInt(HDShaderIDs._EnableSSSAndTransmission, frameSettings.enableSSSAndTransmission ? 1 : 0);
cmd.SetGlobalInt(HDShaderIDs._UseDisneySSS, sssParameters.useDisneySSS ? 1 : 0);
unsafe
{
// Warning: Unity is not able to losslessly transfer integers larger than 2^24 to the shader system.

using (new ProfilingSample(cmd, "Subsurface Scattering", HDRenderPipeline.GetSampler(CustomSamplerId.SubsurfaceScattering)))
{
// For Jimenez we always need an extra buffer, for Disney it depends on platform
if (!sssParameters.useDisneySSS ||
(sssParameters.useDisneySSS && NeedTemporarySubsurfaceBuffer()))
if (ShaderConfig.k_UseDisneySSS == 0 ||
((ShaderConfig.k_UseDisneySSS == 1) && NeedTemporarySubsurfaceBuffer()))
{
// Caution: must be same format as m_CameraSssDiffuseLightingBuffer
cmd.ReleaseTemporaryRT(m_CameraFilteringBuffer);

}
}
if (sssParameters.useDisneySSS)
if (ShaderConfig.s_UseDisneySSS == 1) // use static here to quiet the compiler warning
{
using (new ProfilingSample(cmd, "HTile for SSS", HDRenderPipeline.GetSampler(CustomSamplerId.HTileForSSS)))
{

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/SubsurfaceScattering/SubsurfaceScatteringSettings.cs


public sealed class SubsurfaceScatteringSettings : ScriptableObject
{
public bool useDisneySSS = true;
public SubsurfaceScatteringProfile[] profiles;
[NonSerialized] public uint texturingModeFlags; // 1 bit/profile; 0 = PreAndPostScatter, 1 = PostScatter

10
ScriptableRenderPipeline/HDRenderPipeline/HDRP/SceneSettings/Resources/DrawTransmittanceGraph.shader


// Inputs & outputs
//-------------------------------------------------------------------------------------
uint _UseDisneySSS;
float4 _HalfRcpVarianceAndWeight1, _HalfRcpVarianceAndWeight2;
float4 _ShapeParam, _TransmissionTint, _ThicknessRemap;

float d = (_ThicknessRemap.x + input.texcoord.x * (_ThicknessRemap.y - _ThicknessRemap.x));
float3 T;
if (_UseDisneySSS)
{
#if SHADEROPTIONS_USE_DISNEY_SSS
}
else
{
#else
}
#endif
// Apply gamma for visualization only. Do not apply gamma to the color.
return float4(sqrt(T) * _TransmissionTint.rgb, 1);

6
ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderConfig.cs


[GenerateHLSL(PackingRules.Exact)]
public enum ShaderOptions
{
CameraRelativeRendering = 1 // Rendering sets the origin of the world to the position of the primary (scene view) camera
CameraRelativeRendering = 1, // Rendering sets the origin of the world to the position of the primary (scene view) camera
UseDisneySSS = 1 // Allow to chose between Burley Normalized Diffusion (Multi + Fix single scattering) or Jimenez diffusion approximation (Multiscattering only - More blurry) for Subsurface scattering
};
// Note: #define can't be use in include file in C# so we chose this way to configure both C# and hlsl

public const int k_CameraRelativeRendering = (int)ShaderOptions.CameraRelativeRendering;
public static int s_CameraRelativeRendering = (int)ShaderOptions.CameraRelativeRendering;
public const int k_UseDisneySSS = (int)ShaderOptions.UseDisneySSS;
public static int s_UseDisneySSS = (int)ShaderOptions.UseDisneySSS;
}
}

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderConfig.cs.hlsl


// UnityEngine.Experimental.Rendering.HDPipeline.ShaderOptions: static fields
//
#define SHADEROPTIONS_CAMERA_RELATIVE_RENDERING (1)
#define SHADEROPTIONS_USE_DISNEY_SSS (1)
#endif
正在加载...
取消
保存