floating point texture, heightmap

Started by
2 comments, last by mark ds 9 years, 7 months ago

I'm creating an FBO heightmap texture that I can paint to for a terrain editor.

Code:
glTexImage2D(GL_TEXTURE_2D,0, GL_R32F, width,height, 0, GL_RED, GL_FLOAT, NULL);

Attached an image. It does look like it is validly floating point. What you see on the right is a height brush placed into the heightmap. What happens when I draw it again a second time with blending as GL_ONE, GL_ONE (as if I placed the same brush twice), it blows up positive and negative super high values. The vertices stretch crazy high into the air (maybe + FLOAT_MAX) and even negative (which is impossible because the brush is a GL_RGB 0-1 range texture). How it even went negative makes no sense.

Expected result would be adding original brush + the second splat = 2x as tall terrain. Not sure whats going on. You can see that bad height map has black specs inside of it, yet it was the same brush placed on the heightmap twice.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

Advertisement

Whats interesting is that if I glColo4f(1,1,1,.1f); my brush, then it draw the initial brush very softly (very small height change on my terrain) and then the second time I blend it, it blows up again pure red with black holes in it. Does openGL have a problem with blending floating point textures?

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

So I guess graphics cards (still) only support blending on 16bit floating point textures, GL_R32F changed to GL_R16F. Works fine.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

Half floats may cause you problems later because of the lack of resolution. For example, if you have a vertical height range of 500 metres, at the top of the heightmap you're only getting a resolution of approximately 24.5cm between different height points. An unsigned int is a better option in this case.

This topic is closed to new replies.

Advertisement