[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] shadow demo



Hello,

I found some things to improve the quality of the shadow mapping, and
written in more comments.

http://rene.f0o.com/~rene/stuff/shadows_rd.zip


It also by default uses a polygon as a floor, and a teapot from GLUT.
There's a constant at the top of demoShadows.py which changes this.
However the objects you draw are a very simple part of this demo, they
could be anything really.  The complexity comes from the other code.

I think maybe the glPolygonOffset call may have something to do with
it... but haven't managed to get the call to do anything.  I tried
glScale, and glTranslate, but that seems to be wrong - and in one
paper it says you can't use translate/scale but have to use
glPolygonOffset.


The main thing which improved quality for me was to use
GL_DEPTH_COMPONENT32 instead of GL_DEPTH_COMPONENT with the
glTexImage2D call.  GL_DEPTH_COMPONENT lets the driver pick the
resolution (which for this Imac as only 8 bit).

I haven't managed to increase the resolution of the shadow map successfully.


Apparently it's possible to do shadow mapping in one pass... but it's
more complicated.

However I think using display lists will be quite quick even though
it's done in 3 passes.

eg.
# 1. draw stuff first time, and create display list at the same time.
# 2. second pass reusing display list.
# 3. third pass reusing display list.


Another improvement would be to anti-alias the shadows some how.
There's a whole bunch of different methods for doing this mentioned in
the literature, but I haven't tried anything yet.



cheers,






On Thu, Mar 13, 2008 at 4:00 AM, Ian Mallett <geometrian@xxxxxxxxx> wrote:
>
>
> On Tue, Mar 11, 2008 at 10:32 PM, René Dudfield <renesd@xxxxxxxxx> wrote:
> > Hello,
> >
> > I noticed with this cool shadow demo:
> > http://www.pygame.org/project/556/
> >
> > On this ATI card I have, I had to change the glAlphaFunc to use
> > GL_LESS... which I think is because of float inaccuracies.
> >
> > #Set alpha test to discard false comparisons
> > #glAlphaFunc(GL_EQUAL, 1.0)
> > glAlphaFunc(GL_LESS, 1.0)
> >
> > Any ideas on how to make the shadows softer? Either by making the
> > shadow map a higher resolution or some other algorithm?  I tried
> > changing shadowMapSize = 2048, but it looks like the shadow map is
> > wrong some how.  Like it isn't the correct scale, or something.
> >
> I tried increasing the shadow map resolution, but although the resulting
> shadow was very nice and smooth, the area it covered on the landscape was
> tiny. The resolution appeared to be inversely proportional to the area that
> could be shadowed.  I think a well-commented simple demo that shadowed a
> single quad with another quad might actually be more useful than a
> full-blown demo such as this.
> > cheers,
> >
> Ian
>