views:

99

answers:

1

How would I implement loading a texture to be used as a specular map for a piece of geometry and rendering it in Directx9 using C++?

Are there any tutorials or basic examples I can refer to?

+4  A: 

Use D3DXCreateTextureFromFile to load the file from disk. You then need to set up a shader that multiplies the specular value by the value stored in the texture. This gives you the specular colour.

So you're final pixel comes from

Final = ambient + (N.L * texture colour) + (N.H * texture specular)

You can do this easily in a shader.

Its also worth noting that it can be very useful to store the per texel specular in the alpha channel of the texture. This way you only need one texture around, though it does break per-pixel transparency.

Goz