Firstborn/Library/PackageCache/com.unity.terrain-tools@4.0.5/Editor/TerrainTools/Compute/Height.compute
Schaken-Mods 4ff395c862 Finished the NPC Creator tool
Finished the NPC Creator tool
2023-04-27 18:37:28 -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];
}