浏览代码

Merge remote-tracking branch 'refs/remotes/origin/master' into Merge-FPTL

/main
Sebastien Lagarde 8 年前
当前提交
bebe7f01
共有 3 个文件被更改,包括 25 次插入23 次删除
  1. 1
      Assets/ScriptableRenderLoop/HDRenderLoop/Material/Material.hlsl
  2. 25
      Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl
  3. 22
      Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl

1
Assets/ScriptableRenderLoop/HDRenderLoop/Material/Material.hlsl


#include "Debug.hlsl"
#include "GeometricTools.hlsl"
#include "CommonMaterial.hlsl"
#include "CommonLighting.hlsl"
#include "EntityLighting.hlsl"
//-----------------------------------------------------------------------------

25
Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl


return 1.0 / (zBufferParam.z * depth + zBufferParam.w);
}
//-----------------------------------------------------------------------------
// various helper
//-----------------------------------------------------------------------------
// NdotV should not be negative for visible pixels, but it can happen due to perspective projection and normal mapping + decal
// In this case this may cause weird artifact.
// GetNdotV return a 'valid' data
float GetNdotV(float3 N, float3 V)
{
return abs(dot(N, V)); // This abs allow to limit artifact
}
// NdotV should not be negative for visible pixels, but it can happen due to perspective projection and normal mapping + decal
// In this case normal should be modified to become valid (i.e facing camera) and not cause weird artifacts.
// but this operation adds few ALU and users may not want it. Alternative is to simply take the abs of NdotV (less correct but works too).
// Note: This code is not compatible with two sided lighting used in SpeedTree (TODO: investigate).
float GetShiftedNdotV(float3 N, float3 V)
{
// The amount we shift the normal toward the view vector is defined by the dot product.
float shiftAmount = dot(N, V);
N = shiftAmount < 0.0 ? N + V * (-shiftAmount + 1e-5f) : N;
N = normalize(N);
return saturate(dot(N, V)); // TODO: this saturate should not be necessary here
}
#endif // UNITY_COMMON_INCLUDED

22
Assets/ScriptableRenderLoop/ShaderLibrary/CommonLighting.hlsl


// various helper
//-----------------------------------------------------------------------------
// NdotV should not be negative for visible pixels, but it can happen due to perspective projection and normal mapping + decal
// In this case this may cause weird artifact.
// GetNdotV return a 'valid' data
float GetNdotV(float3 N, float3 V)
{
return abs(dot(N, V)); // This abs allow to limit artifact
}
// NdotV should not be negative for visible pixels, but it can happen due to perspective projection and normal mapping + decal
// In this case normal should be modified to become valid (i.e facing camera) and not cause weird artifacts.
// but this operation adds few ALU and users may not want it. Alternative is to simply take the abs of NdotV (less correct but works too).
// Note: This code is not compatible with two sided lighting used in SpeedTree (TODO: investigate).
float GetShiftedNdotV(float3 N, float3 V)
{
// The amount we shift the normal toward the view vector is defined by the dot product.
float shiftAmount = dot(N, V);
N = shiftAmount < 0.0 ? N + V * (-shiftAmount + 1e-5f) : N;
N = normalize(N);
return saturate(dot(N, V)); // TODO: this saturate should not be necessary here
}
// Performs the mapping of the vector 'v' located within the cube of dimensions [-r, r]^3
// to a vector within the sphere of radius 'r', where r = sqrt(r2).
// Modified version of http://mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html

正在加载...
取消
保存