migueltk's picture

Improving shadow mapping in two passes


He adaptado la demo "Shadow Mapping" del libro "OpenGL Superbible, 3rd Edition" para OpenTK, se puede descargar desde aquí

El problema es que la calidad de las sombras no es muy buena, ¿Como podría mejorarse? ¿Alguien con más conocimientos que yo podría reescribir la demo para mejorar la calidad en dos pasadas ?

(Google Translator)

I have adapted the demo "Shadow Mapping" the book "OpenGL Superbe, 3rd Edition" to OpenTK can be downloaded from here

The problem is that the quality of the shadows is not very good, how could it be improved? Someone with more knowledge than I could rewrite the demo to improve quality in two passes?

Inline Images
Shadow Mapping in 2 Passes


Comment viewing options

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

El link del programa, segundo intento:


the Fiddler's picture

I don't know if you can create smooth shadows without shaders.

I have attached a slightly modified version that compiles with OpenTK 1.0 (needs both OpenTK.dll and OpenTK.Compatibility.dll). On my nvidia card, this generates an InvalidEnum exception at line 281, you might wish to look into that.

SimpleWindow.cs16.13 KB
migueltk's picture

I have tested your implementation and to operate normally, to make the program work the graphics card must support the extension GL_ARB_shadow_ambient, I think your card supports it, check it out.

the Fiddler's picture

Unfortunately, it seems that GL_ARB_shadow_ambient isn't supported on my card. (This is a mobile Quadro, equivalent to a 8400M, using the 195.62 drivers. OpenGL version is 3.2). However, the application seems to run fine when I remove this line.

Hortus Longus's picture

migueltk, on the lines 242/243, when you increase GL.Translate/GL.Scale from 0.5f to 0.99f, the result becomes better. I think you have some operations to finetune.

migueltk's picture

The best results are obtained with the following code, lines 309 to 311:

            GL.LightModel(LightModelParameter.LightModelAmbient, noLight);
            //GL.Light(LightName.Light0, LightParameter.Ambient, ambientLight);
            //GL.Light(LightName.Light0, LightParameter.Diffuse, diffuseLight);
ShadowMapping2Passes2.png46.46 KB
Shadow2PassOtk1.zip8.55 KB
Hortus Longus's picture

Perhaps. ; -)

Possibly a small help for you, if you regard some of these articles:
(do not follow the links to his website on simsysbr.com, they are gone)
Simple Ray Tracing in C#
Simple Ray Tracing in C# Part II (Triangles intersection)
Simple Ray Tracing in C# Part III (Reflection)
Simple Ray Tracing in C# Part IV (Anti-Aliasing)
Simple Ray Tracing in C# Part V (Texture Mapping)
Simple Ray Tracing in C# Part VI (Vertex Normal Interpolation)
Simple Ray Tracing in C# Part VII (Shadows)

Solution Architect: "But you can use patterns"
Young Developer: "Yes, but can I get it as an ActiveX control?"