   Recommended Shadow Technique
  From what I hear, they all sort of suck but I was hoping someone could recommend me a shadowing technique just from the following things I want...1. Clean Edges - Any kind of edges other than jagged! I set up basic shadow mapping and the edges were horrid. I didn't feel like jumping through the hoops to fix it and I'm not sure it would be worth it in the end.2. Decent Speed - I want something that can run at 60fps. I realize different techniques vary for different situations so this is just a factor in the list.3. Directional Light - Most of the lighting will be done by the sun.4. Simplicity - I don't need everything to look realistic or anything just decent and easy to implement if possible.My demands may possibly infer to a technique that doesn't exist yet but never hurts to ask I suppose.   
  What's your target platform/API?   ;  I'm using XNA for Xbox 360.   ;  You should be using shadow mapping with a relatively high resolution and an orthographic camera for directional lights. I'm not sure if you would consider jumping these through hoops, but I would definitely try using a screen-space blur, jitter (noise), or averaging multiple samples (PCF?) a try. They're certainly easier than PSSM or anything like that.You could try lightmapping if you aren't using a dynamic environment. It's fast and can look incredible. Other than that though, shadow mapping is THE standard in lighting.Example of sampling multiple times:float Depth = 4.0f;Depth -= IN.sun.z>tex2D(samp5, IN.sun.xy+float2(0.00015f,0.00015f)).r;Depth -= IN.sun.z>tex2D(samp5, IN.sun.xy+float2(-0.00015f,-0.00015f)).r;Depth -= IN.sun.z>tex2D(samp5, IN.sun.xy+float2(-0.00015f,0.00015f)).r;Depth -= IN.sun.z>tex2D(samp5, IN.sun.xy+float2(0.00015f,-0.00015f)).r;Depth /= 4.0f;   ;Quote:Original post by AntiGuy1. Clean Edges - Any kind of edges other than jagged! I set up basic shadow mapping and the edges were horrid. I didn't feel like jumping through the hoops to fix it and I'm not sure it would be worth it in the end.Most shadow mapping techniques are simply extensions of the basic idea, with lots of hoops to jump through to get softer edges :(PCF is probably a decent place to start, for simplicity.Quote:3. Directional Light - Most of the lighting will be done by the sun.As Akitsune says, directional lights just require a different projection matrix. If you need the light to cover a large area (e.g. a outdoor scene lit by the sun), then cascades are a good idea (e.g. PSSM, CSM).   ;  Lightmapping seems to be more of an indoor thing from what I can tell. But seems interesting.I didn't try a screen-space blur, would that be similar to using a linear filter in the samplerstate? That helped a bit. Most interestingly though, Also I tried bumping up the texture resolution to 8192x8192 and got more of the result I was looking for although I was still using a smaller far plane for my frustum. Unfortunately a 8192 size is far to slow in real-time. I wonder if there's a pre-rendered solution.   ;  The two main shadow techniques available are shadow maps, and shadow volumes (stencil shadows). Stencil shadows used to be pretty popular, but in the past few years have been almost completely superseded by the various shadow mapping techniques. I'd recommend going with shadow maps since (IMO) they're simpler in concept than shadow volumes, and since there's a wide range of optimizations and improvements available. In terms of shadow maps, for a directional light you're probably going to want to use some variant of cascaded shadow maps (AKA parallel split shadow maps). This helps avoid perspective aliasing, by giving you a better distribution of shadow map resolution compared to using just one big orthographic projection fit to the view frustum. For further reducing shadow map aliasing, you can use filtering. Typically PCF is used, which essentially takes several samples from the shadow maps and performs a weighted average to combine them. On the Xbox 360 you should definitely be able to do 4 samples no problem and stay above 60 fps. You may be able to get to 8 or 9 with some optimized shader code, depending on your shader, shadowmap resolution, and your rendering pipeline. There are also various ways of averaging the samples...for instance with 4 samples you can use standard bilinear filtering. Or you can sample in a grid and just average the results which is simple, but gives kinda blocky results. Or you can trade aliasing for noise by using a jittered sample pattern. This PDF has a brief rundown of a few options.Aside from PCF, there are also a few techniques (ESM, VSM) that allow for hardware filtering and prefiltering (blurring) of shadow maps. They can have great quality, but introduce new problems. There's a good overview of them here. In general it can be hard to get them to look right for all scenes, and the 360's lack of hardware filtering for floating point formats kinda makes them a no-go.The above poster mentioned screen-space blur...you can do this if you render the results of your shadow test to a screen-sized texture and then blur that. However with this technique you will get light bleeding across geometry edges unless you take depth into account while blurring. Plus you will end up with a penumbra size that's equal everyone on the screen, which will blur out distant shadows.If you want, I have an older sample here that uses XNA and runs on the Xbox 360. It uses deferred shadow maps, which means that the results of the shadow test are done in a single full-screen pass rather than as the geometry is being rendered. This nicely decouples the shadowing from the geometry, making it easier to organize shaders. It also sets you up for doing a screen-space blur, if you want to go that route. However it also has a few versions of PCF implemented, which you can switch through to see how they look (just be aware that for the edge-tap smoothing, I didn't spend time to optimize it so it's a little ugly and perhaps slower than it could be). That page also has a link to a version that uses cascaded shadow maps.   ;Quote:Original post by AntiGuyLightmapping seems to be more of an indoor thing from what I can tell. But seems interesting.I didn't try a screen-space blur, would that be similar to using a linear filter in the samplerstate? That helped a bit. Most interestingly though, Also I tried bumping up the texture resolution to 8192x8192 and got more of the result I was looking for although I was still using a smaller far plane for my frustum. Unfortunately a 8192 size is far to slow in real-time. I wonder if there's a pre-rendered solution.To see (dynamic) lightmapping done well, check out Wolfire games' blog/screenshots. Sure, you won't be able to put something like that together in a day, but it's a possible (but difficult) technique.Screen-space blur is just a blur shader applied to a render target which renders only shadows.By a large resolution I meant 1024x1024! What are you trying to create shadows for? Terrain and structures? Small characters? Have you tried PCF? Moving your camera height/zdepth?EDIT: Study MJP's link! I remember seeing that example a long time ago and it's still a great example of how to do shadows well (and now it's even faster).   ;  Can someone explain what, in a nutshell, actually is the difference between PSSM and CSM please?Ta   ;Quote:By a large resolution I meant 1024x1024! What are you trying to create shadows for? Terrain and structures? Small characters? Have you tried PCF? Moving your camera height/zdepth?I was really hoping to lump everything together on one map, terrain, structures, characters etc..Much of what's mentioned hasn't been tried and I think there's a lot of information here to go on for me to try something. I was really hoping I could be lazy about it : )Thanks for the help guys.   