浏览代码

Merge pull request #561 from Unity-Technologies/Unity-2017.3

Unity 2017.3
/main
GitHub 7 年前
当前提交
bec11b73
共有 3 个文件被更改,包括 7 次插入5 次删除
  1. 4
      ScriptableRenderPipeline/Core/ShaderLibrary/Common.hlsl
  2. 2
      ScriptableRenderPipeline/Core/ShaderLibrary/CommonMaterial.hlsl
  3. 6
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl

4
ScriptableRenderPipeline/Core/ShaderLibrary/Common.hlsl


#define HFLT_MIN 0.00006103515625 // 2^14 it is the same for 10, 11 and 16bit float. ref: https://www.khronos.org/opengl/wiki/Small_Float_Formats
#define SMALL_FLT_VALUE 0.0001
// General constant
float DegToRad(float deg)
{
return deg * PI / 180.0;

2
ScriptableRenderPipeline/Core/ShaderLibrary/CommonMaterial.hlsl


// Helper function for anisotropy
//-----------------------------------------------------------------------------
// Ref: http://blog.selfshadow.com/publications/s2012-shading-course/burley/s2012_pbs_disney_brdf_notes_v3.pdf (in addenda)
// Convert anisotropic ratio (0->no isotropic; 1->full anisotropy in tangent direction) to roughness
void ConvertAnisotropyToRoughness(float roughness, float anisotropy, out float roughnessT, out float roughnessB)
{
// Use the parametrization of Sony Imageworks.

6
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl


CBUFFER_END
// General constant
#define MIN_N_DOT_V 0.0001 // The minimum value of 'NdotV'
#define MIN_N_DOT_V SMALL_FLT_VALUE // The minimum value of 'NdotV'
//-----------------------------------------------------------------------------
// Helper for cheap screen space raycasting

float NdotL = saturate(dot(bsdfData.normalWS, L)); // Must have the same value without the clamp
float NdotV = preLightData.NdotV; // Get the unaltered (geometric) version
float LdotV = dot(L, V);
float invLenLV = rsqrt(abs(2 * LdotV + 2)); // invLenLV = rcp(length(L + V))
float invLenLV = rsqrt(max(2 * LdotV + 2, SMALL_FLT_VALUE)); // invLenLV = rcp(length(L + V)) - caution about the case where V and L are opposite, it can happen, use max to avoid this
float NdotH = saturate((NdotL + NdotV) * invLenLV);
float LdotH = saturate(invLenLV * LdotV + invLenLV);

// TODO: Do comparison between this correct version and the one from isotropic and see if there is any visual difference
DV = DV_SmithJointGGXAniso(TdotH, BdotH, NdotH,
preLightData.TdotV, preLightData.BdotV, preLightData.NdotV,
preLightData.TdotV, preLightData.BdotV, NdotV,
TdotL, BdotL, NdotL,
bsdfData.roughnessT, bsdfData.roughnessB
#ifdef LIT_USE_BSDF_PRE_LAMBDAV

正在加载...
取消
保存