浏览代码

Address the remaining PR feedback

https://github.com/Unity-Technologies/ScriptableRenderLoop/pull/277
/RenderPassXR_Sandbox
Evgenii Golubev 7 年前
当前提交
2a641adb
共有 5 个文件被更改,包括 14 次插入23 次删除
  1. 1
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl
  2. 4
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl
  3. 15
      Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/DrawTransmittanceGraph.shader
  4. 7
      Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/Resources/DrawSssProfile.shader
  5. 10
      Assets/ScriptableRenderPipeline/ShaderLibrary/BSDF.hlsl

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


// Computes the fraction of light passing through the object.
// N.b.: it is not just zero scattering (light traveling in a straight path)!
// We derive the transmittance function from the SSS profile, by normalizing it s.t. R(0) = 1.
// Ref: Approximate Reflectance Profiles for Efficient Subsurface Scattering by Pixar (BSSRDF only).
float3 ComputeTransmittance(float3 S, float3 surfaceAlbedo, float thickness, float radiusScale)
{

4
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitData.hlsl


if (transmissionMode != SSS_TRSM_MODE_THIN)
{
// Convert thickness along the normal to thickness along the viewing direction.
// We assume that the thickness along the normal corresponds to the diameter of a sphere.
// We then find a position on the sphere which corresponds to the normal, and
// compute the length of the chord of the sphere along the viewing direction.
// We add a small bias to (hopefully) have non-zero thickness.
surfaceData.thickness *= saturate(dot(interpolatedVertexNormal, V) + 0.01);
}

15
Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/DrawTransmittanceGraph.shader


Shader "Hidden/HDRenderPipeline/DrawTransmittanceGraph"
{
Properties
{
[HideInInspector] _StdDev1("", Vector) = (0, 0, 0, 0)
[HideInInspector] _StdDev2("", Vector) = (0, 0, 0, 0)
[HideInInspector] _LerpWeight("", Float) = 0
[HideInInspector] _TintColor("", Vector) = (0, 0, 0, 0)
}
SubShader
{
Pass

#include "../../ShaderLibrary/Common.hlsl"
#include "../../ShaderLibrary/Color.hlsl"
#include "../ShaderVariables.hlsl"
#define UNITY_MATERIAL_LIT // Needs to be defined before including Material.hlsl
#include "../Material/Material.hlsl"
//-------------------------------------------------------------------------------------
// Inputs & outputs

float4 Frag(Varyings input) : SV_Target
{
float d = (_ThicknessRemap.x + input.texcoord.x * (_ThicknessRemap.y - _ThicknessRemap.x));
float3 S = _ShapeParameter.rgb;
float3 T = 0.5 * exp(-d * S) + 0.5 * exp(-d * S * (1.0 / 3.0));
float3 T = ComputeTransmittance(_ShapeParameter.rgb, _SurfaceAlbedo.rgb, d, 1);
return float4(T * _SurfaceAlbedo.rgb, 1);
return float4(T, 1);
}
ENDHLSL
}

7
Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/Resources/DrawSssProfile.shader


Shader "Hidden/HDRenderPipeline/DrawSssProfile"
{
Properties
{
[HideInInspector] _StdDev1("", Vector) = (0, 0, 0, 0)
[HideInInspector] _StdDev2("", Vector) = (0, 0, 0, 0)
[HideInInspector] _LerpWeight("", Float) = 0
}
SubShader
{
Pass

10
Assets/ScriptableRenderPipeline/ShaderLibrary/BSDF.hlsl


return F_Schlick(f0, 1.0, u); // sub mul mul mul sub mad
}
float F_t_Schlick(float f0, float f90, float u)
float F_Transm_Schlick(float f0, float f90, float u)
{
float x = 1.0 - u;
float x5 = x * x;

float F_t_Schlick(float f0, float u)
float F_Transm_Schlick(float f0, float u)
{
return F_Schlick(f0, 1.0, u); // sub mul mul mul sub mad
}

return f0 * (1.0 - x5) + float3(x5, x5, x5); // sub mul mul mul sub mad*3
}
float3 F_t_Schlick(float3 f0, float u)
float3 F_Transm_Schlick(float3 f0, float u)
{
float x = 1.0 - u;
float x2 = x * x;

{
float facing = 0.5 + 0.5 * LdotV;
float rough = facing * (0.9 - 0.4 * facing) * ((0.5 + NdotH) / NdotH);
float transmitL = F_t_Schlick(0, NdotL);
float transmitV = F_t_Schlick(0, NdotV);
float transmitL = F_Transm_Schlick(0, NdotL);
float transmitV = F_Transm_Schlick(0, NdotV);
float smooth = transmitL * transmitV * 1.05; // Normalize F_t over the hemisphere
float single = lerp(smooth, rough, perceptualRoughness); // Rescaled by PI
// This constant is picked s.t. setting perceptualRoughness, albedo and all angles to 1

正在加载...
取消
保存