#### Archived

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

# Normalised high-exponent specular bump-mapping?

This topic is 5506 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I''m having problems getting specular bump-mapping working on my GF3. Currently I''m interpolating the Half-Vector (in tangent space), doing a dot-product with the pixel normal, and doing a look-up in a texture to raise the result of the dp3 to a certain power. The problem with this is that the half-vector is not normalised per-pixel, which can cause very obvious artifacts (darkening) on any surface that isn''t highly tesselated. So, I''d like to have normalised specular bump-mapping with arbitrary powers. I''ve tried doing various per-pixel tricks to raise the power of a normalised dp3 result (eg. doing a bunch of multiplies) but they''re too limiting and introduce banding artifacts. I''m thinking the solution will lie in transforming my normals from tangent-space to another space and looking up in a cube map. This would give me a normalised result with arbitrary specular-power. The problem is that the only examples I''ve seen that use these more complex instructions (texm3x3vspec in DX8) transform the normals into world-space and then look up in a fixed env-map. I''m trying to use this for point lights, so the direction of the light will be different per-vertex, so I can''t just use world space!!! Specifically I envisage having a cube map with a highlight pointing in the +ve y direction, so I need to transform the normals to whichever space would make this highlight point towards the light. Any ideas? Cheers Matt

##### Share on other sites
  dp3 r0, v0_bx2, v0_bx2  mad r0, v0_bias, 1-r0, v0_bx2

[A vector normalise using the Newton Raphson method to get a pretty good approximation to the sqrt]

The banding is a fair bit trickier to solve. If you''ve only got 8 bit precision to play with inside a pixel shader register you end up killing the lower bits very quickly with the exponentiation and so you get banding.

There are some interesting hacks and solutions to the banding problem on the nVidia and ATI websites IIRC.

Phong specular requires ~4 times less exponentiation than Blinn so just changing to that (although more work per pixel) might be enough to reduce the banding to a suitable level.

I suppose a nice fake might be to plug the result of N.H or R.V into a 1D lookup table texture representing a *non-linear* ramp so you get less of a range of specular, but smoother highlights where they''re most noticable. You could even have a 2D map and plug some other function into the other axis to give more control.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

##### Share on other sites
That''s a very cool trick!
Unfortunately I don''t think I''ll be able to put it to much use.

The problem is that I need to do:

Normalise
Dp3
Raise to power

So if I use that trick to normalise the half vector, I still won''t be able to use the result of the dp3 to look up in a 1d specular map (On GF3 that is)...

In this situation I may as well use a normalisation cube map instead. Unless I''m missing something?

Cheers,

Matt