Sign in to follow this  
dpadam450

floating point texture, heightmap

Recommended Posts

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.

Edited by dpadam450

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this