doing static shadows in blender?

Hi,
Can static shadows be done in blender, rather than it automatically recalculating all of the shadows for each frame? (I’m using a large landscape with motion blurring animation) I could render it from above using an orthogonal camera and apply the shadowed texture as the texture but what if I want to have static shadow maps for buildings as well? BTW, can shadow maps be saved as vertex colours?

I was looking around the forums and I found this:
Lightmapping? thread:
hannibar said:

You can make lightmaps in blender. It’s not difficult.

Small minitut.

  1. Make an UV sphere
  2. Light it with a few lights
  3. Select the sphere
  4. Go to the edit buttons
  5. Push small button called ‘make’ next to ‘vertcol’
  6. Delet the lights
  7. Go to the material buttons
  8. Set VColLight
  9. et F12

Then it has this:
ray_theway: “Set Smooth is not working with VColLight on and a light map. I put Set Smooth on before and after making the light map, and then it doesn’t work. This is on 2.23 and 2.25.”

hannibar: “I managed to get it smooth however by going into vertexpaint mode, and clicking on the object then.”

=================

Well I’ve got the vertex lighting to become smooth - once - I haven’t been able to reproduce it again yet… it works with spot lights, and lamps - maybe the other lights as well. It also works with coloured lighting, but not textured lighting.

Doesn’t keep the shadows, though. I just tried it and after I deleted the spot light the shadows disappeared. I don’t think it’s possible to save shadow maps. At least not with this method.

You can render your shadow-casting object from the light point of view (select the light that is supposed to cast the shadow then press Cntrl+0), obtaining a b/w image (the object-shadow black, the arounding white) which you can map (in sub mode maybe, but mix works too) on the ground obtaining a fake static shadow.

Env

Yeah, so vertex lighting can’t be used to make static shadows…

When I pressed Ctrl-0 the camera changed to the spotlight’s viewpoint. I had to make the camera view square to be able to fit all of the spot light in. When I pressed F12 it just rendered the scene normally, except from the POV of the spotlight. So the objects were showing their highlights rather than just the shadows being shown. BTW, from the spotlight’s point of view, the only shadows would be outside of the circle of the spotlight, and behind objects that it can’t see. If there is shadow-blurring then there would be a little shadow at the edges of objects that are casting a shadow.
Assuming I made all the objects white somehow, what you’d end up would be a circle with some outlines of the objects (because of the blurry shadows). Anyway, if you projected that rendering from the spotlight’s POV onto the scene, the objects it was looking at would render correctly, but there wouldn’t be shadows behind the objects (where the spotlight can’t see) - the first render would be projected through the scene - not just onto the top layer that was visible to the spotlight… basically the scene would have a white circle or elliptical boundary that is black outside of the bounday, with some outlines of shapes projected trough the scene. The outlines would be fuzzy on the outside (where the blurry shadow is seen) and sharp on the inside (where the object casting the shadow is overlapping the shadow).

When I pressed Ctrl-0 the camera changed to the spotlight’s viewpoint. I had to make the camera view square to be able to fit all of the spot light in.

I don’t really understand this, but you can make a spot square too.

When I pressed F12 it just rendered the scene normally, except from the POV of the spotlight. So the objects were showing their highlights rather than just the shadows being shown.

Yes, I didn’t explain myself too much well… I meant you must render from the spotlight POV only the OBJECT that is supposed to cast the shadow on the ground as a BLACK silouette against a white background (you can obtain this by layers and the world option or by postprocessing the rendering in PS or Gimp). Then you have to apply in mix or sub mode this fake shadow on the ground mesh, selecting object mode for the texture and tiping in the name of the spotlight you rendered the image from. You will have to tweak a little with the texture size buttons to fix the shadow correctly. If you have many objects supposed to cast shadow on the ground with different lights, you should repeat this procedure for every object_light.
Hope to have been clearer.

Env

[When I pressed Ctrl-0 the camera changed to the spotlight’s viewpoint. I had to make the camera view square to be able to fit all of the spot light in.]
I don’t really understand this, but you can make a spot square too.

If I select the spotlight, then press Ctrl-0, then press F12, the top and bottom of the round spotlight is cut off. But as I said, I was able to fit it by making the SizeX and SizeY of the render square. Making the spotlight square doesn’t fix it… it cuts off the top and bottom of the shadow in the render… but making SizeX equal SizeY also fixes that.

Yes, I didn’t explain myself too much well… I meant you must render from the spotlight POV only the OBJECT that is supposed to cast the shadow on the ground as a BLACK silouette against a white background (you can obtain this by layers and the world option or by postprocessing the rendering in PS or Gimp). Then you have to apply in mix or sub mode this fake shadow on the ground mesh, selecting object mode for the texture and tiping in the name of the spotlight you rendered the image from. You will have to tweak a little with the texture size buttons to fix the shadow correctly. If you have many objects supposed to cast shadow on the ground with different lights, you should repeat this procedure for every object_light.

I was really looking for a way to save all of the shadow map data so that I could have static shadows for an entire scene… e.g. with buildings casting shadows on themselves, etc.
I’m using a non-tiled texture for the landscape (from Bryce) and I could probably just render it orthogonally from above, and making the buildings invisible but still let them cast a shadow. Then I could use that render as the texture for the landscape - instead of having a 2 part texture (the texture plus the shadow map). But the buildings wouldn’t have static shadows… and note that they aren’t simply rectangular box buildings either…

Just as you apply the fake shadow textures to the ground, you can apply them to the buildings (with the two part textures method).
Your method is good too, I think, bit you don’t really need to have a huge hortoganal rendering of the ground… anyway… good luck! :smiley:

Env

I recommended this as a feature when NaN still owned Blender. They thought I was crazy and told me to just use Radiosity.

True, radiosity WILL save shadows as vertex colors, but there are big disadvantages to it:
1)More than 16 materials? Sorry, it will delete any more materials if it exceeds this 16 material limit. If two separate objects are sharing the same material it counts it as 2 materials also!
2)It’s not practical (Or accurate) for large scenes or scenes with a high polygon count
3)It takes too long to calculate, and you can’t change the lighting after you bake it.

I haven’t been able to get Blender to compile on my computer with C++, otherwise I would have looked into this more. But the shadow buffer could probably be saved between frames and the recalculation skipped. This should be an extremely easy feature to impliment, but like I said, I haven’t looked at it too much.

Ok I’ve been looking through the code and I’ve narrowed it down to two .c modules:

rendercore.c under void shadelamplus()

and the whole shadbuf.c

Rendercore.c calls testshadowbuf quite a few times from various places. I’ll keep looking into it!

I’ll keep looking into it!

Wow!

Env

Okay…the lightmapping thread was locked…can someone further explain how to smooth a mapped object ?

no, saving the shadow buffer is really not possible.

you must be doing a lot if it is taking you too long…
(too long has only occured to me when I do motion blurred environment maps for reflection and refraction, and use osa 16, or when having > 20 lamps with shadows)

my idea: (though kinda not useful on buildings)
vertex paint the lighting…

rather simple, here goes

select the object
enter face select mode [F]
select all the faces
in the paint buttons make the color black, and press [Copy VertColor]
exit face mode
select your lamp, and make it your active camera (ctrl+0)
in the paint buttons choose a lighter color (white)
… also enlarge the brush, and increace the opacity, and very important
press the [Normals] button
[you may want to fullscreen your 3d view with ctrl+uparrow]
paint over your image with white. The areas pointing more directly at the light will be lighter, the areas not will be darker, and If the area is not directly in the lign of sight of the light (obscured by another face, aka in shadow) it will not be changed.

the material setting changes are up to you, but the [VCol Paint] and/or the [VCol light] buttons will be the ones you need

A result on a quick cloud heightmap
erghh, netscape network [presumably through firewalls] doesn’t work
geocities image it is:
http://www.geocities.com/z3r0_d/files/heightMapImage.txt

to smooth the vertex colors on an object on which Make Vertex colors has been used try entering vertex paint mode, decreacing the size of the brush, selecting an inconspicous color, and painting on your object in that color. Odd, but it seems to work (sometimes to my annoyance)

I’ve only got one spotlight, but it is a hi-res one across the entire scene - it will eventually have buildings in there. Anyway, I’m making a 3 and 1/2 minute music video for TV so it uses motion blur and field rendering (but not OSA - motion blur has some automatic jiggling). I need to do heaps of renders so speed is important. It takes about 20 seconds to render a frame (it even has bump-mapped animated procedural texture rivers) on my Athlon XP 2000+ but I guess I could try doing network rendering with my P4-1700.
Here is a picture of the terrain - it takes about 3 or 4 seconds to render - that’s because I’ve got the field rendering and motion blur turned off (because it would have made the picture harder to see). I guess I should try to resist doing motion blur and field rendering for tests… it makes it look much smoother on TV though.

my idea: (though kinda not useful on buildings)
vertex paint the lighting…

I was talking about shadows though… e.g. soft but detailed shadows that connect accurately to the bottoms of buildings… (like normal shadows, but not recalculated every frame…)

The landscape looks like it could have been done with a sun light instead… and perhaps making the material emit light to lighten the “shadows”. (Or you could have a sun light in the opposite direction that is not as strong to lighten the “shadows”)

It seems like you’re talking about manual painting of shadows… well I’ve got 70,000 faces on my terrain and I’ll be having lots of complex futuristic buildings, so no thanks… it would be quicker to use normal shadows…

…to smooth the vertex colors on an object on which Make Vertex colors has been used try entering vertex paint mode, decreacing the size of the brush, selecting an inconspicous color, and painting on your object in that color. Odd, but it seems to work (sometimes to my annoyance)

Yeah it did work… thanks…

If you want shadows cast on buildings a simple way would be to download POV-Ray and POVAnim. The lamps in POV-Ray act more like lights in real life. A tutorial on adding textures to exported meshes will be available soon, if you decide to go that route.

Blender can do shadows for buildings… I was looking for ways of reducing the time I spend rendering. POV would probably render things slower than Blender, and there is the added time of continuously exporting things to get an updated render…

I’m trying to speed up how long it would take to have lots of shadows in an animation. And since the shadows wouldn’t be moving, they don’t need to be recalculated every single frame - in fact, I sometimes use fields and motion blurring which makes it calculate the shadows a few times every frame. The time I’d spend learning about POV-anim and exporting the huge project (it has a 4096x4096 texture for the terrain and also video textures, etc) In blender I can just press F12 and get a preview of exactly what the final output will render like. If I am using pov-anim to render it, I wouldn’t be able to render a preview that quick. I’m using heaps of features of blender that the pov-anim export script probably doesn’t support.

You could try the lightflow export script by Eeshlo. It actually takes the settings from the .blend file instead of relying purely on python functionality. Very cool. It has an in-blender preview within the script, and I belive you can have static shadows. But ya, it takes awhile to render.

RipSting:
Sounds interesting… though this project is commercial really and I think LightFlow isn’t free for commercial use.