Lighting without Shaders

I am currently doing volume rendering using 3D textures and am very happy with the results thus far. I would like to know if there is a good solution to lighting the scene. I can compute the normal for each voxel using the gradient. I would prefer to use the core functionality of OpenGL over writing my own shader. I have been looking into cube maps using GL_NORMAL_MAP and filling it with my gradient values. I would then use multitexturing to apply a normal to each outbound fragment. Is this the best solution?

You need the normal vector somewhere. You could create an object space vector map using software gradient analysis and simply send that as another texture for DOT3 in a texenv combiner.

Preprocessing the data avoids the need for a sophisticated shader, it is also a lot faster than the multiple texture taps you’d otherwise need in a shader.

Thank you very much. That is kind of what I was leaning toward. The thing that still has me a little confused is how to perform the dot3 between the normal and the light vector if the light or the object is moving. That is why I was thinking I may need a GL_NORMAL_MAP, so that lighting would take care of itself as if it were any other geometric object.

hi,jtipton,I have the same problem with you.
At present I do a precomputation to get gradient for all voxels, and this process takes quite a lot
of time. Then I store the gradient in a RGB texture for light-computing in fragment shader. This
approach costs many precious video-memory while its speed is slow. :frowning:
So I am also wishing to have a faster method using core functionality of Opengl.Any help will be greatly appreciated.

There’s no need for new OpenGL extensions to shade volume data. GLSL is core functionality and it is sufficient.

For local illumination you can either pre-compute gradients (- memory consumption, + performance) or compute gradients on-the-fly (+ memory consumption, - performance):

Simple extensions like ARB_texture_env_dot3 and more sophisticated programmable fragment shading extensions like ARB_fragment_program or GLSL can compute the contribution of each light source. It is also possible to employ cube environment maps for more complex lighting scenarios.

For global illumination, Joe Kniss has presented very nice work, e.g. in

If your performance is too slow, think about performance optimization strategies:

  • Klaus

Thank you klaus!
Compared to my current method, can the dot3 light approach gain better performance?

You can only achieve very simple lighting with the dot3 extension (single light source, only diffuse). For such simple lighting it might be a little faster than using a fragment program.

  • Klaus