Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Shadowmapping...  (Read 420 times)
serial
Customers
Community Member
*****
Posts: 299


« on: July 09, 2008, 01:26:09 AM »

Was thinking about this today.  Havn't had time to test the idea out. but was just curious if this would work for shadowmapping.

First you get the distance from the lightsource to the point on the landscape.  Then you cast a ray from the light source to the same point.  You then compare the length of the ray compared to the distance.  If the length of the ray is shorter then that means that part of the landscape is shadowed. 

Does that sound about right?  I spent just a little bit of time on this today but wanted to have some idea of what I'm doing before I get there.
Logged
Zaknafein
Customers
Community Member
*****
Posts: 2599


WWW
« Reply #1 on: July 09, 2008, 10:50:26 AM »

Hahah my friend, you've just invented shadowmapping. Smiley
That's exactly what shadowmapping is about, and how most (or all) of the implementations work. That's called depth comparison.
Logged

zaknafein.
>> the instruction limit : my blog & samples repository! <<
zwiglm
Customers
Community Member
*****
Posts: 118


« Reply #2 on: July 10, 2008, 08:25:10 AM »

First you get the distance from the lightsource to the point on the landscape.  Then you cast a ray from the light source to the same point.  You then compare the length of the ray compared to the distance.

Forgive me for my bad english, but I don't get. Isn't that the same in your explanation?
1. distance form light to landscape
2. ray from light to landscape.

Where/what's the difference?
Logged

Cheers,
Martin
serial
Customers
Community Member
*****
Posts: 299


« Reply #3 on: July 10, 2008, 12:47:45 PM »

Okay imagine it this way.  Lets say there is a brick wall about 200 meters away.  In front of that brick wall is a chair.  If you shine a laser pointer at every point on the brick wall the length of the laser would be 200 meters except where the chair is.
So for everypoint where distance <> laser length that point on the wall would be shadowed.

Getting the distance does not take in to count collisions.  You are check for collisions with the ray that you are cast.  If you get a collision and the distance returned is shorter you have a shadow. 

Another way you could do is check to see if the normal of a surface is pointing towards a light if it is then the surface is probably receiving light.
Logged
WEst
Community Member
*
Posts: 799

Daniel Martinek


WWW
« Reply #4 on: July 10, 2008, 01:27:08 PM »

Getting the distance does not take in to count collisions.  You are check for collisions with the ray that you are cast.  If you get a collision and the distance returned is shorter you have a shadow. 

But normally you use not raycasting, but render the scene from the lights point of view using a depth shader, that returns the depth of the scene seen from the lights position. And compare this depth- or shadowmap to the normal scene rendering in a shader.
Logged

Greetings

Daniel Martinek
Lead Programmer
Roaming Nova Studios
Shadowsong
Customers
Community Member
*****
Posts: 132


« Reply #5 on: July 11, 2008, 05:33:15 AM »

Is there any tutorial out there that explains FROM SCRATCH how to create simple directional shadowmapping? Where from scratch means I am able to make a shader but I have no idea about shadowmapping, depht mapping etc...
Logged
WEst
Community Member
*
Posts: 799

Daniel Martinek


WWW
« Reply #6 on: July 11, 2008, 07:05:27 AM »

I would recommend this article it's for DX9/XNA but you can easily convert it to TV3D:

http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Shadow_map.php

BUT, I also would advise that you look a bit into shadowmapping and the methods behind it (it's explained at the beginning of the article), because you will get very weird and strange problems in the beginning, and it's difficult to find them if you don't know about how it works.
Logged

Greetings

Daniel Martinek
Lead Programmer
Roaming Nova Studios
Shadowsong
Customers
Community Member
*****
Posts: 132


« Reply #7 on: July 14, 2008, 01:32:07 AM »

Thanks I'll read it carefully.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks