|
|
|
|
|
|
ADD_IDX(_UVDetailsMappingMask).y * input.texCoord1 + |
|
|
|
ADD_IDX(_UVDetailsMappingMask).z * input.texCoord3 + |
|
|
|
// Note that if base is planar, detail map is planar |
|
|
|
ADD_IDX(_UVMappingMask).w * -position.xz; |
|
|
|
ADD_IDX(_UVMappingMask).w * -position.xz; |
|
|
|
|
|
|
|
ADD_IDX(layerTexCoord.details).uv = TRANSFORM_TEX(uvDetails, ADD_IDX(_DetailMap)); |
|
|
|
|
|
|
|
|
|
|
float3 direction = sign(input.tangentToWorld[2].xyz); |
|
|
|
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); |
|
|
|
// 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.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)); |
|
|
|
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 |
|
|
|