Difference between revisions of "How do I..."

From Bakery GPU Lightmapper: Wiki
Jump to navigation Jump to search
(How do I make an object to cast lightmap shadows/GI without having a lightmap on its own?)
Line 82: Line 82:
 
* Enable '''Lightmap Static''' (pre-2019.2) or '''Contribute GI''' (2019.2 or newer) on your GameObject.
 
* Enable '''Lightmap Static''' (pre-2019.2) or '''Contribute GI''' (2019.2 or newer) on your GameObject.
 
* Set '''Scale In Lightmap''' to 0 on Mesh Renderer.
 
* Set '''Scale In Lightmap''' to 0 on Mesh Renderer.
"Receive Global Illumination" Mesh Renderer option is not used by Bakery.
+
Object will receive GI via light probes.
 +
Note that "Receive Global Illumination" Mesh Renderer option is not used by Bakery.
  
 
=== How do I make an object to receive lightmapped lighting without affecting it (not casting shadows or GI)? ===
 
=== How do I make an object to receive lightmapped lighting without affecting it (not casting shadows or GI)? ===
 
* Enable '''Lightmap Static''' (pre-2019.2) or '''Contribute GI''' (2019.2 or newer) on your GameObject.
 
* Enable '''Lightmap Static''' (pre-2019.2) or '''Contribute GI''' (2019.2 or newer) on your GameObject.
 
* Set '''Cast Shadows''' to Off on Mesh Renderer. In Bakery this will disable GI from this object as well.
 
* Set '''Cast Shadows''' to Off on Mesh Renderer. In Bakery this will disable GI from this object as well.

Revision as of 08:29, 30 April 2020

How do I make a lightmapped prefab?

See Lightmapped Prefab component.

How do I use git/collab/other version control system with Bakery?

First, make sure all machines have the same version of Unity and Bakery.

Unity 2017.1 or newer:

You should commit:

  • Any updated assets unrelated to Bakery.
  • All updated *.meta files.
  • Lightmap textures.

You should not commit:

  • Bakery folders.

Pre-2017.1 versions of Unity:

  • Also commit ftGlobalStorage.asset.

If UVs don't look right, right click affected models and click Reimport.

Alternative solution

UV padding settings can be saved into a padding asset instead of a meta file. In this case the UVs are fully locked. They will be identical across machines and can't be further adjusted. To create the asset:

  • Select all model assets you want to lock UVs for in Project inspector.
  • Bakery -> Utilities -> Save UV padding to asset.

Files named "modelName_padding.asset" will be created. These should be commited to other machines. When importing padding assets, but with models already present in the project, you'll need to click Reimport on them.

Known issue: baking the scene with "Adjust UV padding" enabled, then switching it off and baking again will still leave assets modified, but modifications won't show on other machines. This problem is addressed in the upcoming new version.

How do I share a scene with someone who doesn’t have Bakery installed?

Apart from the scene and its lightmaps you also have to include a few scripts, namely:

  • ftLightmaps.cs
  • ftLightmapsStorage.cs
  • ftLocalStorage.cs
  • ftGlobalStorage.cs
  • ftModelPostProcessor.cs
  • ftSavedPadding2.cs (on v1.7+)

How do I bake using my own UVs without any alterations to them?

Check out Lightmap Groups ("Original UV" mode).

How do I trigger a bake via scripting?

There are 3 steps involved:

1. Get the render settings object:

ftLightmapsStorage storage = ftRenderLightmap.FindRenderSettingsStorage();

2. Modify the settings. Full list can be seen in ftLightmapsStorage.cs. As an example, here is how you can limit the amount of bounces and set the output folder:

storage.renderSettingsBounces = 2;
storage.renderSettingsOutPath = "MyFolder";

3. Create Bakery instance, load the settings and bake:

ftRenderLightmap bakery = ftRenderLightmap.instance != null ? ftRenderLightmap.instance : new ftRenderLightmap();
bakery.LoadRenderSettings();
bakery.RenderButton();

How do I add fake ambient lighting?

Faking constant ambient factor with 6 shadowless directionals

In some non-realistic scenes you may want to add a fake ambient factor that doesn't come from natural GI or sky lighting (i.e. a cave that would be pitch black in reality, but has to be visible in a game).

Bakery doesn't have a built-in fake ambient option, but you can emulate it with 6 shadow-less directional lights:

1. Create 6 axis-aligned Direct Lights.

2. Set their Shadow Samples to 0.

3. Set their colors to desired ambient colors (you can use different top/bottom/side lighting if needed).

How do I use Skylight with a procedural sky shader?

Having baked sky lighting match visible skybox is important for correct look. You can bake any sky shader into a cubemap texture and use it in Skylight. Luckily, Update Skybox Probe button already generates that cubemap for you.

1. Click Update Skybox Probe

2. Locate the cubemap file. It will be in your output folder ("BakeryLightmaps" by default), named YouSceneName_0_sky.exr.

3. Plug the file into the Skylight "Sky texture" slot.

How do I make an object to cast lightmap shadows/GI without having a lightmap on its own?

  • Enable Lightmap Static (pre-2019.2) or Contribute GI (2019.2 or newer) on your GameObject.
  • Set Scale In Lightmap to 0 on Mesh Renderer.

Object will receive GI via light probes. Note that "Receive Global Illumination" Mesh Renderer option is not used by Bakery.

How do I make an object to receive lightmapped lighting without affecting it (not casting shadows or GI)?

  • Enable Lightmap Static (pre-2019.2) or Contribute GI (2019.2 or newer) on your GameObject.
  • Set Cast Shadows to Off on Mesh Renderer. In Bakery this will disable GI from this object as well.