浏览代码

HDRP: Fix issue with metal having wrong tangent (need more investigation - quick fix)

/main
sebastienlagarde 6 年前
当前提交
641c8119
共有 1 个文件被更改,包括 10 次插入1 次删除
  1. 11
      com.unity.render-pipelines.high-definition/HDRP/Material/NormalBuffer.hlsl

11
com.unity.render-pipelines.high-definition/HDRP/Material/NormalBuffer.hlsl


// RT1 - 8:8:8:8
// Our tangent encoding is based on our normal.
float2 octNormalWS = PackNormalOctQuadEncode(normalData.normalWS);
#if defined(SHADER_API_METAL)
// With octahedral quad packing we get an artifact for reconstructed tangent at the center of this quad. We use rect packing instead to avoid it.
float2 octNormalWS = PackNormalOctRectEncode(normalData.normalWS);
#else
float2 octNormalWS = PackNormalOctQuadEncode(normalData.normalWS);
#endif
float3 packNormalWS = PackFloat2To888(saturate(octNormalWS * 0.5 + 0.5));
// We store perceptualRoughness instead of roughness because it is perceptually linear.
outNormalBuffer0 = float4(packNormalWS, normalData.perceptualRoughness);

{
float3 packNormalWS = normalBuffer.rgb;
float2 octNormalWS = Unpack888ToFloat2(packNormalWS);
#if defined(SHADER_API_METAL)
normalData.normalWS = UnpackNormalOctRectEncode(octNormalWS * 2.0 - 1.0);
#else
#endif
normalData.perceptualRoughness = normalBuffer.a;
}

正在加载...
取消
保存