
Shadow casting
Posted Monday, 17 May, 2010 - 17:36 by TheNerd inHi Guys, The newbie is back.
I'm working on trying to get an object, say a sphere, to cast a shadow onto something else (say, a plane) because the sphere is in between the light and the plane. The opengl bible has a lot of math, but the page doesn't really render properly for me to see all of the symbols. before I go into doing this myself - is there already a means to implement shadow casting in OpenTK (without using Shadow maps?)\
Thanks!
TheNerd


Comments
Re: Shadow casting
OpenGL doesn't provide shadows out of the box (which means OpenTK doesn't either). I have implemented shadow mapping with OpenTK, which needed a fair chunk of code but wasn't all that complicated.
A quick search on "shadow casting tutorial" pointed at NeHe Lesson #27. It is written in C but someone has also ported it to C#. The code should be fairly trivial to port to OpenTK, just ignore the parts that create the window and OpenGL context (use OpenTK.GameWindow instead) and translate the OpenGL function calls to their OpenTK equivalents (e.g.
GL.Enable(EnableCap.StencilTest) instead ofglEnable(GL_STENCIL_TEST)).Re: Shadow casting
Hi Fiddler
I started out with NEHE 27 - porting it myself. I can't seem to find the C# port of this already...
So you are successfully running a real time shadow-mapper in your code? Hows the performance?
-TheNerd
Re: Shadow casting
Ah, you are right there's no C# port of this tutorial. My mistake.
Shadow mapping performance is pretty good actually, my last project runs in realtime on a weak 8400M card, using one directional and one point light with VSM-style shadows. HDR and relief mapping both have a larger impact on performance than shadow maps on that project.
Re: Shadow casting
Perhaps this will be good for something ... Node 1469
Re: Shadow casting
So is Shadow Mapping better (performance wise) than the algorithm offered by the NeHe tutorial? Maybe I should be focusing on real time shadow mapping instead of procedurally creating them.
Did you ever add your VSM code to OpenTK?
Re: Shadow casting
I'm still learning how to use OpenGL, it is too early to study vertex and fragment shader, for me.
I recommend this site, where they try to Variance Shadow Maps Variance Shadow Maps (William Donnelly, Andrew Lauritzen). If I had time would carry (port) the code of c++ to c# (OpenTK), but for now it is not possible, I have to dedicate my time to other projects and is now shaded flat enough for me.
A greeting ...
Re: Shadow casting
I downloaded their code and will port it over to C# (as best I can). If Fiddler doesn't already have the port/general library for this, I'll go ahead and send it to him.
Re: Shadow casting
No, I don't have a general library for shadows. While this wouldn't belong directly to OpenTK, it would be very useful as a tutorial/sample.
Re: Shadow casting
hmm ok so the demo in that site is an SDL based shader (a few of them) - this is beyond my skill level to port over to OpenTK as I think it would involve building the same shaders in GLSL. I'm trying to derive the algorithm from their paper so I can write it as a library (from scratch) instead, but wow, that math is pretty hardcore. The results are VERY good and have good performance stats, so this is definitely worth it (especially if I add an ambient occlusion section to complete my shadow library).
-TheNerd
Re: Shadow casting
I'm quite new to all of this, but does this post bear any relevance?