x


2 (or more) Lightmaps in one scene - is it possible?

Subject says it all I guess.

My entire game project runs in a single scene, levels are made up of prefab objects which are instantiated and destroyed at runtime as the player goes in and out of levels - I need each level prefab to be lightmapped, but I've got no idea how to do this.

more ▼

asked Nov 23 '11 at 10:44 PM

Alkan gravatar image

Alkan
32 10 10 12

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

2 answers: sort voted first

The active lightmaps are a simple function of what lightmaps are in the lightmap list, and what lightmap index and lightmap atlas properties the objects in the scene have. So you could actually do a bunch of different bakes with your different prefabs active, and then "merge" them all together by putting all the produced lightmaps in the lightmap array, and setting the correct lightmap indexes and atlases on all the different objects. I actually use custom scripts for doing that (still has problems which is why I haven't shared it), but there is a script called "Beast Helper" that can help with this (it also has problems, especially with identically named objects in the hierarchy) but it's a great starting point for merging bakes

Another option that probably won't actually work for you (because it's probably too much to bake at once) is to put all your prefabs in the world at once, and bake them all, and save the baked stuff back out to the prefab.

more ▼

answered Nov 24 '11 at 01:05 AM

thorbrian gravatar image

thorbrian
325 7 8 13

Thanks for your response, is there any information anywhere on how to use the lightmap array and how to set Indexes on objects?

Another alternative solution I think may work, is to place each individually light mapped piece of geometry in its own scene and load them into the game when needed at run-time using additive load.

Nov 25 '11 at 08:26 AM Alkan

Yeah, unity provides interfaces for all this - for getting how objects map into lightmaps it's: Renderer.lightmapIndex Renderer.lightmapTilingOffset

and to get at the lightmap array it's: LightmapSettings.lightmaps

May 01 at 09:19 PM thorbrian
(comments are locked)
10|3000 characters needed characters left

You could also delete the model and instantiate in it's place an identical model that has different lightmaps.

more ▼

answered May 01 at 07:58 PM

rhgrant10 gravatar image

rhgrant10
1

(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:

x38

asked: Nov 23 '11 at 10:44 PM

Seen: 1201 times

Last Updated: May 01 at 09:19 PM