Implemented Shadows

Shadows are finally working in GLGE. It’s taken a little longer then expected as rendering a depth map to a texture doesn’t seem to be working in any browsers and checking out the firefox code it would seem it’s just not supported there yet.  Until it is, It’s been hacked a bit encoding and decoding the depth from the rgb values. It works but it’s a more intensive an operation then it should be so spares use is recomended! This one works on firefox but I’m getting slow frame rates and I’m still not sure why, the JS isn’t that that complex and the frame rate is fine on chromium so it’s not the GFX card end either.

In addition this week I’ve added parsing of color values attributes in the XML so you can now specfy light/material colours using the normal HTML syntax ie “#ff0000″ “red” “rgb(255,0,0)”.

Click here to view the latest demo

Demo Video:

Tags: , ,

18 Responses to “Implemented Shadows”

  1. gero3 says:

    very nice

    works in chromium ;)

  2. richtaur says:

    FYI in the latest Minefield and Webkit nightlies I get a few alerts:

    ERROR: 0:58: ‘assign’: cannot convert from ‘const int’ to ‘float’

    Looks like WebGL isn’t available on Macs :( Video looks great tho! I was surprised when reading about WebGL that shadows aren’t part of light sources, seemed odd to me.

  3. richtaur says:

    er, meant WebGL not available on *Chromium* for Macs.

  4. Giles says:

    Very cool! I’ve been intending to do a lesson on shadows sometime soon, perhaps now I can peruse your code for clues? ;-)

  5. horace says:

    wow! that’s so awesome.

    i just still don’t know how we are supposed to do collision detection/physics with javascript. there will be huge performance problems…

    javascript sound support doesn’t seem to ne that great either. can you play many samples at once? do stuff like pitch shifting? all very important for games…

  6. horace says:

    can webgl be driven from silverlight/moonlight? maybe that’s the solution? since there is a C# port for the bullet physics engine.

  7. Paul Brunt says:

    You’re right it would be a little old school but it’s somewhere to start, and I loved Quake :-) We also have access to the GPU now, so I can see no reason why it couldn’t be used for a little heavy lifting on the collision detection as well as rendering graphics.

    For sound developments checkout:
    http://vocamus.net/dave/?p=955

    As for O3D, I’ve no idea where that’s at now, I had a play with it a couple of months back but it just kept crashing, so I got frustrated and gave up on it.

  8. Paul Brunt says:

    I think people are under estimating what can be done with javascript now. It may not be C but as far as interpreted languages go it’s way up there. But, it’s also getting faster at what is really an amazing pace the browser devs are really doing a great job.

    At the very least javascript should be on par with C speeds of a decade ago and games like quake emerged more then a decade ago. I’d guess that C is about 10-15x faster then javascript(conservative guess, at least in modern browsers) and processors are certainly more then 10x faster then a decade ago ;-)

    I think the main reason people perceive javascript as slow is the fact that it’s been used primarily for manipulating the DOM and drawing unaccelerated graphics. There are many overheads there that aren’t there when your just using it for processing.

    As for sound, things are still a little lacking but I believe things are moving along well so it will only be an issue short term.

    Some interesting comparison benchmarking:
    http://shootout.alioth.debian.org/u32q/benchmark.php?test=binarytrees&lang=all

  9. horace says:

    yes, probably quake would be very doable already with webgl and javascript but working with a old-school bsp system like that (which requires long precompiling and limits the useable geometry to convex blocks) isn’t very fun anymore. :)

    “”"As for sound, things are still a little lacking but I believe things are moving along well so it will only be an issue short term.”"”

    are there any developments in this regard? i didn’t find anything with google.


    by the way, what is happening with o3d? there is no news anymore since months on their blog. is it still alive or will webgl be the future?

  10. horace says:

    “”"We also have access to the GPU now, so I can see no reason why it couldn’t be used for a little heavy lifting on the collision detection as well as rendering graphics.”"”

    how? with shader hacks?

    it would be pretty cool if there was access to openCL from javascript. :)

  11. Paul Brunt says:

    yeap, I was thinking shader hacks. I really do hope the browser does get openCL soon. I think it would jump start something very cool indeed. Developers are bound to turn to it for heavy processing to speed up there code. Then we’ll get some mad advances.

  12. seth says:

    from what i could tell of the sample, you aren’t dealing with self shadowing (character to self). is that correct? is the precision too little and the artifacts apparent?

    btw, don’t overestimate javascript either. C is probably closer to 100x the performance, especially in this arena. the overhead required to sift though binary data or deal with large scale scene management can be considerable. but quake seems doable.

    openCL binding would be nice, but that’s a long way off. openCL requires at least as much direct memory management and unless binary tools extensions are available, it would be quite frustrating. the time spent doing housekeeping in javascript could end up eating your gains.

  13. Paul Brunt says:

    There is a little self shadowing, check out the hat :-) but you’re right it doesn’t seem to have the precision. I had to set the bias so high to get rid of the artifacts that the shadow on the character all but disappeared :-( I’m hoping that when depth pixel formats are supported it’ll improve the situation.

    Hopefully, WebGLArrays will much improve the 100x estimate, but we can but try ;-) I’ll have to run some tests soon to see what can be achieved.

  14. [...] Brunt has managed to add shadows to GLGE! Shadows require some fairly complex trickery with frame buffers to work properly, and [...]

  15. seth says:

    agreed. i *think* (this has been said before) that we’re looking at the future standard for web 3d. it’s the beginning and more development has to happen, but 35% of browsers are looking to support it. and microsoft can only swing the momentum if they don’t do anything and wait for or help adobe to make a move through flash.

  16. Steve Elbows says:

    This demo has those pesky integer-float issues and wont run for me on webkit.

  17. SHAWN says:


    PillSpot.org. Canadian Health&Care.Special Internet Prices.Best quality drugs.No prescription online pharmacy. Low price pills. Order pills online

    Buy:Advair.Cozaar.Female Cialis.Aricept.Buspar.Ventolin.Seroquel.Amoxicillin.SleepWell.Nymphomax.Zetia.Lipothin.Lipitor.Benicar.Lasix.Zocor.Prozac.Acomplia.Female Pink Viagra.Wellbutrin SR….

Leave a Reply