Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 


Submitted by Si Brown, posted on April 16, 2002




Image Description, by Si Brown



These screenshots are taken from a small project I undertook about a month ago to integrate ODE, DirectX and stencil shadowing into a single demo.

ODE is the Open Dynamics Engine - an open source rigid-body physics simulator, written by Russ Smith. This demo uses version 0.03. The stencil shadowing is performed using the standard "Carmack's reverse" method on convex bodies. The basic algorithm for each light is:
  • Project the body onto the plane normal to the light direction
  • Compute the convex hull on the plane
  • Extrude this hull into a shadow volume, being careful to cap before the far clip plane
  • Using the shadow volumes, additively render the scene into the frame buffer
This works fine for the directional lights used in the demo, and could easily be extended to more useful point and spotlights.

The end result is what I hope is a fun demo. The player controls a buggy in a simple world containing plenty of dynamic objects to smash into and ramps to drive off. Many thanks to the population of #flipcode on ETG for their invaluable comments, suggestions and artwork. :) The demo uses vertex shaders for geometry processing, so unless you own a card with hardware shaders (e.g. GeForce3) you will need at least a 800MHz CPU to get a decent framerate. The demo requires Windows 2000/XP with DirectX 8.1 installed.

The demo binaries (which include the textures) and the full project source code are avaiable here:
  • iotd-04-16-2002-buggydemo-binary.zip (389k)
  • iotd-04-16-2002-buggydemo-source.zip (50k)
  • The source is all C++ (with a bit of vertex shader assembler) in a Visual Studio .NET project.

    Si Brown


    [prev]
    Image of the Day Gallery
    www.flipcode.com

    [next]

     
    Message Center / Reader Comments: ( To Participate in the Discussion, Join the Community )
     
    Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
     
    KieranIsOK

    April 16, 2002, 05:13 PM

    Brilliant! A really, really lovely demo.

     
    Si Brown

    April 16, 2002, 05:14 PM

    Yep a stencil buffer is *required*. I could test for it first and only enable shadowing if present, but since the demo started off being about shadowing I thought "hmm, no." :)

     
    Dr.Mosh

    April 16, 2002, 05:31 PM

    It may be my IE that is borked. But I have no firewall at home, but there IS one at work.
    Thanks VERY much for the http links!!

     
    elJaco

    April 16, 2002, 05:32 PM

    I assume you did not press F11?

     
    MC BAXTON

    April 16, 2002, 05:34 PM

    Thanks for info but I have DirectX 8.1 (4.08.01.0810)
    also my card supports stencil buffer. So reason is in another place ... Yes I have a source.
    Thanks anyway

     
    elJaco

    April 16, 2002, 05:49 PM

    I've got the source, but can I use it?

    Any thoughts of legal issues?

     
    ShockBoy

    April 16, 2002, 06:03 PM

    I'm pissed. I got to the top of the tower, and fell off right when I was rounding the last turn.

    *grr*

    Looks good. I love the physics, but the car turns too quickly

     
    Ian Romanick

    April 16, 2002, 06:09 PM

    I don't think you mean the convex-hull. Isn't it just the outline of the object (wrt it's project to the light's plane)? I looked back at Carmack's e-mail on the subject, and he seems to think "anything that requires finding convex hulls in realtime is starting to sound like a Bad Idea." I have to agree. Finding the convex-hull, even in 2D, can be very, very time consuming.

    If that's what you're actually doing, how are you doing it so fast? :)

    http://developer.nvidia.com/docs/IO/2585/ATT/CarmackOnShadowVolumes.txt

     
    ndx

    April 16, 2002, 06:10 PM

    Yeah, turns fairly quickly, but it'd be great if analog joystick support was implimented wouldn't it? :D

     
    Jeff Quesnelle

    April 16, 2002, 06:15 PM

    Software shaders. That can't spell a high FPS for me...

     
    Si Brown

    April 16, 2002, 06:16 PM

    The use of ODE is restricted to the terms of the LGPL. Check http://www.q12.org/ode/ for details to make sure that using my code doesn't violate ODE's license.

    Consider my stuff to be released completely without license - i.e. do what you want with it. However, if the code does help you out then I'm always grateful for links/acknowledgements back to my site. ;-)

    Ta,
    Si

     
    Si Brown

    April 16, 2002, 06:18 PM

    I have just been sent some modified code that adds joystick support. I'll integrate and post a link to some updated code soon. :)

    Ta,
    Si

     
    Si Brown

    April 16, 2002, 06:27 PM

    Have a look at the source. I *am* finding the 2D convex hull every frame, using an algorithm called QuickHull. (Plus the implementation I did was written quickly using the stl, and as such has room for some heavy optimisation)

    Well, actually that's not entirely true, I *was* finding the convex hull every frame until I realised that for objects with smooth normals (i.e. not face normals) this produces some horrible lighting artefacts for faces that turn away from the light before the normals do. So the spheres now have a special-case shadow volume construction that does a more accurate shadow volume without considering the actual points of the mesh.

    Wrt finding convex hulls for more convex objects, I'd agree that in general this is a Bad Idea (TM), but this demo was written knowing that I'd only ever throw around convex solids. For more complex scenes (with a more general topology on objects) then something else should be used to find the silhouettes and construct the shadow volumes. As you no doubt already know, nvidia have some good documents on more "robust" shadowing techniques.

     
    Si Brown

    April 16, 2002, 06:44 PM

    [hulls for more convex objects]
    ... needs to be ...
    [hulls for more general objects]

    Note to self: preview first. :)

     
    stefan/dxm

    April 16, 2002, 07:09 PM


    WHERE'S THE THUMBS UP BUTTON??!!
    oh well:

    http://ff00ff.dezin.dk/~stefan/thetop.jpg

    :D

    KUN *FUH* ELITE MEGAHAPPY HARDCORE DRUNK CAR ;D

     
    Sniper BoB

    April 16, 2002, 07:11 PM

    WOW! very cool! I get a solid 50 frames persecond with one light and 40 to 50 with 2. I am running Windows XP Home, Geforce3, AMD 1600XP+ and 512 DDR ram.

    I would like to know some more stats like poly or shadow counts, anyone have these numbers for me?

    keep up the good work

    SniperBoB

     
    magpulse

    April 16, 2002, 07:19 PM

    Nice work. I noticed the car has some air control, especially when going over jumps. Not side to side, but forward and back while in the air.

     
    ent

    April 16, 2002, 07:22 PM

    >Hey Si, would you have enough time to write a good tutorial on >Volume Shadow capping? I'm having major trouble with that.

    http://developer.nvidia.com/view.asp?IO=robust_shadow_volumes

    But as far as i know, Si is not using carmack's. reverse method. With this method you don't need far plane capping because it's in the infinite (w coordinate == 0)

     
    doz

    April 16, 2002, 07:22 PM

    I got to the top of the tower... then i fell off NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!

     
    Si Brown

    April 16, 2002, 07:33 PM

    Carmack's Reverse doesn't imply an infinite projection AFAIK. It's just the technique of using the zfail test to modify the stencil buffer rather than the pass test.

    With an infinite projection you obviously don't need to worry about clipping at the far plane because there isn't one. Carmack's Reverse is a solution to near-plane clipping problems, because it works even when the camera origin is inside a shadow volume.

     
    MC BAXTON

    April 16, 2002, 07:42 PM

    I received some lovely emails from you ;p
    note that my e-mail is correct now, so if you want to shut up me send e-mail. So far it was not as childish shit as posted here in reply to my posts
    thanks

     
    Frank L

    April 16, 2002, 08:22 PM

    I have a geF 3 and it doesn't work (same error as above)

     
    llyod

    April 16, 2002, 08:41 PM



    Wow! I'm simply loving this demo! Got a nice 20-30 fps on my p850+GF2 (in windowed mode)


    But am I the only one thinking.... STUNT CAR RACER REMAKE!!!! ;)


    Lloyd
    2dnow.zenzer.net

     
    disableddan

    April 16, 2002, 08:45 PM

    DUDE!!!! That rocks!! I think the car slides too much but the beach balls are totally awesome! It would be nice to be able to lock the camera behind the vehicle as well.

    Excellent work!!!

     
    Punchey

    April 16, 2002, 09:13 PM

    Wow! I never knew that! That's great stuff. Where'd you learn that?

     
    jeff weber

    April 16, 2002, 09:37 PM

    I downloaded the code and tried to compile it. I get one compile error:

    c:Downloadsiotd-04-16-2002-buggydemo-sourcebuggyteststdafx.h(9): fatal error C1083: Cannot open include file: 'ode/ode.h': No such file or directory

    it appears this has not been included in your zip file. I'm not a c++ guy, so maybe i'm missing something... besides the file. :)

    -jeff

     
    ghost007

    April 16, 2002, 09:42 PM

    aaawwweeeessooommmeeee =)

    This is killer app man. I really love this! Though, try and increase the friction on the ground. The buggy rolls all over the place =)

     
    henry ludemann

    April 16, 2002, 10:20 PM

    This is one really fun app... love the shadows. I'm going to have a look at that physics engine.

     
    SirKnight

    April 16, 2002, 10:28 PM

    I must say your little game here is quite fun! At first it was hard to do much since its like driving on ice but after a while i got a hang of it. At times it reminded me of hauling ass through mud spinning around and stuff. I've discovered you can do some cool freestyle tricks when using the backspace key and driving around at the same time. :)

    Oh also, it ran at 49 to 50 fps (dipped in the low 40s a few times, wierd) on my P3 600, 256MB ram, GeForce 4 Ti 4400, Windows XP. Very cool.

     
    Craig Rennie

    April 16, 2002, 10:43 PM

    It's damn cool. Although I had to run it in 320x240 :)
    I DID get ~15fps though on a k6-2 350 with TnT1.
    But yeah, I have to agree with most people here, the friction from the ground seems too low.

     
    This thread contains 120 messages.
    First Previous ( To view more messages, select a page: 0 1 2 3 ... out of 3) Next Last
     
     
    Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.