• Create Account

### #Actuallarspensjo

Posted 09 August 2012 - 06:54 AM

The question is how to get an decreasing shadow effect with distance from sun?

Some background:
• I am using shadow maps, a separate render pass with the camera up in the sky in using orthogonal projection with the depth buffer saved in a bitmap for the final render phase.
• My world is infinite in all dimensions. There will be objects above ground, unlimited. In theory, that means that there should always be shadows from the sun. But in practice, I want nice views instead of totally realistic views.
• The idea is to let the effect of the shadow decrease with distance between the object doing the shadow and the surface that is shadowed. Beyond a certain limit, there would be no shadow at all.
• It is easy to get a value for the distance, from the object casting a shadow to the surface, in the fragment shader.
This is where the problems start. The shadow map records the distances to the objects closest to the sun. If there are two objects casting a shadow on the same surface, the distance computation algorithm would be based on the object closest to the sun. This is not the result I want. I want the near distance object to cast a dark shadow, and the far distance object to cast a weaker shadow, outside of the shadow of the near distance object.

Edit: Of course I want decreasing shadow effects with distance from the sun, not increasing.

### #1larspensjo

Posted 08 August 2012 - 01:37 AM

The question is how to get an increasing shadow effect with distance from sun?

Some background:
• I am using shadow maps, a separate render pass with the camera up in the sky in using orthogonal projection with the depth buffer saved in a bitmap for the final render phase.
• My world is infinite in all dimensions. There will be objects above ground, unlimited. In theory, that means that there should always be shadows from the sun. But in practice, I want nice views instead of totally realistic views.
• The idea is to let the effect of the shadow decrease with distance between the object doing the shadow and the surface that is shadowed. Beyond a certain limit, there would be no shadow at all.
• It is easy to get a value for the distance, from the object casting a shadow to the surface, in the fragment shader.
This is where the problems start. The shadow map records the distances to the objects closest to the sun. If there are two objects casting a shadow on the same surface, the distance computation algorithm would be based on the object closest to the sun. This is not the result I want. I want the near distance object to cast a dark shadow, and the far distance object to cast a weaker shadow, outside of the shadow of the near distance object.

PARTNERS