简体   繁体   English

使用SOIL加载16位高度图

[英]Loading 16-bit heightmaps with SOIL

I am trying to load a height map for terrain using SOIL. 我正在尝试使用SOIL加载地形的高度图。 I use the following code: 我使用以下代码:

unsigned char* image = SOIL_load_image(fname.c_str(), &width, &height, 0, SOIL_LOAD_L);

glBindTexture(GL_TEXTURE_2D, name);
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, width, height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, image);

However, my terrain looks steppy because the height is expressed with 8 bits only. 但是,我的地形看起来很step,因为高度仅用8位表示。 How can I load 16-bit height map with SOIL? 如何使用SOIL加载16位高度图? Or should I use another image library for this task? 还是应该为此任务使用另一个图像库?

正如Andon M. Coleman所建议的那样,我使用原始二进制格式存储16位高度数据并获得了所需的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM