浏览代码

fix normalizations

fix normalizations to match the bump framework.
/RenderPassXR_Sandbox
mmikk 8 年前
当前提交
82540b9f
共有 1 个文件被更改,包括 9 次插入5 次删除
  1. 14
      Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/VaryingMesh.hlsl

14
Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/VaryingMesh.hlsl


// For now do some test by keeping code consistent with previous visual.
#ifdef SURFACE_GRADIENT
// Normalize normalWS vector but keep the renormFactor to apply it to bitangent and tangent
float renormFactor = 1.0 / length(input.interpolators1);
float3 normalWS = renormFactor * input.interpolators1;
float3 unnormalizedNormalWS = input.interpolators1.xyz;
float renormFactor = 1.0 / length(unnormalizedNormalWS);
float3x3 worldToTangent = CreateWorldToTangent(normalWS, tangentWS.xyz, tangentWS.w);
output.worldToTangent[0] = worldToTangent[0];
// prepare for surfgrad formulation without breaking compliance (use exact same scale as applied to interpolated vertex normal to avoid breaking compliance).
float3x3 worldToTangent = CreateWorldToTangent(unnormalizedNormalWS, tangentWS.xyz, tangentWS.w); // this is the mikktspace transformation (must use unnormalized attributes)
// surface gradient based formulation requires a unit length initial normal. We can maintain compliance with mikkts
// by uniformly scaling all 3 vectors since normalization of the perturbed normal will cancel it.
output.worldToTangent[0] = worldToTangent[0] * renormFactor;
float3 normalWS = output.worldToTangent[2];
#else
// TODO: Check if we must do like for surface gradient (i.e not normalize ?) For now, for consistency with previous code we normalize
// Normalize after the interpolation

正在加载...
取消
保存