Copy Link
Add to Bookmark
Report

A Fast Approach at Real-Time Phong Bump Mapping

DrWatson's profile picture
Published in 
atari
 · 25 Nov 2023

A Fast Approach at Real-Time Phong Bump Mapping
(maybe)
by Frenzy / TeSkO


This is an idea about how to do real-time phong bump mapping. I'm not sure if it will work or if there are any shortfalls in this approach. Please do not flame me if this sounds absolutely wrong. It was an idea and I have yet to implement it. I just thought I'd write it down for people to read and maybe add some CONSTRUCTIVE advice. Of course, if you've done bump mapping and you know that this is not the way to do it then please tell me :) Don't tell me the slow interpolating normals method. Thats not any good for real time! Whatever your thoughts, at least it might make you think or at least come up with an idea of your own..

The Idea

You firstly have two maps. One is the texture map and the other is a bump map. They are identical except the bump map is precalculated and does not represent pixel colour like the texture map. If you were to draw them both on screen you'd see they look like each other but the bump map would have weird colours :)

First thing you should do is calculate the theta values for each vertex in the polygon. Just like in angular interpolated phong. You take the dot product of the light vector with your vertex normals.

 cos THETA = Lx*Nx + Ly*Ny + Lz*Nz 
THETA = ARCCOS(cos(THETA))

Now its time to texture map. I'm assuming a linear distortional texture mapping approach. I don't think perspective corrected texture mapping is a good idea for this :) Interpolate your U,V coordinates like you would normally but also interpolate those theta values like you would in phong. Now, your ready to draw a scan line. You have, or at least should have two things.. A set of U,V coordinates to index into the texture map and a THETA value. This is where we start the bump mapping..

Pull out a pixel from the texture map using the U,V coordinates. Call this pixel colour 'C'.

Next pull out a byte (not a pixel colour) from the bump map using the same U,V coordinates. Call this value 'D'.

Now, the bytes in the bump map should be of signed magnitude.

We now add the D value to your THETA value. This displaces the theta value by a small amount. Now, we compute the shade/intensity of that colour 'C'.

We use a lookup table structured like this:

                     IntensityTable[colour][shade];

colour is the colour of the pixel you are working on, in this case 'C'. shade is the shade of the value we want for that colour.

We also have some more work to do. We have to precalculate a table I'm going to call this PhongIntensityTable. This will be calculated like so:

             PhongIntensityTable[0..256]=cos(THETA)*MAXSHADES;

Still with me? Hope so..

This is what we do.. Using our displaced THETA value we calculate the colour to plot like this:

  PixelColour = IntensityTable[C][PhongIntensityTable[THETA]]

Then we plot PixelColour where we would of ploted the original value of 'C' if we were only texture mapping.

Keep doing this until we have finished the scan line and move onto the next. This might sound slow but its only using lookups. The only calc's your doing is the interpolation which you would do anyway and that single add in the loop.. All tables are pre-calculated.

Has this gave you any amazing idea's? Are you totally in agreement with me? Are you completely bamboozled?? Whatever your thoughts please tell me and let me share in your ideas too :)

Byeeee

Signed,
Paul aka Frenzy
EMAIL: p.adams@wlv.ac.uk

← previous
next →
loading
sending ...
New to Neperos ? Sign Up for free
download Neperos App from Google Play
install Neperos as PWA

Let's discover also

Recent Articles

Recent Comments

Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT