BUMP
I find on google some info about 32bit. 32bit float doesn’t have limits for height. 16bit has about 0-65k.
I tried to recode loading from img to generate 0 height in float, but it crashing my driver:
Old code to load map:
SamplerPtr sampler(new Sampler);
sampler->create();
sampler->setMinificationFilter(GL_LINEAR);
sampler->setMagnificationFilter(GL_LINEAR);
sampler->setWrapMode(Sampler::DirectionS, GL_CLAMP_TO_EDGE);
sampler->setWrapMode(Sampler::DirectionT, GL_CLAMP_TO_EDGE);
heightMapImage.load("heightmap-1024x1024.png");
m_funcs->glActiveTexture(GL_TEXTURE0);
TexturePtr heightMap(new Texture);
heightMap->create();
heightMap->bind();
heightMap->setImage(heightMapImage);
New code to load map:
SamplerPtr sampler(new Sampler);
sampler->create();
sampler->setMinificationFilter(GL_LINEAR);
sampler->setMagnificationFilter(GL_LINEAR);
sampler->setWrapMode(Sampler::DirectionS, GL_CLAMP_TO_EDGE);
sampler->setWrapMode(Sampler::DirectionT, GL_CLAMP_TO_EDGE);
// float* mapData (in header)
mapData = new float[1024 * 1024];
for(int i = 0; i < 1024 * 1024; ++i)
mapData[i] = 0.0f;
m_funcs->glActiveTexture(GL_TEXTURE0);
TexturePtr heightMap(new Texture);
heightMap->create();
heightMap->bind();
heightMap->setImage(mapData, 1024, 1024);
Old code to set heightmap image data
void Texture::setImage(const QImage& image)
{
Q_ASSERT(m_type == Texture2D);
// convert to use only .bits, .width, .height
QImage glImage = QGLWidget::convertToGLFormat(image);
// glImage.bits() == uchar* QImage.bits()
glTexImage2D(m_type, 0, GL_RGBA, glImage.width(), glImage.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, glImage.bits());
}
New code to set heightmap image data
void Texture::setImage(float* pixelArray, int width, int height)
{
Q_ASSERT(m_type == Texture2D);
glTexImage2D(m_type, 0, GL_RGBA32F_ARB, width, height, 0, GL_RGBA32F_ARB, GL_FLOAT, &pixelArray[0]); // crash here!
}
What’s incorrect on my new code?
Is generating of new mapData correct?