Is this technique possible?

Started by
1 comment, last by Geometrian 12 years, 4 months ago
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?
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.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]


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

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

This topic is closed to new replies.

Advertisement