Giter VIP home page Giter VIP logo

gitweaks's Introduction

GI Tweaks

For a detailed overview of the features provided, click here.

This package contains various tools and tweaks for working with global illumination in Unity. Both Unity's builtin progressive lightmapper and the third-party Bakery Lightmapper are supported, though not all tweaks work with Bakery. Harmony is used for making patches. Tested with Unity 2022.3 on the Builtin Render Pipeline.

All features can be toggled via the settings window in "Tools > GI Tweaks > Settings".

How to install

Option 1 - Unity Package Manager

  1. Open the package manager (Window > Package Manager).
  2. Press the big plus icon, select "Install package from git URL".
  3. Paste the URL of the repo https://github.com/pema99/GITweaks.git (note the .git ending) and click install.

image

Option 2 - VRChat Creator Companion

For VRChat users, the package can be installed via the VRChat Creator companion:

  • Click here.
  • When prompted, open the redirect with VCC.
  • Add the repository. You can now add GITweaks to your projects as normal.

Option 3 - Via releases

  1. Download the latest release zip.
  2. Open the package manager (Window > Package Manager).
  3. Press the big plus icon, select "Install package from disk".
  4. Select the downloaded zip file.

Current features

Share lightmap space across all LODs

When using LOD groups, if you use lightmapping for several LOD levels, each LOD level will take up its own space in the lightmap. This tweak adds a script "GI Tweaks Shared LOD" which lets you reuse the same lightmap space for several LOD levels. Simply attach the script to the GameObject that has the LOD group and bake. Unlike some of the other solutions that exist for this, the script will edit the LightingDataAsset stored on disk, meaning you don't need to manually fiddle with lightmap indices, scales and offsets at runtime.

1zWgISsTpp

For reference, the same scene baked with the script disabled, and using lightmaps for each LOD level:

image

Clickable Lightmap Preview charts

The Lightmap Preview window can highlight the UV chart of the currently selected object. However, you cannot inversely click on a chart to select the corresponding object. This tweak adds that functionality.

ZFvbglRVTT

Lightmap index dropdown in Lightmap Preview window

This tweak adds a dropdown to the Lightmap Preview window that lets you switch between viewing different lightmaps. A convenient shortcut for opening the window has been added under "Tools > GI Tweaks > Open Lightmap Preview".

Before:

image

After:

image

Optimize lightmap sizes after baking

Note: This feature does not work with the Bakery lightmapper.

Note: This tweak is not enabled by default, and must be enabled in "Tools > GI Tweaks > Settings".

Unity's builtin Lightmapper has a tendency to produce poorly packed lightmaps in some cases, which leads to wasting VRAM on empty texture space. An example is shown below.

image

When a bake is finished with this tweak enabled, the lightmap packing will be re-done, producing a new set of lightmaps, each of which is packed more tightly. These new lightmaps will often be smaller than the original lightmaps, and may be different sizes. Instances in each lightmap will never be resized, so there shouldn't be any noticeable quality difference. Below is the result of using the feature on the lightmap shown above. Before optimization, the scene had a single 512x512 lightmap. After optimization, the scene uses two 256x256 lightmaps - a 2x reduction in VRAM usage:

image

The tweak is configurable via two additional settings:

  • Target coverage % is a threshold determining when lightmap size optimization will be enabled. If less than the specified percentage of lightmaps texels are covered, optimization will be done. This should usually be set pretty high.
  • Minimum Lightmap Size determines the minimum allowed lightmap size after optimization. If you want to avoid many small lightmaps, increase this value. If you set it too high, no optimization will be done.

image

Fix lightmap seams between objects

When baking scenes containing surfaces built of multiple modular pieces, you will often get seams where the pieces meet, due to differences in bilinear sampling. Unity has a solution for fixing seams on a single renderer, but nothing to fix seams between different renderers, which is typically worked around by manually merging meshes. This tweak provides some tools for mitigating seams between different renderers.

It can be used in 2 primary ways: As a volume, and as a targeted component. The gif below shows an example of using the "GI Tweaks Seam Fix Volume" variant to fix a seam. Volume components can be quickly created with the right click context menu / GameObject menu.

s2o3BE4np4

image

The volume component will only attempt to fix seams occuring within the volume. Alternatively, you can use the targeted "GI Tweaks Seam Fix" component, shown below. This component is applied directly onto the object exhibiting seams, and should be provided a list of other renderers contributing to the seams. In this example, the component is applied to a cube, and pointed to another cube, in effect fixing the seam between the 2 cubes.

l42h87mouz

The tweak is configurable via some additional settings:

  • Run After Baking controls whether the seam fix should be applied automatically when baking.
  • Max Surface Angle is the maximum allowed angle in degrees between 2 surfaces for them to be considered "the same". This is used to prevent fixing intentional seams, such as the corners of a cube.
  • Seam Fix Strength controls how aggresively the seam fixing algorithm blurs the seam.
  • Max Solver Iteration Count controls how many iterations the algorithm takes at maximum. Higher numbers may give better quality, but will be slower.
  • Solver Tolerance is an error threshold which, when reached, will cause the seam fixing algorithm to stop early.
  • (Volume variant only) Renderers To Exclude is a list of renderers to ignore, even if they overlap the volume.
  • (Targeted variant only) Renderers To Fix Seams With is a list of renderers to run the seam fixing algorithm for.

The "Preview fix" and "Reset preview" button can be used to non-destructively preview the result of applying the seam fix. "Apply fix" will permanently modify the lightmap texture on disk.

Note: This tweak only fixes hard seams due to differences in bilinear filtering. If the lightmaps have perceptually different colors at the seam, this tweak will not fix that.

Note: Seam fixing can be expensive, especially with the volume component. Try not to make huge volumes - instead, keep the small and use only where seams occur.

Bulk select renderers

Making bulk lighting-related changes to renderers in a large scene is tedious. This tool provides a simple way to mass-select renderers based on some configurable filters, for the purpose of multi-editing them. Accesible via "Tools > GI Tweaks > Bulk Renderer Selection".

image

Baked Transmission view modes

The rules for what is considered transmissive/transparent by the builtin lightmapper are somewhat opaque. These added scene view modes allow for easy identification and debugging of transparents. There are 2 modes, both accessible from the scene view toolbar:

image

"Baked Transmission Modes" displays what the baker sees as transmissive:

Unity_c35PO3McfI

"Baked Transmission Data" displays the actual transmission textures fed to the baker:

uwJ51JYeAA

Better Lighting Data asset inspector

The output of the a bake - the Lighting Data asset - is a black box. The asset's inspector doesn't show any information about the contents. This tweak changes the default inspector to display all the contained data. Warning: Modifying this data can screw up your bake. Any issues should be resolved by simply rebaking, though.

Before:

image

After:

image

Show lightmap flags in default material inspector

Unity has a hidden MaterialGlobalIlluminationFlags on each material, which must be set in order for baked emission to work. It is in't shown in the inspector by default. This tweak shows it.

Before:

zDSlKh9F6x

After:

Om0RfPY6M5

Automatic embedded Lighting Settings

When you create a new scene in Unity, it will by default have no Lighting Settings asset assigned, and you won't be able to edit any settings without creating one. This tweak instead assigns a new embedded Lighting Settings asset which is serialized directly into the scene, letting you immediately modify settings without having to create an additional asset.

Before:

fJ3RSEK0VC

After:

N9cgB5O7BE

Better default Lighting Settings

When you create a new scene or Lighting Settings asset, the CPU lightmapper is the default choice of baking backend. The CPU lightmap is very slow and shouldn't be used if you have a GPU. This tweak changes the default to be the GPU lightmapper. Additionally, it disables the "Progressive Updates" checkbox by default, which can slow down bakes heavily.

Before:

D909MxI0nx

After:

Unity_Vdixu05Zlp

Convert lightmapped renderer to probe-lit without rebaking

When you have a lightmapped renderer, and you want to change it to be lit by probes, changing the setting in the inspector won't immediately make the change. For the setting to apply, you must bake again! This tweak adds a button to the inspector that only appears when you have changed a previously lightmapped renderer to be probe-lit, and allows you to immediately apply the change to the Lighting Data asset without having to re-bake.

6C1yre8Mth

New and Clone buttons for Skybox material

This tweak adds some buttons for quickly creating new Skybox Materials and assigning them in the Environment tab of the Lighting Window.

image

gitweaks's People

Contributors

pema99 avatar teehzero avatar

Stargazers

Bryan Bortz avatar  avatar Joohun, Maeng avatar Sathyaraj Shettigar avatar  avatar  avatar Carlos Melero avatar Leander Dirkse avatar  avatar David Matos avatar Hyblocker avatar  avatar  avatar Kit avatar  avatar

Watchers

 avatar

Forkers

teehzero

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.