private static float4 Sample2(sampler tex, float4 coords, float polar) { float4 tex1 = tex.SampleLevel(coords.xy); float4 tex2 = tex.SampleLevel(coords.zw); return(_lerp(tex1, tex2, polar)); }
private static float4 SampleSmooth(sampler tex, float2 coord, float2 size) { float2 pix = coord * size; float2 sub = _floor(pix - 0.5f) + 0.5f; float2 f = pix - sub; f = _smoothstep(_float2(0.0f, 0.0f), _float2(1.0f, 1.0f), f); return(tex.SampleLevel((sub + f) / size)); }
private static float GetHeightUV(float2 coord, float4 detailCoord) { float height = _Radius; float4 heightMap = SampleSmooth(_HeightMap, coord, _HeightMapSize); float4 maskMap = _MaskMap.SampleLevel(coord); float polar = _saturate((_abs(coord.y - 0.5f) - 0.2f) * 30.0f); height += Sample2(_DetailMapA, detailCoord, polar).w *maskMap.x *_DetailScaleA; height += Sample2(_DetailMapB, detailCoord, polar).w *maskMap.y *_DetailScaleB; height += heightMap.w * _HeightMapScale; return(height); }