You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
546 B
C
26 lines
546 B
C
float DecodeHeightmap(float4 heightmap)
|
|
{
|
|
float4 table = float4(1.0, -1.0, 0.0, 0.0);
|
|
return dot(heightmap, table);
|
|
}
|
|
|
|
float DecodeHeightmap(shTexture2D HeightmapSampler, float2 texcoord)
|
|
{
|
|
float4 heightmap = shSample(HeightmapSampler, texcoord);
|
|
return DecodeHeightmap(heightmap);
|
|
}
|
|
|
|
float4 EncodeHeightmap(float fHeight)
|
|
{
|
|
float h = fHeight;
|
|
float positive = fHeight > 0.0 ? fHeight : 0.0;
|
|
float negative = fHeight < 0.0 ? -fHeight : 0.0;
|
|
|
|
float4 color = float4(0,0,0,0);
|
|
|
|
color.r = positive;
|
|
color.g = negative;
|
|
|
|
return color;
|
|
}
|