Jump to content
  • Advertisement
Sign in to follow this  
Christoph

simple(?) bump mapping question

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

Hi there, I have implemented simple dot3 bump mapping (fixed function). The texture space light vectors are stored in the vertex color. That means that I have to disable lighting - otherwise the vertex color would be affected and thus the bump calculation would not work properly (for example a bright light could make the vertex color much brighter and thus change the texture space vector). How can I use per vertex lighting and fixed function bump mapping at the same time? Is there perhaps an alternative to storing the texture space vectors in the vertex color? tHx!

Share this post


Link to post
Share on other sites
Advertisement
Which devices are you targetting that do not support fragment shaders?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:

Which devices are you targetting that do not support fragment shaders?


My engine is fixed function based. For effects like bump mapping I cannot use shaders, as this would conflict with the structure.

Share this post


Link to post
Share on other sites
You can use an object space normal map. This means the normal map is created for a specific mesh, with vectors mainly +-Z on front and back, +-X on right and left, and +-Y on top and bottom. Because the map is designed for a specific object, you can't really share maps across multiple objects. You can then program your light vector in D3DRS_TEXTUREFACTOR / D3DTA_TFACTOR. You should multiply your light vector by the object's world transform (using TransformNormal, not Coord)... or perhaps the inverse of the world transform (I'm too lazy to work out which). This allows it to light correctly when the object is rotated.

The other, possibly better option if you want to learn it, is to use a vertex shader to do the tangent space transforms most dot3 shaders do, and a pixel shader to mix your lights. You can avoid the pixel shader if you're really against needing shader hardware, and your non bump lights are limited to grey, or a single color. In a vertex shader, output ((lightvector*0.5)+0.5) in diffuse color rgb, and output non bump light in diffuse color a. Then in one stage do your "dot3 diffuse, texture", and the next stage do an "add current, diffuse|alphareplicate", followed by a third stage to modulate(regular, 2X or 4X) by your diffuse texture.

You don't need shader capable hardware for that last technique. If you determine that vertex shader 1.1 is not available, just ask for a software processing device, as all vertex shaders can be emulated quite quickly on the CPU.

When coloring lights, you can stick the color into tfactor.

If all lights are one color, you can modulate by that color in a 4th stage.

If your bump light is colored, you can modulate by it in your second stage, and move everything else down a stage.

If your non bump lights are colored, you should either:
set the resultarg of stage 0 to TEMP, then in stage 1 modulate tfactor, diffuse|alphareplicate, and use stage 2 to add current,temp. Don't forget to change stage 0's resultarg back to current when you're done rendering.
OR:
If you caps say you have multiplyadd, set stage 1 to multiply tfactor and diffuse|alphareplicate, while adding current.

Share this post


Link to post
Share on other sites
Ok, I decided to use object space normal maps.

However, another problem came up:
I need a tool that converts my bump map to an object space normal map (with respect to the model). I know there are tools like nVidia's Melody, but they can only compute high poly normal maps. What I need is an individually designed greyscale bump map being converted to a normal map.

Do you know any tools/ algorithms that convert my bump maps?

Share this post


Link to post
Share on other sites
ATI's normal map tools have the ability to convert a tangent space normal map into an object space one. I have no idea how these tools work, as I've never used them, but they seem to have plugins for Max and Maya as well as stand alone EXEs. There is a readme that contains the command line options.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!