• Hi Guest!

    We are extremely excited to announce the release of our first Beta for VaM2, the next generation of Virt-A-Mate which is currently in development.
    To participate in the Beta, a subscription to the Entertainer or Creator Tier is required. Once subscribed, download instructions can be found here.

    Click here for information and guides regarding the VaM2 beta. Join our Discord server for more announcements and community discussion about VaM2.
Custom Shader Loader

Plugins + Scripts Custom Shader Loader

Download [0.02 MB]
This is a plugin that loads custom unity shader from assetbundle.

It works on person atoms, clothing items (via @Stopper 's clothing plugin manager) and CUAs.

How to use:

1. load the plugin on a person plugin
2. go into UI

1744346182329.png


3. click on "Select Load Shader Bundle" and pick an assetbundle that has a shader.
4. choose shader from "Select Shader" popup
5. if you want to replace shader on the person's skin:
check "Show Skin Material Slots"
then check any material you want the custom shader on
WARNING: DO NOT SIMULTANEOUSLY ENABLE SHADER REPLACMENT ON SKIN AND OTHER PLUGINS THAT ALSO REPLACES SKIN SHADERS (i.e. @Hunting-Succubus 's SSS skin, anime-cell effect etc.)
6. if you want to replace shader on person's active clothing items:
pick clothing items from "Select Clothing item" popup
Clothing's material slots will show. By default they are all checked and the shader should be applied. Uncheck based on what material you want shader on.

7. Once the shader is loaded and if the shader property json file (explained more below) is properly prepared, control UIs will show up on right side of the panel:

1744346630970.png


8. adjust UIs to achieve your desired result.
9. you can now save plugin preset for future use from VaM's plugin preset tab.

Before using this as a clothing plugin, read @Stopper 's guide here first:


After creating or modified existing clothing to have clothing plugin manager loaded.
1. Load CustomShaderLoader plugin to clothing items:
1744347199038.png


2. Load shader from assetbundle
3. Choose which shader
4. choose which material of the clothing you want the shader applied
5. adjust shader property control for desired look
6. Save plugin via ClothingPluginManager. When saved as default. The plugin and shader will automatically load when clothing is put on
This is the recommended way to use this plugin on clothing items. Once setup, all you need to do is to put on the clothing.

1. Load the CUA first
2. load the plugin on the CUA
3. Load shader from assetbundle
4. Choose which shader
5. choose which material of the clothing you want the shader applied
6. adjust shader property control for desired look
7. To save preset, since CUA cannot save plugin preset, you'll need to use @Blazedust 's Custom Unity Asset Manager plugin to save a preset.


Where do I get the shader assetbundles?
I have one posted here:


I plan to post a couple of more in coming months.
I hope with this plugin more people will try their hands at create custom shader for different scenarios.



For creators, how to create shader for this plugin:


1. For CUA, as long as the shader runs fine in Unity 2018.1, it should be compatible in VaM.
2. For shaders meant for person's skin and clothing, you need to write the shader in a certain way to make use of VaM's internal vertex buffers, otherwise you will see the dreaded T-Pose problem. I will soon post a guide and a template to create such.
3. Once the shader is done, create an assetbundle with the shader.


In additional to the shader assetbundle, the shader author should also prepare a json file containing shader properties info. This file is for the plugin to read and spawn corresponding control UIs to configure shader properties at runtime. We have to do this due to Unity version limitation that shader properties are not accessible at runtime.


The json file should look like below:

Code:
[
    {
        "name": "property_name",
        "displayName": "Display Name",
        "type": "color"
    },
    {
        "name": "float_property",
        "displayName": "Float Property",
        "type": "float",
        "defaultValue": 0.5,
        "minValue": 0.0,
        "maxValue": 1.0
    },
    {
        "name": "range_property",
        "displayName": "Range Property",
        "type": "range",
        "defaultValue": 0.5,
        "minValue": 0.0,
        "maxValue": 1.0
    },
    {
        "name": "texture_property",
        "displayName": "Texture Property",
        "type": "texture"
    },
    {
        "name": "vector_property",
        "displayName": "Vector Property",
        "type": "vector",
        "defaultVector": {
            "x": 0.0,
            "y": 0.0,
            "z": 0.0
        },
        "minVector": {
            "x": -1.0,
            "y": -1.0,
            "z": -1.0
        },
        "maxVector": {
            "x": 1.0,
            "y": 1.0,
            "z": 1.0
        }
    }
]

Currently it supports float, range, vector, texture, color. I plan to add support for toggle boolean later

You should name the json file <Shader_Name>.json. put it at the same directory as the assetbundle. When the shader with the same name is loaded, the json file will be picked up and you should see property controls on the right.
You don't need to put all properties in the json, just the ones you want control over at run time.
If the assetbundle is in a var and/or you need to put the json file elsewhere, you can manually load the json file using the "Load Shader Properties" button

Known issue:
If plugin is loaded on a person configured to replace skin/cloth, then saved in a scene. Upon loading the scene the shader replacement will not be applied. Rechecking the material box and rescanning clothing will will get it back on.
I will fix this in next update.

Due to how clothingplugnmanager handles json restores, when a person atom has the plugin loaded, and simultaneously the person has a clothing item loaded the plugin as clothing plugin, the storeId of the scripts can collide and will cause issue when loading preset from clothingplugnmanager.
For now please avoid such use case, i.e. don't use the plugin both as person plugin and clothing plugin on the same person.
I will resolve this in coming updates by separating person plugin and clothing plugin code.



Please try this out and report any issue. Thanks!


Here is credit to all creators whose resource I referenced when creating this plugin:

More resources from regguise

Share this resource

Latest updates

  1. Fixes and Updates

    New features: 1. Added trigger action for rescan clothing items and rescan CUA materials 2...
Back
Top Bottom