Jump to content
  • Advertisement
Sign in to follow this  
ic0de

Is this technique possible?

This topic is 2498 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I came up with this idea on a new way to do 3d shadows but I don't know if it already exists or if its even possible on modern hardware, it involves integrating shadows and lighting into the same shader, its pretty simple so here it goes:

Step 1.

While light is being calculated for a pixel using blinn-phong or any other algorithm store light intensity of that pixel but do not yet apply it to that texture.

Step 2.

Determine if there is a polygon between that pixel and the light source to do this calculate a vector between the pixel and the light. (Not sure how to do this yet without looping through every polygon)

Step 3.

If that vector passes through the polygon then calculate the distance between the light and the polygon and subtract the distance from the pixels intensity.

Step 4.

Apply the pixels intensity to the texture.

DONE

If all this works I should end with shadows that get softer the farther the caster gets from the receiver but also vary slightly in tone based on the shape of the shadow caster.

Now, does this technique already exist? if so whats it called. Are modern computers capable of this technique?

Share this post


Link to post
Share on other sites
Advertisement

Determine if there is a polygon between that pixel and the light source to do this calculate a vector between the pixel and the light. (Not sure how to do this yet without looping through every polygon)

As with most things, the devil is in the details - and you've hit the particular detail right on the head.

Most shadowing algorithms work exactly as you describe, except that it is prohibitively expensive to loop through every polygon in the scene, so instead we pre-render all those polygons into a depth-map, from the perspective of the light (this is known as a 'shadow map'). Then rather than checking every polygon, you can just perform one lookup in the shadow map, and all is good...

Unfortunately, this still requires rendering a shadow map for every light that casts shadows, and each shadow map requires rendering the full scene, so we are still performance limited to a handful of shadow-casting lights.

Share this post


Link to post
Share on other sites

Hi I came up with this idea on a new way to do 3d shadows but I don't know if it already exists or if its even possible on modern hardware, it involves integrating shadows and lighting into the same shader, its pretty simple so here it goes:

Step 1.

While light is being calculated for a pixel using blinn-phong or any other algorithm store light intensity of that pixel but do not yet apply it to that texture.

Step 2.

Determine if there is a polygon between that pixel and the light source to do this calculate a vector between the pixel and the light. (Not sure how to do this yet without looping through every polygon)

Step 3.

If that vector passes through the polygon then calculate the distance between the light and the polygon and subtract the distance from the pixels intensity.

Step 4.

Apply the pixels intensity to the texture.

DONE

If all this works I should end with shadows that get softer the farther the caster gets from the receiver but also vary slightly in tone based on the shape of the shadow caster.

Now, does this technique already exist? if so whats it called. Are modern computers capable of this technique?
You'll get soft shadows, maybe, but incorrectly. Although the intensity of a shadow can fall off with distance, soft shadows come about as a result of area light sources. Your algorithm does not account for this, nor does it take into account distance from polygons' edges. There are some cases, for instance, where a far-off object will always be in complete shadow, even if that shadow has soft edges.

The rest of the algorithm has the general feel of ray traced shadows. As to step 2., you can do this by shooting rays from the light (this is called shadowmapping). Shadowmapping is implemented very well on the GPU, and is easily possible in real-time. There are many papers about altering the basic shadowmapping algorithm (yes, with depth) to achieve a soft shadows look.

-G

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!