Lightmaps and Shadows

If you feel like you're up to the challenge of building your own Ages in Blender or 3ds Max, this is the place for you!

Lightmaps and Shadows

Postby tachzusamm » Fri Apr 30, 2010 7:45 am

Okay, after some hours of hard work I figured out how to work with lightmaps. Understood the principles, that is - and how to get them bright enough - and a closer look into the PyPRP plugin sources was needed to get an idea which settings and switches in Blender are taken into account at all.

But now I got a question.

Isn't Blender able to render the shadows of objects between the light source and the object into the lightmap as well when baking it?
I mean, here is a lamp, and there is my object, and some other objects between them. But whatever I do, I get always the shading of the object applied to the lightmap, without shadows, neither from other objects nor from the object itself (assume a fountain; this should draw a shadow of it's border into the inner part).

What may I have missed?
Or is this only possible with non-sun type lamps, and if yes, which type?
Or do I need to use projection lights (hopefully not)?

I know this is not a PyPRP question, more Blender related, but I thought it's a right place to ask here - because, well, not really many guys in Blender forums even know about URU, age writing or baking; mostly they just render complete scenes without baking a single texture.
User avatar
tachzusamm
 
Posts: 575
Joined: Thu May 29, 2008 2:03 am
Location: Germany

Re: Lightmaps and Shadows

Postby dendwaler » Fri Apr 30, 2010 1:11 pm

did you not forget to press the button "selected to active"?
all the objects with the given distance from the active object will cast shodows on the active object.

May be i do not fully understand what you mean.
Attachments
bake2.jpg
bake2.jpg (9.82 KiB) Viewed 3468 times
Those wonderfull Worlds are called " Ages" , because that is what it takes to build one.



Watch my latest Video Or even better..... watch the Cathedral's Complete Walkthrough made by Suleika!
User avatar
dendwaler
 
Posts: 936
Joined: Mon Jun 22, 2009 10:49 am
Location: Nederland

Re: Lightmaps and Shadows

Postby Sirich » Fri Apr 30, 2010 3:25 pm

Though I don't really know a sure-fire fix for this, I noticed the bit about Sun and Non-sun lamps.
For me; trying to bake a Lightmap with a Sun lamp never works, I usually add a temporary spotlight with a wide range to act as the sun, and some temporary regular lamps to lighten dark areas.

I would try baking with a spotlight to see if that renders your shadows correctly.

If that doesn't work, try baking the objects in different orders, in my age 'Eder Feroshtam' I use one mesh for the floor and another for the walls.
I baked the wall mesh first, then the floor after that, and shadows of the walls show up fine on the floor, so that might make your shadows work properly.

If none of that works, what version of blender do you use? I use 249.2, and it works pretty well.
User avatar
Sirich
 
Posts: 13
Joined: Wed Apr 09, 2008 10:43 pm

Re: Lightmaps and Shadows

Postby tachzusamm » Sat May 01, 2010 7:18 am

dendwaler: Yes, they cast shadows when I press the button "selected to active" - but they also project their texture onto my lightmap, sometimes, and not totaly predictable.
Not really what I had in mind. :?

Sirich: I will follow your advice and see what happens. Maybe suns behave sometimes this way, sometimes totally different. I made a small blend file yesterday with only a few objects, settings the same as in my real age, but in this file it works. Really strange.
Oh, and yes, I am using Blender 249.2 too.
User avatar
tachzusamm
 
Posts: 575
Joined: Thu May 29, 2008 2:03 am
Location: Germany

Re: Lightmaps and Shadows

Postby dendwaler » Sat May 01, 2010 8:11 am

but they also project their texture onto my lightmap, sometimes, and not totaly predictable.


Yes, but did you actually use it?
I think the texture is not of importance because you use "multiply settings" , besides that In many cases that colour is partly hidden by the object which its cast because it is exactly where that object hits the floor. (The texture in your lightmap is its "footprint") and the rest is shadow with a little ambient reflection.

It is also possible to use only the sun as a lamp in outside environments . But often the lightmap will turn out to be to dark if you do so.
I found a little trick to get this better without adding lamps.
Before you press "bake", go to the shader menu (F5)
Turn on the "VCol Light" button in the material settings.
The chosen Colour value will be added to lightmap. You give it a "bias" value in this way
If you chose black it will be the same as without VCol light pressed. (0 is added)
With Gray the bake result will be lighter (0.5 is added)
With White it will be "overexposed" (1 is added.)

After baking the lightmap turm off your VCol Light again.

Its really worth trying.
Those wonderfull Worlds are called " Ages" , because that is what it takes to build one.



Watch my latest Video Or even better..... watch the Cathedral's Complete Walkthrough made by Suleika!
User avatar
dendwaler
 
Posts: 936
Joined: Mon Jun 22, 2009 10:49 am
Location: Nederland

Re: Lightmaps and Shadows

Postby Jojon » Sun May 02, 2010 7:04 am

Huh?

I just made a minimal test render, with a plane and some objects and it renders just fine, regardless of lamp type...

Do you want the shading and the drop shadows, or only the shadows? In case of the latter; tick the Shadows button in the Bake tab, this will produce a monocrome image -- if the former; tick FullRender: now the buttons in the Render tab determines what is rendered, including shadows.

I probably missed something in your question...

EDIT: Umm, ok, 'read your follow-up post... :P Any transpiracy/reflectivity in your materials, that might affect the outcome, perhaps?
Jojon
 
Posts: 1116
Joined: Sun Sep 30, 2007 5:49 am

Re: Lightmaps and Shadows

Postby tachzusamm » Sun May 02, 2010 7:50 pm

First, thank you all for your valuable hints and for trying to help.

dendwaler wrote:Yes, but did you actually use it?
I think the texture is not of importance because you use "multiply settings" ,

I didn't in the first place, but then I did to check it - and the textures of surrounding objects were mapped onto the object then. Even in URU. So it seems just setting multiply does not remove color information from the lightmap. E.g. multiplying "green" (gras) with a grey value results in a darker grey, but still green.

dendwaler wrote:It is also possible to use only the sun as a lamp in outside environments . But often the lightmap will turn out to be to dark if you do so.
I found a little trick to get this better without adding lamps.
Before you press "bake", go to the shader menu (F5)
Turn on the "VCol Light" button in the material settings.
The chosen Colour value will be added to lightmap. You give it a "bias" value in this way
If you chose black it will be the same as without VCol light pressed. (0 is added)
With Gray the bake result will be lighter (0.5 is added)
With White it will be "overexposed" (1 is added.)

After baking the lightmap turm off your VCol Light again.

That was a good tip, thanks.
I mostly use additional hemi-type lamps to give it a bias, with property "page_num" set to a high (and unused) value (e.g. 12345) so it does not get exported to URU.
By the way, if the baking comes out too dark: Remember that the "Reflection" setting of the object's material (Shaders->Ref.) is taken into account as well when the lightmap is generated. If this value is 0, the lightmap will always come out black. Better set this to 1.0 always.


Jojon wrote:Do you want the shading and the drop shadows, or only the shadows?

Shading and drop shadows. :)

Jojon wrote:Any transpiracy/reflectivity in your materials, that might affect the outcome, perhaps?

I assume you mean transparency? I have no idea how this does affect the outcome. So I just left those values to their defaults to be sure.
As for the Reflectivity thing: Yes, this DOES affect the outcome - I've set this to 1.0. See comment above.


Now, finally: I've figured out what was wrong.
Oh my dear; you won't believe it.

It was ... a Camera Region! I did not believe it in the first place, so I checked twice. It's true.
I mean, it's only a region; added via the PyPRP scripts, drawtype set to wire, no material.
Removing it, or restricting its renderability in the outliner did help - suddenly the object was lit by the sun again, and creating the lightmap worked as expected.
To be honest, I must admit that I moved the Region from Layer 2 to 1 in the past (when I did not understand why it's added there). Now I see, hehe.
The strange thing is that this region did not affect suns which don't cast shadows, or hemi lamps - just my special "main" sun. And the sun's "cast Shadows on same Layer only" button is still not checked now, so I'm surprised the layer is taken into account at all - but, well, that's Blender. :D


As a final conclusion:
If you're using regions, always be sure to set its renderability in the outliner to "restrict" (uncheck the render icon, that is).
:idea:
User avatar
tachzusamm
 
Posts: 575
Joined: Thu May 29, 2008 2:03 am
Location: Germany

Re: Lightmaps and Shadows

Postby Jojon » Tue May 04, 2010 1:32 pm

Haha, got that the one time I rendered an envmap - all the colliders were visible to the renderer, so I got a nice cubemap with nothing but gradients of grey. :D
Jojon
 
Posts: 1116
Joined: Sun Sep 30, 2007 5:49 am


Return to Building

Who is online

Users browsing this forum: No registered users and 4 guests