Soft(-er) Shadows

This is a modified version of Sothh ‘Shader-less’ Shadows, it’s not shaderless, it’s a bit slower, but it looks real nice :wink:

The goal was to have nice shadows for geometry with alpha textures.

Here’s a screen shot:


Here’s the source (shadows.rar 2.6MB):
sendspace.com/file/87hpzk

You can edit the shader (gray_invert.sha, line 21 and 22) to have the shadow sharper(it’s at 0.3 by default) or darker (I wanted them gray, not black, so my default is at 0.8).

If you don’t like it… well, there still a decent (and free) tree model in the pack :smiley:

Looks nice!
How about trying to make it work for multiple objects spread throughout the whole view?
I’m really missing some sort of automatic soft shadows in panda. Just a line of code and all you see is shadowed :smiley:

If you make the buffer bigger and the camera lens wide enough it can cover the whole scene. You can switch to a orthographic lens to have shadows like from a directional light.

As far as multiple objects, you only need to put a hide mask on the object that the shadows are cast on, and setup the lens, buffer, camera, shaders… but you can put that all in one convenient class Here a shot from my dev-game, where I use this:

Just tried out on linux with an onboard intel gfx chip. Put aside the low framerate caused by the half-transparent tree, it runs great. congratulations :slight_smile:

I’m using the softer shadows by wezu, and they are really easy to implement and look great. Performance is also good.

There is one thing I would like to get support for. The shadows textures are projected on the ground nodes, and I have the shadow camera following me when I am driving through the database. Everything around me casts shadows on the ground nodes, as expected. But the ground nodes just outside the shadow camera’s frustum sometimes give gray flickering artefacts. I can put the shadowcamera higher so that the area it sees gets larger, and the flickering outside the camera frustum is hardly noticed, but then the quality of the shadows is reduced. Does anyone have a suggetsion on how to solve the gray flickering artefacts ?

Hi I’m having a little trouble with my models from blender becoming invisible with these shadows, I found a fix but it only works on nonetextured objects, ( Yabee wont export properly with the ’ fix ’ enabled, could someone explain what settings I need so the objects wont become invisible? Thanks.

I haven’t taken a look at the shader, but I noticed in World of Tanks they gradually fade object shadows with distance. So either doing a fade in the shader or perhaps fading the edge of the projected texture (if its using shadowmaps like I think it would be).

We solved the problem firefly had by setting the projected textures border to white or near black…

self.Tex=Texture()
self.Tex.setWrapU(Texture.WMBorderColor  )
self.Tex.setWrapV(Texture.WMBorderColor  )
self.Tex.setBorderColor(Vec4(0.04,0.04,0.04,0))       
self.shadowBuffer = base.win.makeTextureBuffer("Shadow Buffer",1024,1024,self.Tex)

For the invisible problem…hmm…maybe it’s my shader, try this: in the shader gray_invert.sha change the last line from

o_color = float4(g, g, g, 0);

to

o_color = float4(g, g, g, 1);

Thanks! that fixed the invisibility issue! :smiley: