Jump to content
  • Advertisement
Sign in to follow this  
TwoNybble

Texture Issues With Unusual Internal Formats

This topic is 1183 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

As part of my terrain streaming system, I page heightmap detail levels into a larger texture using the same method I use for the normal- and splat-map datasets, which both seem to work perfectly fine. However, the heightmap data seems to substitute in with visible artifacts, and also seems to insert or remove an additional pixel for every three in the substitution. This results in the page being unusable and skewed by about a third.

 

Now, I'm suspicious that it has to do with the unorthodox internal format of the texture; it is a single component, 16-bit texture (GL_RED, GL_R16, GL_UNSIGNED_SHORT). The other two datasets use relatively normal formats (GL_RGB8 for normals, and GL_RGBA8 for splat-values), and so that would explain the problem only appearing in the height data. I've double-checked my code, and I'm very positive that this is not a problem with the data or the substitution routines.

 

I am currently using Intel HD 4000 integrated graphics on a Linux system with Mesa drivers, both of which I realize could cause problems for me. This is still a dilemma if this is the root of the problem, because I'd like to be able to support Intel HD 4000 graphics for my game. I've been thinking that, worse case scenario, I can create a "normal" format texture (GL_RGB8) and simply use both R and G for my 16-bit height values, ignoring the B component. I'm just wondering if anybody has experienced this and/or has found a simple fix that I've been overlooking?

 

Here are some visual examples of this problem, taken directly from the textures themselves:

 

[attachment=28317:02.png]

A simple checkerboard dataset, which shows the 1/3 "skewing" effect, as well as some artifacts throughout. There was no size mismatch in the data during the substitution, which I suspected could be the cause of the misalignment at first.

 

[attachment=28318:01.png]

The actual height test dataset, which is a simple cosine 3D surface (better seen in the following image). The data should look more or less like the next image, but instead is skewed, and has a strange triangular artifact. I have no idea where this might be originating from. The data looks fine when I plot it using other software.

 

[attachment=28316:03.png]

This is the test splatmap, which looks great. I'm not handling this any differently besides the obvious different formatting, etc.

Share this post


Link to post
Share on other sites
Advertisement

There are many things that may go wrong. The first candidate coming to my mind is the pixel unpack alignment. With each texel being 2 bytes in size and the chance that you transfer an odd number of texels per row, the default alignment of 4 will not match. Have you considered glPixelStorei(GL_UNPACK_ALIGNMENT, 2) yet? Alternatively, do you do some padding?

Share this post


Link to post
Share on other sites

Looks like you forgot to

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

Edit: Darn you, server hiccups.

Edited by kolrabi

Share this post


Link to post
Share on other sites

Thanks guys, that looks to be what the problem was! I thought 2-bytes would be fine, but I was indeed substituting an odd number of texels (the pages are (2^n)+1, but the texture is POT). I'm glad it was a simple fix.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!