浏览代码

HDRenderPipeline: Move ComputeTransmittance to commonMaterial.hlsl

/RenderPassXR_Sandbox
Sebastien Lagarde 7 年前
当前提交
894b33fe
共有 3 个文件被更改,包括 20 次插入17 次删除
  1. 15
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl
  2. 3
      Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/DrawTransmittanceGraph.shader
  3. 19
      Assets/ScriptableRenderPipeline/ShaderLibrary/CommonMaterial.hlsl

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


#endif
}
// 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)
{
// Thickness and SSS radius are decoupled for artists.
// In theory, we should modify the thickness by the inverse of the radius scale of the profile.
// thickness /= radiusScale;
float3 expOneThird = exp(((-1.0 / 3.0) * thickness) * S);
return 0.5 * (expOneThird + expOneThird * expOneThird * expOneThird) * surfaceAlbedo;
}
void FillMaterialIdStandardData(float3 baseColor, float specular, float metallic, float roughness, float3 normalWS, float3 tangentWS, float anisotropy, inout BSDFData bsdfData)
{
bsdfData.diffuseColor = baseColor * (1.0 - metallic);

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


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

19
Assets/ScriptableRenderPipeline/ShaderLibrary/CommonMaterial.hlsl


return float3(oneMinusT, oneMinusT, oneMinusT) + b * t;
}
// ----------------------------------------------------------------------------
// SSS/Transmittance
// ----------------------------------------------------------------------------
// 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)
{
// Thickness and SSS radius are decoupled for artists.
// In theory, we should modify the thickness by the inverse of the radius scale of the profile.
// thickness /= radiusScale;
float3 expOneThird = exp(((-1.0 / 3.0) * thickness) * S);
return 0.5 * (expOneThird + expOneThird * expOneThird * expOneThird) * surfaceAlbedo;
}
// MACRO from Legacy Untiy
// Transforms 2D UV by scale/bias property
#define TRANSFORM_TEX(tex, name) ((tex.xy) * name##_ST.xy + name##_ST.zw)

正在加载...
取消
保存