Firstborn/Library/PackageCache/com.unity.terrain-tools@4.0.3/Editor/TerrainTools/Compute/Height.compute
Schaken-Mods b486678290 Library -Artifacts
Library -Artifacts
2023-03-28 12:24:16 -05:00

25 lines
673 B
Plaintext

Texture2D<float> In_HeightTex;
Texture2D<float> In_BaseMaskTex;
Texture2D<float> RemapTex;
RWTexture2D<float> OutputTex;
float EffectStrength;
int RemapTexRes;
float4 HeightRange;
float GetHeightScale(float height)
{
return saturate((height - HeightRange.x) / (HeightRange.y - HeightRange.x));
}
#pragma kernel HeightRemap
[numthreads(1, 1, 1)]
void HeightRemap(uint3 id : SV_DispatchThreadID)
{
float heightMask = GetHeightScale(In_HeightTex[id.xy]);
uint remapIdx = (uint)(heightMask * (float)(RemapTexRes - 1));
float remappedGradient = RemapTex[uint2(remapIdx, 0)];
OutputTex[id.xy] = lerp(1.0f, remappedGradient, EffectStrength) * In_BaseMaskTex[id.xy];
}