x


Changing ambient light color during runtime with baked ambient occlusion

I'd like to be able to change the ambient light color in realtime, while using beast's baked ambient occlusion. So what I do is set my light to realtime only and the ambient light to white, which effectively creates a nice ambient occlusion bake.

The problem is that changing ambient lighting afterwards won't affect a thing - makes sense since normally you would have baked shadows / reflected light etc. in the lightmap, meaning you need to rebake when changing ambient light.

Is there any way to access the lightmap in the shader so i just can multiply the albedo with the lightmap color and ignore lightmapping during light calculation? I played around with using renderer.lightmapIndex and renderer.lightmapTilingOffset and putting the corresponding lightmap texture as a separate texture in the shader using the secondary uvs (they are the ones for lightmapping i suppose, turned on generate lightmap uvs in the importer), but the results are wrong - any ideas how to access it in the surface shader, or is there another way?

more ▼

asked Jul 07 '11 at 06:50 PM

klabauterklaus gravatar image

klabauterklaus
1 2 2 3

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

if you explicitely implement the lightmap support and don't let the auto add of surface shaders do it, then yes you could overwrite it. But as long as you rely on auto addition no, as it will not exist for your access in the surface shader code you write.

more ▼

answered Jul 19 '11 at 03:48 PM

Dreamora gravatar image

Dreamora
3.2k 1 4 25

ehm could you clarify what you mean by auto addition? or could you point me in a direction how to access the lightmap directly in a surface shader? many thanks for the answer

Jul 27 '11 at 07:39 PM klabauterklaus

surface shaders, when compiled, get a host of extra coded added for the lightmap handling. In the docs you find a pragma that allows you to prevent that from happening if I recall right, which would allow you to write the whole code for lightmap handling yourself.

you can add a #pragma debug to make it generate the inbetween code for you so you can look at it

Jul 27 '11 at 07:47 PM Dreamora
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x207
x19
x10

asked: Jul 07 '11 at 06:50 PM

Seen: 1447 times

Last Updated: Jul 27 '11 at 07:47 PM