Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Dot-product bump mapping & texture effects

This topic is 6328 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

I''m in the processing of lighting my landscape. I''m using lightmaps, but want to move to dot-product bump mapping instead in order to enable dynamic lighting capabilities. I was wondering if I can use texture effects like mip-mapping, and/or texture filtering, and/or texture compression with these special dot-product textures (which really store vectors inside. sneaky-sneaky!) Your thoughts are more than welcome, Malachii.

Share this post

Link to post
Share on other sites
Yep, a normal map is just a straight everyday texture. Its just pure coincidence that its RGB values happen to encode a vector. Theres no restrictions I know of on any hardware - its just the same as any other texture in a multitexture op.

There are issues however - consider what happens when stretch a texture encoding normals with bilinear filtering turned on... you can end up with normals which are less than unit length - what that means to your per-pixel lighting is you get a slight darkening of those pixels (the normal is shorter than it should be, try it with vertex normals - the same happens per pixel).

Mipmapping can be good if your normal maps have a lot of detail in them - otherwise the scene can end up looking very "fizzy" in the distance. You might need to do some careful experimentation with the filter options between mip levels (tri-linear etc) - because you can end up causing the same filtering.

If you''re on nVidia GeForce 3 hardware, they have a new texture format called HILO which encodes normal maps differently giving much higher precision to the normals in the map.

What looks best and which artefacts are tolerable depends very much on your own situation. Some stuff you should try experimenting with in the stage where the normal map is set:

Mipmaps generally
Different filtering types
Detail normal maps (for _really_ high precision bumps)

Theres loads of other stuff you can do once you get a directional or infinite point light going such as attenuation maps, normalisation cubemaps (for per pixel specular and sorting out the shortened normals mentioned above), glossmaps if doing a specular pass, the clever 2 instruction Newton-Raphson normalisation if you''re using pixel shaders etc etc...

Once you have dot3 going for a directional light, you might discover a faster way of doing back/mirrored shadow elimination - lots of fun to be had once you start thinking about what happens with a dot3.

Finally to save you the work, heres some info about hardware which supports dot3:

only the following can do it:
- 3DLabs Permedia 3 and above
- nVidia GeForce 1 and above
- ATI Radeon and above
- PowerVR Kyro and above
[and some others I''m not allowed to mention]

GeForce 1 & 2 will only let you use 2 different textures in the multitexture setup (say normal map and base texture). You can use the same texture twice in 2 different stages, but it is limited. You can probably still do extra cunning things if you remember that the alpha channel is still available in the texture. [GF3 will do more - and you get pixel shaders anyway]

Permedia 3 has pretty similar setup restrictions to GeForce

Radeon will let you use 3 textures.

Kyro will let you use 4 textures over all stages IIRC, but their architecture works in a very different way so the restrictions are different.

Simon O''''Connor
Creative Asylum Ltd

Share this post

Link to post
Share on other sites
You said that the alpha channel is still available. Is that in the dot-product texture? If so I guess it makes sense. 24 bits for R,G,B (woops, X,Y,Z I mean), and the remaining 8 for alpha? That means I could use the remaining 8 bits as a dark map for my landscape right, because as you were saying, shorter normals mean darker areas, right? So an alpha of 128 should darken those points if I do things right. So I could light my terrain, and have pre-determined ray-traced shadows applied to my landscape as well as the shading (dor-product), all in 1 rendering pass? That would be sweet! And the second pass could apply the general grass texture. Hmm. I like it.

The only trouble is how to deal with my lighting when people don''t have dot-product available. I guess I could simply use a pre-generated light map (probably the same image I used with the dot-product generation tools).

Thanks for the wonderful info,


Share this post

Link to post
Share on other sites
Yup, you have an alpha channel ("scalar") available in both the normal map texture and possibly also the base map texture.

How much you can use them for depends on which texture stage states you can persuade the driver to do before it fails ValidateDevice - sometimes some very twisted thinking is required, and sometimes what the drivers won''t pass can be very annoying.

From what you describe about storing a dark map, you''d do it something like:

Stage0Colour = NormalMap DOTPRODUCT3 Diffuse
Stage1Colour = Current MODULATE BaseMap
Stage2Colour = Current MODULATE NormalMap|AlphaReplicate

[Assuming Diffuse stores the L vector - usually in texture space]

Whether it will work is down to luck, the drivers, the hardware and whether its raining in Manchester.

Another common use of the alpha channel of the normal map is as a gloss map when doing a specular pass, you do N.H in stage 0, then modulate with the gloss map. [Look at Malice on the Xbox for an example of a game using Dot3 specular which could do with some proper gloss mapping]

Generally you don''t want to shorten the normals, just point them away - the shortening is a side effect of filtering which results in the L dot N being done with a shorter N - I suppose you could use it to your advantage somehow.

Simon O''''Connor
Creative Asylum Ltd

Share this post

Link to post
Share on other sites

  • 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!