浏览代码

Use real types for heightmap packing/unpacking.

/main
Yao Xiao Ling 6 年前
当前提交
b853132b
共有 1 个文件被更改,包括 8 次插入8 次删除
  1. 16
      com.unity.render-pipelines.core/CoreRP/ShaderLibrary/Common.hlsl

16
com.unity.render-pipelines.core/CoreRP/ShaderLibrary/Common.hlsl


#if defined(SHADER_API_VULKAN) || defined(SHADER_API_GLES) || defined(SHADER_API_GLES3)
float4 PackHeightmap(float height)
real4 PackHeightmap(real height)
uint a = (uint)(65535.0f * height);
return float4((a >> 0) & 0xFF, (a >> 8) & 0xFF, 0, 0) / 255.0f;
uint a = (uint)(65535.0 * height);
return real4((a >> 0) & 0xFF, (a >> 8) & 0xFF, 0, 0) / 255.0;
float UnpackHeightmap(float4 height)
real UnpackHeightmap(real4 height)
return (height.r + height.g * 256.0f) / 257.0f; // (255.0f * height.r + 255.0f * 256.0f * height.g) / 65535.0f
return (height.r + height.g * 256.0) / 257.0; // (255.0 * height.r + 255.0 * 256.0 * height.g) / 65535.0
float4 PackHeightmap(float height)
real4 PackHeightmap(real height)
return float4(height, 0, 0, 0);
return real4(height, 0, 0, 0);
float UnpackHeightmap(float4 height)
real UnpackHeightmap(real4 height)
{
return height.r;
}

正在加载...
取消
保存