Thread: Ray Traced Terrain Self Shadowing Tut

  1. #1
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640

    Ray Traced Terrain Self Shadowing Tut

    hey y'all. I found this great tutorial on the web for ray traced terrain self shadowing. its an improvement on the one from gamedev.net. It gets a huge performance gain by storing data about the heights of vertices that caused shadows. So rather than comparing against all vertex heights along the ray to test for a shadow, you compare against their height plus the height difference of it and the vertex that shadows it. They claim a shadow map that took over 10 minutes with the gamedev.net algo ran in under 10 seconds with theirs. Its a cool idea, and I've already got a few more that would further increase the best case performance.

    If i ever get an ounce of free time this will be the next thing I impliment.

    Bon appetite:
    http://gpwiki.org/index.php/Faster_R...in_Shadow_Maps

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I may do real time shadows using shaders. Pre-computing them is ideal, but I'd like to alter it on the fly.

  3. #3
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968
    Well, terrain seems to be something that you can be safe mapping out before hand.. Generally your terrain isn't going to move... Unless you have realtime shadows via HDR lighting..

    But for things that move, yeah realtime is better ..

    Check out some Oblivion demo videos (the first one) for dynamic soft shadow demonstration, its pretty sweet..
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

  4. #4
    ---
    Join Date
    May 2004
    Posts
    1,379
    On a side note: How good are wiki style tutorials?

  5. #5
    Call me AirBronto
    Join Date
    Sep 2004
    Location
    Indianapolis, Indiana
    Posts
    195
    is it not possible to do ray casting effectivly on the fly?

  6. #6
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    is it not possible to do ray casting effectivly on the fly?
    In a word. No.

    With a heightmap of 1024x1024 you would have to re-compute the vector of light from the point in question to the sun to see if it lies in shadow. Not very real time. I could speed it up with a quad tree, but it would still be slow.

    Re-casting the map is not an option.

  7. #7
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    >Re-casting the map is not an option.

    not all at once anyway. I was thinking about this, calculate the the shadow map from the suns initial position and its position 500 frames later. Then you could distribute the showmap computation over many frames, like 500 or so, then interpolate the current shadow map with the next one each frame while computing the succesor. This would give you continuous shadow transitions.

    Calculat S0 and S1 as part of initialization
    Interpolate from S0 to S1 over N frames
    Distribute the calculation of S2 over N frames
    after you reach N frames, start interpolating from S1 to S2, throw out S0 and start calculating S3

  8. #8
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    Couldent you calculate constant shadows first, then calculate moving ones every frame? Better yet, flag the moving ones so when they're moving they get their shadow redrawn. It would lag less than calculating all the terrain's shadows, unless, it all happens to be moving :P.

    Lol one look at that tutorial told me its wayy beyond me atm :P.
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  9. #9
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    >unless, it all happens to be moving :P.

    its not the geometry thats moving, its the light source. So all of the shadows change as the light source moves.

    You could pre-calculate all of the shadowmaps, but that would be quite a bit of data and would keep your lights path fixed.

  10. #10
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    Ah, so you mean if theirs a dark allyway with a lamp, and a player pushs it over, the shadow would recalculate itself? I guess with the sun where all shadows need to be recalculated, it becomes a pritty crazy task. I'd say its to small to make a huge impact on a game. I guess if you calculated what would happen ahead of time it would help, but you'd still have to reassign every shadow. And then theirs resizing and redrawing. For a single player game, I guess you could just recalculate, resize, and redraw every shadow in visible distance, but that could be quite a bit. Especialy if only a few of the shadows are fixed. (A bunch of moving targets or something.) Its still a pritty big task for a pritty small portion of a game.
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  11. #11
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212
    Is there anyway I could (other than recursive wget ) download that wiki for use offline.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help designing a recursive function.
    By broli86 in forum C Programming
    Replies: 3
    Last Post: 07-24-2008, 12:45 PM
  2. Continous LOD Terrain Source... Released!
    By Perspective in forum Game Programming
    Replies: 13
    Last Post: 04-17-2006, 11:21 PM
  3. New terrain engine
    By VirtualAce in forum Game Programming
    Replies: 16
    Last Post: 03-16-2006, 02:47 AM
  4. Ray Traced Reflections
    By Perspective in forum Game Programming
    Replies: 14
    Last Post: 08-31-2004, 03:29 PM
  5. Terrain algos
    By VirtualAce in forum Game Programming
    Replies: 1
    Last Post: 04-10-2004, 02:50 PM