|
|
|
|
|
|
void ADD_IDX(ComputeLayerTexCoord)( // Uv related parameters |
|
|
|
void ADD_IDX(ComputeLayerTexCoord)( // Uv related parameters |
|
|
|
float2 texCoord0, float2 texCoord1, float2 texCoord2, float2 texCoord3, float4 uvMappingMask, float4 uvMappingMaskDetails, |
|
|
|
// scale and bias for base and detail + global tiling factor (for layered lit only) |
|
|
|
float2 texScale, float2 texBias, float2 texScaleDetails, float2 texBiasDetails, float additionalTiling, |
|
|
|
|
|
|
|
|
|
|
surfaceData.baseColor = SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_BaseColorMap), ADD_ZERO_IDX(sampler_BaseColorMap), ADD_IDX(layerTexCoord.base)).rgb * ADD_IDX(_BaseColor).rgb; |
|
|
|
#ifdef _DETAIL_MAP_IDX |
|
|
|
surfaceData.baseColor *= LerpWhiteTo(2.0 * detailAlbedo, detailMask * ADD_IDX(_DetailAlbedoScale)); |
|
|
|
// we saturate to avoid to have a smoothness value above 1 |
|
|
|
surfaceData.baseColor = saturate(surfaceData.baseColor); |
|
|
|
// Use overlay blend mode for detail abledo: (base < 0.5 ? (2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend))) |
|
|
|
float baseColorOverlay = (detailAlbedo < 0.5) ? |
|
|
|
surfaceData.baseColor * PositivePow(2.0 * detailAlbedo, ADD_IDX(_DetailAlbedoScale)) : |
|
|
|
1.0 - 2.0 * (1.0 - surfaceData.baseColor) * (1.0 - (detailAlbedo * ADD_IDX(_DetailAlbedoScale))); |
|
|
|
// Lerp with details mask |
|
|
|
surfaceData.baseColor = lerp(surfaceData.baseColor, saturate(baseColorOverlay), detailMask); |
|
|
|
#endif |
|
|
|
|
|
|
|
surfaceData.specularOcclusion = 1.0; // Will be setup outside of this function |
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
#ifdef _DETAIL_MAP_IDX |
|
|
|
surfaceData.perceptualSmoothness *= LerpWhiteTo(2.0 * detailSmoothness, detailMask * ADD_IDX(_DetailSmoothnessScale)); |
|
|
|
// we saturate to avoid to have a smoothness value above 1 |
|
|
|
surfaceData.perceptualSmoothness = saturate(surfaceData.perceptualSmoothness); |
|
|
|
// Use overlay blend mode for detail abledo: (base < 0.5 ? (2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend))) |
|
|
|
float smoothnessOverlay = (detailSmoothness < 0.5) ? |
|
|
|
surfaceData.perceptualSmoothness * PositivePow(2.0 * detailSmoothness, ADD_IDX(_DetailSmoothnessScale)) : |
|
|
|
1.0 - 2.0 * (1.0 - surfaceData.baseColor) * (1.0 - (detailSmoothness * ADD_IDX(_DetailSmoothnessScale))); |
|
|
|
// Lerp with details mask |
|
|
|
surfaceData.perceptualSmoothness = lerp(surfaceData.perceptualSmoothness, saturate(smoothnessOverlay), detailMask); |
|
|
|
#endif |
|
|
|
|
|
|
|
// MaskMap is RGBA: Metallic, Ambient Occlusion (Optional), emissive Mask (Optional), Smoothness |
|
|
|