Skip to main content
GameDev.net gamedev.net
🔒 Locked

is a 16 bit normal map overkill for a 16 bit heightmap?

Started by Wilhelm van Huyssteen Jul 2, 2012 at 11:33 AM 6 replies 5.4k views
Original Post
Wilhelm van Huyssteen
Wilhelm van Huyssteen
Hi.

Im creating a heightmap from a 16 bit channel in a texture that came from a 16 bit per channel png image using the vertex shader. I was thinking that instead of using a seperate texture for the normal map I might as well put both the normal and height map in a single 16 bit per channel (64 bbp) png image. RGB would become the normal map and Alpha would be the height map. This would also greatly simplify the process of creating height and normal maps in photoshop using the nifty normal map plugin from nvidia. Using this way I also bind one less texture but I dont know how much of an advantage that is. I dont know if the end result will have any noticeble quality improvement.

Is this aproach fine or should i rather save the normal map in a seperate 8 bits per channel image.
Enalis
Enalis
Well, it depends on what kind of system configurations you want to support. Do your research and make sure that it's supported on devices that you are targeting. Also, make sure that it is giving you adequate performance for your application. Besides that it's up to you! I encourage you to do the research and try it out. That's half the fun! If you are using opengl or directx, there are definitely performance measurement tools. I will say that in a deferred pipeline it's not uncommon to have 32bits per channel to store gbuffer data, so why not store high resolution normals, I do, it works out pretty great!
Douglas Eugene Reisinger II
Projects/Profile Site
Hodgman
Hodgman
48-bit normals (and 32-bit g-buffer channels) sounds like overkill to me. 24-bit normals work fine, and 16-bit normals work in a lot of situations.

If you were really space concious, you could use an 8bit*4channel format and pack the normals into the R&G channels, and the height into the B&A channels.

If you've got a 2048[sup]^2[/sup] heightmap, that's 32MiB if using 4x16-bit channels. Dropping down to 8-bit channels saves you 16MiB, which may or may not be a lot of RAM depending on your target hardware.
chronozphere
chronozphere
If you feel like optimizing, you could also store the normal using spherical coordinates (in R and G) and still have B left for other purposes. That would allow you to squeeze your image into an RGB format, saving 16bits per pixel.
Wilhelm van Huyssteen
Wilhelm van Huyssteen
I like the idea of packing the normal into R and G and then using the B and A for the 16 bit heightmap. Just one concern. Im not sure what calculations im going to have to do in my vertex shader if im using spherical coords for normals but wont it maybe be too slow? Il read up on how to do it I was just wondering what the performance impact is.

Alternitively cant i just store the normal in 15 bits using 5 bits for each axis and let one bit go to waiste? or is that a bad idea.
Hodgman
Hodgman
Check the link I posted earlier wink.png They show that the quality result is very good, but there's quite a few ALU ops required in the decoding. However, seeing as your vertex shader is performing texture fetches, then you're going to get a certain amount of ALU ops "for free" anyway to cover that fetch latency.
Wilhelm van Huyssteen
Wilhelm van Huyssteen
OK Il go with that. But just one last thing. I was stil editing my previous response when you replied biggrin.png

[background=rgb(250, 251, 252)]cant i just store the normal in 15 bits using 5 bits for each axis and let one bit go to waiste? how would that compare to sperical normals[/background]


[background=rgb(250, 251, 252)]EDIT: this is probely a pretty stupid idea .[/background]



[background=rgb(250, 251, 252)]Im going to go with the spherical normals idea wich seems perfect for my needs. Thnx a lot![/background]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.