Making shadows in OpenGL (or DirectX) is not a trivial task. I'm not surprised that you would have trouble with the NeHe tutorial on the subject. The important thing to understand is that, in order to determine the shadows that the objects will cast, you need to render the scene from the perspective of the light point. If you look at a scene from the point of view of the light, everything that makes it to the "screen" is a surface that is lit by the light, everything that doesn't is covered by a shadow (at least with respect to that light source). So, the basic idea to create a shadow in OpenGL is to first render the scene from the point of view of the light source, and generating masking textures from that rendering pass. Once you have the masks, you blend them (by multiplication) with the surface textures of your objects and render the scene in the final point of view (camera).
Obviously, the technical details of how to do this can be complicated, it traditionally involves using the stencil buffer to record the masking texture. I'm not sure what the state-of-the-art is on this subject. Many modern multi-pass rendering and scene graph rendering employ render-to-texture capacities of most modern GPUs.
Thank you, your description helped a bit. I will try to read the tutorial again and see if I can get it working. Ill post back if I need more help.
After reading it again I guess I don't fully understand the stencil buffer. Is it some kind of storage space on the GPU? How exactly does it work? Could I also implement shadows as a 2D image that I overlay on top of my scene before drawing it? Could I do some math and create a set of triangles that represent the triangle and are placed just above the surfaces on which they are set?
The stencil buffer is just a part of the framebuffer (which is the image that is rendered to the screen). The framebuffer is basically an image whose pixels are defined by different values, like red, green, blue, alpha, depth, stencil, and others. Obviously, RGB stores the color, Alpha stores the transparency, Depth stores the "distance" to the screen, and the stencil is just an additional value that is available to the programmer to store anything else he might want to store on a per-screen-pixel basis.
I don't know much about making shadows, and my knowledge of it goes back many years ago, so I really don't have much more to say about it.
Maybe this tutorial will be more helpful and current than NeHe's tutorial.
Isn't it about time forums rewarded their contributors?
Contribute to this discussion and earn rewards points that can be cashed out for dollars.
Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...
Hi. so this is actually a continuation from another question of mineHere but i was advised to start a new thread as the original question was already answered.
This is the result of previous question answered :
code for the listbox - datagridview interaction
At the top of the code ...
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...