1
\$\begingroup\$

Using a gray-scale bump-map and N sources of colored light, what is the algorithm to render the light on the textured surface, assuming I have the angle(s) and distance of each light source? (I am pre-rendering in software).

I have the part where it renders light based on the position and angle of light source. My question is twofold:

  1. How do I decide on an RGB color based on multiple different light sources? Is it simply additive by nature?
  2. What do I do about cases where the angle is not a sufficient way to determine intensity? For instance when there is a deep caveat in the surface and a higher elevated area is blocking the light to that lower shaded area? How do you handle something like that?

enter image description here

\$\endgroup\$

2 Answers 2

2
\$\begingroup\$
  1. Yes, you simply add them. Stupid explanation: x photons from source 1 go in, y photons from source 2 in, so x+y photons go out. Normally, these processes are independent of each other.

  2. You can handle something like that by encoding visibility information into Spherical Harmonics. For a good explanation google for "Spherical harmonics gritty details". You would need to precalculate the visibility for each element of your bumpmap via raycasting* and store it in coefficients for spherical harmonic base functions. This might not to fast, but 1 used it for real-time shadowing in volume rendering.

You would do this raycasting in the 2D bumpmap with Bresenhams algorithm:

enter image description here

Starting at the green pixel, you would traverse along the red line in direction of your lightsource until you would find a value that would indicate a collision (yellow). If you end outside the image, you have no collision and your light source is visible.

1 Kronander J, Jonsson D, Low J, Ljung P, Ynnerman A, Unger J. Efficient Visibility Encoding for Dynamic Illumination in Direct Volume Rendering. IEEE Trans. Vis. Comput. Graph. [Internet]. 2011 Feb 3;18(3):447–62. Available from:http://www.computer.org/csdl/trans/tg/2012/03/ttg2012030447-abs.html

\$\endgroup\$
1
\$\begingroup\$

The technique I think you are looking for to achieve this is known as Parallax Occlusion Mapping and is an extension of Parallax Mapping.

Parralax Occlusion Mapping is a technique to interpret which texel to pick based on the viewing angle relative to the surface normal while taking into account the surface displacement provided by the bump map. Keep in mind that when you know which texel to pick you also know which (u,v) point on the triangle surface is being viewed.

What you should interpret using this technique is the texture coordinate for the given triangle that is illuminated by a given light source projecting a ray in a specific direction. So from here you should be able to calculate the per-pixel lighting incident on a fixed surface for the purpose of light baking similar to how you would without the bump-map (whatever technique you are using for this).

This should suffice for baking your diffuse illumination for that surface into some data source (added on top of the standard colour texture maybe?). However, handling specular illumination may prove more of a challenge and possibly can only be done in real-time as it is dependant on the viewing angle/position as well as light and geometry information.

This technique is often used in real-time and isn't so expensive that it necessitates baking. Consider adding it as a real-time extension to your system first as you will probably need this long term for dynamic objects to fit well with the rest of the scene.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .