Giter Site home page Giter Site logo

merlinvr / vrc-bakery-adapter Goto Github PK

View Code? Open in Web Editor NEW
86.0 2.0 3.0 31 KB

A script that handles converting Bakery RNM and SH directional lightmap bindings into a format that VRChat can process

License: MIT License

C# 100.00%
vrchat unity lightmap bakery

vrc-bakery-adapter's Introduction

VRC Bakery Adapter

A script that handles converting Bakery RNM and SH directional lightmap bindings into a format that VRChat can process without the Bakery scripts being whitelisted

This script is only necessary if you are using the RNM or SH directional light modes on Bakery.

If the Bakery scripts get whitelisted, this won’t be needed and the directional lightmaps will just work in game. Please vote on the Canny for this if you have a moment: https://vrchat.canny.io/feature-requests/p/whitelist-bakery-gpu-lightmapper

Examples

Using dominant directional mode

Using the SH directional mode that this script enables in VRC

Why Bakery breaks in VRC and what the script does

Bakery uses a script to bind material property blocks per renderer at runtime. These property blocks contain references to the directional lightmaps that Bakery uses for RNM and SH modes, the property blocks also specify the lightmap mode that the shaders use. Since these scripts aren't currently whitelisted, they cannot set these property blocks in game.

TCL originally demonstrated that adding properties to the materials for these lightmaps and then setting them manually to the Bakery lightmaps per material allowed the lightmaps to function properly in VRChat. This script automates that process and creates unique materials for each combination of material and directional lightmap binding that is used. This is necessary because the mapping between materials and property blocks on their renders is not always 1-to-1.

This also handles automatically patching the Bakery shaders to add the properties they need to work with VRC. This patch does not interfere with the usual operation of Bakery.

The component on an object

Instructions

  1. Make sure Bakery is imported into your project and you have baked lightmaps using the RNM or SH directional lightmap mode.
  2. Download and install the latest release off the releases page.
  3. Make a new object in the scene that will handle managing the bakery materials.
  4. Add a VRC Bakery Adapter component to the object.
  5. Select a replacement scope for the object. The default Scene replacement scope should be enough for almost all situations, but if you have some odd case where you want to have different settings for different groups of objects you may use the Children replacement scope to only replace Bakery materials belonging to renderers on the children of the adapter object.
  6. Choose a directional mode. The default Auto mode will choose the correct lightmap direction mode per material. If you want to specify a specific mode for all bakery materials you can change it to SH or RNM here, but you shouldn't need to touch this.
  7. Leave Compile Keywords checked unless you want slightly faster iteration time when uploading a world. This option will compile static variants of the Bakery shaders that don't need extra keywords to look correct. This prevents lighting from breaking when people are out of shader keywords.
  8. In order to take advantage of SH or RNM lightmaps you need to change any lightmapped assets from using Standard to Bakery's version of Standard. There is a utility under the Utilities dropdown to do this automatically. Click Standard->Bakery SH/RNM to replace the shaders on all materials in the replacement scope with their Bakery counterparts. You can choose which type of lightmap replacement with the lightmap mode selector. If you want lightmap-based specular highlights check the Lightmap Specular checkbox before converting the materials. This will not replace transparent Standard materials by default since Bakery transparency does not get sorted correctly by VRC.
  9. Once you are ready to upload your world to VRC, click the Run Conversion button. This will process all the materials into a format VRC can use.
  10. IMPORTANT after you have finished uploading your world, click the Revert Materials button on the adapter. If you do not revert them, then any changes you make to the materials will get overwritten with old settings the next time you run the conversion.

Recovering from a loss of material reversion data (this should never be needed)

The component should never be able to go into a state that it still has materials replaced in the scene, but has no option to revert them. If you find some way to break it like this, open an issue for it please.

In the off chance that you do manage end up with materials in the scene stuck set to the generatedbakery materials and cannot revert them with the Revert Materials button, there is an option at the bottom of the Utilities dropdown Load Material Reversion Profile. This will open a window at a folder which, in the case of a broken adapter component, should contain a .rev file with the scene name and the adapter object name on it. Load this profile and then try clicking Revert Materials.

vrc-bakery-adapter's People

Contributors

merlinvr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vrc-bakery-adapter's Issues

Material Reversion made Impossible

I had converted my materials for an upload then closed my project, coming back to it in three days. When I came back, the "Revert Materials" button was grayed out. When attempting to use the "Load Material Reversion Profile" no such file existed.
I'm uncertain of any factors that could have led to this, nor do I know of anything that I could link or screenshot that would help in this explanation.

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.