|
|
|
|
|
|
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) |
|
|
|
|
|
|
#else |
|
|
|
surfaceData.perceptualSmoothness = 1.0; |
|
|
|
#endif |
|
|
|
surfaceData.perceptualSmoothness *= ADD_IDX(_Smoothness); |
|
|
|
surfaceData.perceptualSmoothness *= ADD_IDX(_Smoothness); |
|
|
|
#ifdef _DETAIL_MAP |
|
|
|
surfaceData.perceptualSmoothness *= LerpWhiteTo(2.0 * saturate(detailSmoothness * ADD_IDX(_DetailSmoothnessScale)), detailMask); |
|
|
|
#endif |
|
|
|