浏览代码

Fixed planar/triplanar so that tangent space normal aren't flipped when facing away from the world axes.

/main
Julien Ignace 8 年前
当前提交
c26c16b2
共有 1 个文件被更改,包括 13 次插入8 次删除
  1. 21
      Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/LitSurfaceData.hlsl

21
Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/LitSurfaceData.hlsl


ADD_IDX(layerTexCoord.base).uv = ADD_IDX(_UVMappingMask).x * input.texCoord0 +
ADD_IDX(_UVMappingMask).y * input.texCoord1 +
ADD_IDX(_UVMappingMask).z * input.texCoord3 +
ADD_IDX(_UVMappingMask).w * position.xz;
ADD_IDX(_UVMappingMask).w * -position.xz;
ADD_IDX(_UVMappingMask).w * position.xz;
ADD_IDX(_UVMappingMask).w * -position.xz;
ADD_IDX(layerTexCoord.details).uv = TRANSFORM_TEX(uvDetails, ADD_IDX(_DetailMap));

ADD_IDX(layerTexCoord.base).uvYZ = position.zy;
ADD_IDX(layerTexCoord.base).uvZX = position.xz;
ADD_IDX(layerTexCoord.base).uvXY = float2(-position.x, position.y);
float3 direction = sign(input.tangentToWorld[2].xyz);
// In triplanar, if we are facing away from the world axis, a different axis will be flipped for each direction.
// This is particularly problematic for tangent space normal maps which need to be in the right direction.
// So we multiplying the offending coordinate by the sign of the normal.
ADD_IDX(layerTexCoord.base).uvYZ = float2(direction.x * position.z, position.y);
ADD_IDX(layerTexCoord.base).uvZX = -float2(position.x, direction.y * position.z);
ADD_IDX(layerTexCoord.base).uvXY = float2(-position.x, direction.z * position.y);
ADD_IDX(layerTexCoord.details).uvYZ = TRANSFORM_TEX(position.zy, ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.details).uvZX = TRANSFORM_TEX(position.xz, ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.details).uvXY = TRANSFORM_TEX(float2(-position.x, position.y), ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.details).uvYZ = TRANSFORM_TEX(ADD_IDX(layerTexCoord.base).uvYZ, ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.details).uvZX = TRANSFORM_TEX(ADD_IDX(layerTexCoord.base).uvZX, ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.details).uvXY = TRANSFORM_TEX(ADD_IDX(layerTexCoord.base).uvXY, ADD_IDX(_DetailMap));
}
void ADD_IDX(ApplyDisplacement)(inout FragInput input, inout LayerTexCoord layerTexCoord)

正在加载...
取消
保存