Micropro's picture

Shadow Mapping

hi please i have an example to show me the best way to draw shadow mapping


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
migueltk's picture

Here is an adaptation of Cascaded Shadow Maps NVIDIA

the Fiddler's picture

Shadow mapping depends on shaders and FBOs. If you are familiar with these concepts, shadow mapping is relatively easy to implement.

I've obtained good results using this tutorial: Soft shadows with VSM. The original paper is also useful as a reference.

Edit: ninja'd

puklaus's picture

I have simple shadow mapping in my old csat engine (http://www.opentk.com/project/CSat) but I suggest that you write your own, it's not so hard to do (first draw your scene from light, to fbo, and only z-values, then draw your scene from camera and compare if pixel is invisible from light (shadow) or not).
And later use CSM or PSSM so you can use directional light (sun).
Aactually if using light frustum when render from light, it does directional light (used it in my xsat-engine (xna+monogame project, its sourcecodes isnt available yet).

Micropro's picture

thank you for all suggests but how can i compare Pixels between Camera Position and light position this is my code when read pixel

            byte[] pixel = new byte[3];
            int[] viewport = new int[4];
            Gl.glGetIntegerv(Gl.GL_VIEWPORT, viewport);
            Gl.glReadPixels(x, viewport[3] - y, 1, 1, Gl.GL_RGB, Gl.GL_UNSIGNED_BYTE, pixel);

pleas i need a simple example
pleas it's so important for me

the Fiddler's picture

You perform the comparison in a fragment shader, not GL.ReadPixels().

There is some example code here and here, but unless you know how to use shaders and FBOs (render-to-texture), this is not going to be very helpful.

You really need to know how to use shaders before you implement shadow mapping.