Shadow maps are rendered every frame.

Blender's renderer and external renderer export

Moderators: jesterKing, stiv

Post Reply
ideasman
Posts: 0
Joined: Tue Feb 25, 2003 2:37 pm

Shadow maps are rendered every frame.

Post by ideasman » Sat May 24, 2003 9:32 am

Hi all.

I have noticed that a render will first render the shadow map(s) before starting the main render.

This is fine BUT the shadow maps are rendered every frame.
This is annoying when you have a still scene and lots of lights that cast shadows.

It would be great to be able to only render the shadow map once.

This could be done in the same way as environment mapping
(Only Once) / (Every Frame) / (Save current) etc.

z3r0_d
Posts: 289
Joined: Wed Oct 16, 2002 2:38 am
Contact:

Post by z3r0_d » Sat May 24, 2003 9:02 pm

but if any object moves they have to be recalculated again
and there is a lot of processing power going into the transformations so that the lamp can cast shadows.

maybe you should consider using fewer lamps, or less detail (or precalculated radiosity) instead of complaining about the proformance hit of more lamps.

(or a render farm)

ideasman
Posts: 0
Joined: Tue Feb 25, 2003 2:37 pm

Post by ideasman » Sun May 25, 2003 4:38 am

Yep, I have looked at all the options you suggested, Radiosity mucks up uv mapping, there is a work around but adds complexity. less lights are ok but I need soft shadows and I am only using about 40 lights anyway, The scene is large so I need the shadows to look good close up as well as far away so I can't drop the shadowmap res too much.

There is allways a way, I just wanted to know if someone had found a workaround/solution, mabe somthing has been added to the dev ver. etc.

I have access to a render farm, well 50 x 2ghz pc's that I can use overnight or on the weekend, but I'd rather use my PC. because I won't allways have a renderfarm handy.

Little_Cube
Posts: 18
Joined: Tue Oct 22, 2002 5:27 pm

Post by Little_Cube » Wed May 28, 2003 9:14 am

I also think that having the ability to save and load shadowmaps would be a very useful addition to Blender, concerning both speed and, more important, flexibility in lighting.

Goran

cmccad
Posts: 0
Joined: Mon Apr 07, 2003 11:58 pm

Post by cmccad » Wed May 28, 2003 4:42 pm

Just had a brain storm. Save the shadowmap for things that don't move and combine it with a shadowmap of the things that *do* move. Worthless if your lights move, but otherwise can save cpu time and memory.

Will this work, or am I missing something?
Casey

Icalvert
Posts: 0
Joined: Mon Jan 13, 2003 2:20 pm

Post by Icalvert » Wed May 28, 2003 9:57 pm

The shadow maps must be stored on the ram temporarily, would it be very difficult to create an external file from this (similar to pov-ray's photon maps)?

I think it would be very useful for fly-by animations.

cmccad
Posts: 0
Joined: Mon Apr 07, 2003 11:58 pm

Post by cmccad » Wed May 28, 2003 11:39 pm

Hummm....
<thinks for a while>

It seems to me that there are at least two ways to go about doing this, one for flyby animations, the other where the camera is still.

Method one would be memory intensive in that it would store one shadow map for each light showing the shadows of only the stationary objects. The other shadow map, for animated objects, would be discarded and re-calculated every frame, and then combined with the stationary shadow map and applied to the final image. This is probably the most generally useful since it can be used in any situation.

Method two would be less memory intensive. What would happen is that blender would render out the scene with an extra image layer for stationary shadows. This would be the same size as the rendered image, and be combined with the animated shadows for the final image. This would only work if the camera does not move, rotate, or zoom, and so it would probably be less useful.

Since I have no idea how blender currently handles shadow maps, I can't say how this would be implemented. In my very unprofessional opinion, I'd say that it could be done. If blender already stores the shadow map for the entire frame, then this should be really simple! Of course, the memory requirements would double. :lol: Or would they?

<thinks some more>

Maybe the stored map could be the starting point, with the moving items being added one by one. This way, each object would only consume a portion of the memory (using some sort of bounding box routine, I suppose).

<thinks even more>

Wouldn't the distance from the lamp need to be saved as well? Picture an airplane flying in stationary clouds. The shadow is on the clouds and on the ground, and sometimes there are shadows on the airplane, and the plane casts shadows on some clouds. Once the renderer calculates the stationary shadow map, the depth information is lost - the map is a two dimensional, flat plane. :( If z-depth were included (maybe a mini-map for each object, with a z-depth for each mini-map) then the memory requirements would go up, and up, and up...

<gives up thinking>

I knew this would turn out to be more complicated than I first thought. :(

Casey

Little_Cube
Posts: 18
Joined: Tue Oct 22, 2002 5:27 pm

Post by Little_Cube » Thu May 29, 2003 2:30 am

I'm not a native english speaker and it's possible that I missunderstood you, but I think you have a wrong concept about what a shadowmap is (if I'm wrong I appologize). You talk about shadowmaps as if they are an image rendered from the camera point of view that gets composited with the beauty pass, thus generating the shadow areas. Shadowmaps are infact z-depth images (I think they may have subtle differences, but their purpose is the same: storing distance from a given origin). The shadowmap is rendered from the lamp's point of view (a spotlight can be easily transformed into a camera), and, in the rendering stage, it's used to check if the part of the object that's being rendered is occluded from the lamp's rays by another object. If the distance of the rendered part is bigger than the value stored in the coresponding pixel of the shadowmap, then the part is in shadow and the lamp isn't used in it's shading calculations. I know I didn't explain it in the best possible way, but I hope you get my meaning.

Goran

cessen
Posts: 109
Joined: Tue Oct 15, 2002 11:43 pm

Post by cessen » Thu May 29, 2003 4:21 pm

ideasman wrote:It would be great to be able to only render the shadow map once.

This could be done in the same way as environment mapping
(Only Once) / (Every Frame) / (Save current) etc.
A very good idea, ideasman. Thanks. :-)
Now all we need is someone who is willing to wade through the code and impliment it. (At the moment I am busy working on other things in Blender.)

Little_Cube
Posts: 18
Joined: Tue Oct 22, 2002 5:27 pm

shadowmap depth filters

Post by Little_Cube » Thu May 29, 2003 4:59 pm

On a related point. Has anyone considered using a midpoint depth filter for shadowmaps? While it is a little slower than a minimum depth filter, it get's rid of the bias problem.

<edit>
Maybe I should have started a different thread...
</edit>

Goran

cessen
Posts: 109
Joined: Tue Oct 15, 2002 11:43 pm

Post by cessen » Thu May 29, 2003 5:20 pm

Little_Cube wrote:On a related point. Has anyone considered using a midpoint depth filter for shadowmaps?
I assume you're reffering to the Woo trick (at least, I think that's what it's called), where the depth of a shadow-buffer pixel is set to the average depth of the two closest depths.
And yes, I had thought of that. Unluckily, it would be rather difficult to impliment with Blender's current rendering set-up. Also, it could potentially interfere with halo-lights (though one could always have two shadow buffers per light: one for surface shadows, which would use the midpoint depth, and one for halo shadows, which would use the nearest depth).
Little_Cube wrote:While it is a little slower than a minimum depth filter, it get's rid of the bias problem.
Well, it wouldn't actually get rid of the bias problem, but it would *very* significantly reduce it.
Another trick that can minimize the bias problem is to do interpolation (of depths) between the centers of the shadow-buffer pixels.
And if you combine the two tricks (interpolation and Woo), the bias problem is even more significantly reduced. But you still need to be able to tweak the bias--it's just that it can be much, much smaller relative to the shadow-buffer resolution.

Of course, then there's "deep shadow maps" (and variations thereof). And with that, you have to modify the tricks a bit in order for them to still work. But it can be done. :-)

IainH
Posts: 3
Joined: Wed Oct 16, 2002 10:21 pm

Post by IainH » Thu May 29, 2003 5:45 pm

I have a particular interest in NPR render styles. Perhaps someone who understands shadow maps can tell me if this is possible...

As I understand it, a shadow map is essentially a greyscale image recording the depth of scene objects from a lamp, which tells the renderer how much light reaches a spot in 3d space from that lamp. So... can a bitmap image of (say) pencil cross-hatching be combined with that info to generate an image where shadows are not solid colour, but have the appearance of being drawn?

To me (unqualified as i am) this does not sound too hard. As I describe it it is not a true 3d effect - the shading is simply superimposed and the scale would not change with the distance of objects from the camera. Someone with much better 3d geometry knowledge than myself may be able to map the effect to the actual world geometry in the same way as uv mapping etc.

Anyway, just a thought...

Iain

Something a bit like this infact...
http://www.finalrender.com/products/fea ... 37&FID=312

Little_Cube
Posts: 18
Joined: Tue Oct 22, 2002 5:27 pm

Post by Little_Cube » Thu May 29, 2003 6:57 pm

cessen wrote:
Little_Cube wrote:On a related point. Has anyone considered using a midpoint depth filter for shadowmaps?
I assume you're reffering to the Woo trick (at least, I think that's what it's called), where the depth of a shadow-buffer pixel is set to the average depth of the two closest depths.
Yup, that's the one.
cessen wrote:Another trick that can minimize the bias problem is to do interpolation (of depths) between the centers of the shadow-buffer pixels.
I thought that Blender already does this. Too bad.
IanH wrote:As I understand it, a shadow map is essentially a greyscale image recording the depth of scene objects from a lamp, which tells the renderer how much light reaches a spot in 3d space from that lamp.
Just a technicality, but as I said before a shadowmap is used to check if light from a lamp reaches a point in space, not how much. To the renderer there isn't a difference if an object is behind a spotlight or if it's shadowed by another object. In both cases the rays from the spot don't reach the object surface and no shading takes place. That's why I don't understand how shadow-only lamps work :)

Goran

Veronika_
Posts: 0
Joined: Thu Mar 31, 2011 8:56 am

Post by Veronika_ » Thu Mar 31, 2011 9:04 am

Ideasman is excellent! I using about 45 buy cialis lights because i also need rather soft shadows.

Post Reply