Jump to content

  • Log In with Google      Sign In   
  • Create Account

Power of normal mapping and texture formats?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 cozzie   Members   -  Reputation: 1765

Like
2Likes
Like

Posted 05 February 2014 - 04:46 PM

Hi all,

 

First of all, many thanks for helping me out with some challenges in the journey that's called 'my 3d engine'.

Below 2 screenshots to share the power of normal mapping, amazing what you can do with it. Imagine what adding a specular and/or alpha map can do, not even to talk about cool postprocessing effects... Sky's the limit (although for a lot you this might not be new :)

 

I've found that that when adding nice stuff, texture megabytes are also growing (enormously).

Do you have some pointers how to handle this efficiently? (other then procedural mapping, which is currently out of my league)

 

Some thoughts:

- Always use the same file format? (for example DDS?)

- Could I for example save alpha in normal map textures in the 'Z' channel, which is always sort of the same?
(or would this mean that 'height' will always be the same for all normal maps.. that would be bad I guess)

- How about texture compression?

(my normal map tool, Shadermap, has possibilities to save the maps as "DDS DXT 1 / 3 or 5" for example)

- What exactly is DDS DXT?

 

Curious what your thoughts are.

 

Without normal maps:

 

demo_nonormalmap.jpg

 

With normal maps:

 

demo_normalmap.jpg

 



Sponsor:

#2 phil_t   Crossbones+   -  Reputation: 4094

Like
2Likes
Like

Posted 05 February 2014 - 09:47 PM


Some thoughts:
- Always use the same file format? (for example DDS?)
- Could I for example save alpha in normal map textures in the 'Z' channel, which is always sort of the same?
(or would this mean that 'height' will always be the same for all normal maps.. that would be bad I guess)
- How about texture compression?
(my normal map tool, Shadermap, has possibilities to save the maps as "DDS DXT 1 / 3 or 5" for example)
- What exactly is DDS DXT?

 

DDS is just a container for textures, it's not a format in and of itself.

 

DXT is the compressed format used for DX9. So absolutely use this if you can handle the reduction in quality.

 

Sure you could save the alpha in the blue channel of the normal map. Normally this would be in the alpha channel of your diffuse map though. But you can use stronger compression if you have textures without an alpha channel (DXT1 instead of DXT3/DXT5).



#3 pcmaster   Members   -  Reputation: 685

Like
1Likes
Like

Posted 06 February 2014 - 09:06 AM

DXT (DX9) / BC (DX10+) are block compression schemes. They take 4x4 blocks and instead of representing them with 4x4=16 RGB(A) color values, they represent them with only 2 degraded colors (5:6:5-bit instead of 8:8:8-bit) and 16 interpolation coordinates (each 3-bits). DXT1/BC1, for example, will save you always exactly 7/8 of memory, compared to raw R8G8B8A8_UNORM. The cost is quality, obviously.

 

The details vary: http://msdn.microsoft.com/en-us/library/windows/desktop/hh308955%28v=vs.85%29.aspx

 

For example for your normal maps, you might want to use non-compressed formats. But it all depends on how it looks, it has to first look bad enough to reach for a higher quality solution.


Edited by pcmaster, 06 February 2014 - 09:06 AM.


#4 eppo   Crossbones+   -  Reputation: 2624

Like
1Likes
Like

Posted 06 February 2014 - 09:23 AM


Could I for example save alpha in normal map textures in the 'Z' channel, which is always sort of the same?

 

It's not always the same, but its value can be derived of the other two components.

 

D3D10 added the BC5_SNORM 2-channel format which lets you store the x and y channels in the normalized [-1, 1] range. The z component can then be re-calculated in-shader. This format provides high quality compression for normal maps.



#5 8up tuotlo   Members   -  Reputation: 120

Like
0Likes
Like

Posted 08 February 2014 - 11:14 AM

DXT it is Compression for DDS;

DXT1 it is strongest compression but it is no oportunity to save alpha channel;

DXT3 is like DXT1 but you can save alpha channel and it takes double memory instead of DXT1;

in d3d9 it is posible to use DXT1 - DXT5 compression for Direct3DTexture9 elements

if you load compressed texture witch function D3DXCreateTextureFromFile()

compression will be automatically taken and applied from file (it means yor texture will be compressed not only on hard disk but too in video memory)

in function D3DXCreateTextureFromFileEX() you may to set image format (for example A8R8G8B8 or DXT1) to any texture

 

you may use any compression for normal maps but CAREFUL normal maps is more sensetive for resolution and compression

than diffuse map!

 

if you will be save normal map in two channels it will takes some calculations in pixel shader and its hard to deside what is more valuable video memory or pixel fill rate


Edited by 8up tuotlo, 08 February 2014 - 11:21 AM.


#6 phil_t   Crossbones+   -  Reputation: 4094

Like
1Likes
Like

Posted 08 February 2014 - 12:46 PM

Here's a good link for advice on compressing normal maps with DXT: http://blogs.msdn.com/b/shawnhar/archive/2008/10/30/dxt-compression-for-normalmaps.aspx



#7 C0lumbo   Crossbones+   -  Reputation: 2498

Like
1Likes
Like

Posted 08 February 2014 - 04:31 PM


- How about texture compression?

(my normal map tool, Shadermap, has possibilities to save the maps as "DDS DXT 1 / 3 or 5" for example)

- What exactly is DDS DXT?

 

This is a really, really good article explaining the BC formats, starting with the DXT1-5 and then going on to talk about the newer DX11 level ones, which you can't use but are still worth knowingabout. http://www.reedbeta.com/blog/2012/02/12/understanding-bcn-texture-compression-formats/

 

My rule of thumb is to always use DXT compression for diffuse maps, and only roll it back to bigger formats if it looks really bad, which for textures destined to be used on 3D models is really quite rare

 

Normal maps are trickier, as the article suggests, using DXT5 with X encoded in the RGB, Y encoded in alpha and Z reconstructed seems reasonable. Note that the increased complexity of the shader as you reconstruct the normal won't necessarily mean that the shader is slower than an 8888 solution. The fact that you'll be fetching 1/4 of the data might* more than compensate for the extra calculations that the shader has to do. If you don't want to invest the time in modifying your shaders so you can use DXT5, then use a 16 bit texture format like 565 as it'll half your texture footprint for a pretty minimal effort.

 

*I say might. I strongly suspect it will be a win on most graphics cards, but a lose on some others. Graphics programming sucks sometimes.



#8 cozzie   Members   -  Reputation: 1765

Like
0Likes
Like

Posted 12 February 2014 - 01:54 PM

Thanks, I'l get into the links.
For diffuse maps I'll play around with DXT-3 and 5 (not sure yet what 5 brings compared to 3), with this I'll include the alpha map in the diffuse texture to save an extra texture for blended materials. I'm fully using directx3dtexture9 objects (and d3dx) so this should work fine.

On normal mapping for now I'll stay with DDS format for keeping it structured/ standardized, but without DXT compression.

#9 C0lumbo   Crossbones+   -  Reputation: 2498

Like
1Likes
Like

Posted 13 February 2014 - 01:03 AM

Thanks, I'l get into the links.
For diffuse maps I'll play around with DXT-3 and 5 (not sure yet what 5 brings compared to 3), with this I'll include the alpha map in the diffuse texture to save an extra texture for blended materials. I'm fully using directx3dtexture9 objects (and d3dx) so this should work fine.

On normal mapping for now I'll stay with DDS format for keeping it structured/ standardized, but without DXT compression.

 

If you're not sure which to use, use DXT-5 instead of DXT-3, I can't think of any real-life situations where DXT-3 is the better choice (DXT3 vs DXT5 is often referred to as a choice between sharper and smoother, but this is nonsense IMO). Unless you specifically only want 16 different shades of alpha for some reason, use DXT5.



#10 MJP   Moderators   -  Reputation: 11774

Like
2Likes
Like

Posted 13 February 2014 - 01:32 AM

The only difference between DXT3 (AKA BC2) and DXT5 (AKA BC3) is how it stores the alpha value. In DXT3 the alpha value is explicitly stored as a 4-bit value per texel. In DXT5 the alpha value is interpreted based on a min/max alpha per 4x4 block and 16 indices. DXT5 tends to be more useful for real-world cases, since alpha is usually coherent across an image. 



#11 cozzie   Members   -  Reputation: 1765

Like
0Likes
Like

Posted 13 February 2014 - 02:04 PM

Thanks




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS