Since I spent quite some time pulling my hair out over this, here's a quick troubleshooting rundown if your object alpha doesn't fade.

1. Alpha compatible shaders
Anything that uses the ORK Fade Object node must be set up with a transparency-friendly rendering mode. For the standard shaders, that is this Rendering Mode dropdown:

image

You will most likely want to use the "Fade" option. Opaque and cutout won't allow fading.

2. Wait, that doesn't look right!
In some/many cases, the Fade option will do a really dumb job of rendering the object, to the point that it may look inside out.

image
image

This was where I got stuck for a while, until I finally came upon a script hack.

There are now two options to do this. Either use the method directly below or try the script provided by Keldryn in the first reply to this thread, which is even better.

You can download the script here, or just copy and paste the code below:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class shade_r : MonoBehaviour {
public Material mat;

// Use this for initialization
void Start () {
mat.SetFloat("_ZWrite", 1);
}

// Update is called once per frame
void Update () {

}
}


Place this on the object you want to fix (I think it only works correctly if you put it on the mesh that carries the material in question), and in the slot put the material that's displaying weird.

image

This is a dirty hack, but it works. Needless to say, only use it for objects you intend to fade. I'm using it on enemies for death fading, and chests that fade away after being looted.


Hope this is helpful for you!
Post edited by Natnie on
image
Olive Branches ~ in development ~ now with a WEBSITE!!!
  • edited May 2018
    Great tip! This particular issue ends up being a thorn in the side of many developers.
    Natnie said: This is a dirty hack, but it works. Needless to say, only use it for objects you intend to fade. I'm using it on enemies for death fading, and chests that fade away after being looted.
    If you'd like a solution that is less of a dirty hack :-), you can use this script I wrote to set up Editor commands to enable and disable ZWrite on materials either by right-clicking on them in the Project view or selecting the material and picking the option from the Assets menu. This way, you don't need to add another component to your character(s) and you don't have to worry about where that component would be placed.

    Just drop this script in an /Editors folder in your project:

    using UnityEditor;
    using UnityEngine;

    namespace ORKLibrary.Editors
    {
    public class MaterialFixes: Editor
    {
    [MenuItem("Assets/Enable ZWrite on Standard Shader Material")]
    private static void EnableStandardMaterialZWrite()
    {
    var material = Selection.activeObject as Material;
    if (material == null) { return; }

    material.SetInt("_ZWrite", 1);
    Debug.Log(string.Format("ZWrite on material {0} is enabled.", material.name));
    }

    [MenuItem("Assets/Enable ZWrite on Standard Shader Material", true)]
    private static bool ValidateEnableStandardMaterialZWrite()
    {
    var material = Selection.activeObject as Material;
    if (material == null) { return false; }

    return material.HasProperty("_ZWrite")
    && material.HasProperty("_Mode")
    && material.GetInt("_ZWrite") == 0;
    }

    [MenuItem("Assets/Disable ZWrite on Standard Shader Material")]
    private static void DisableStandardMaterialZWrite()
    {
    var material = Selection.activeObject as Material;
    if (material == null) { return; }

    material.SetInt("_ZWrite", 0);
    Debug.Log(string.Format("ZWrite on material {0} is disabled.", material.name));
    }

    [MenuItem("Assets/Disable ZWrite on Standard Shader Material", true)]
    private static bool ValidateDisableStandardMaterialZWrite()
    {
    var material = Selection.activeObject as Material;
    if (material == null) { return false; }

    return material.HasProperty("_ZWrite")
    && material.HasProperty("_Mode")
    && material.GetInt("_ZWrite") == 1;
    }
    }
    }





    Post edited by Keldryn on
  • Wow! That's awesome!
    Thanks so much!
    image
    Olive Branches ~ in development ~ now with a WEBSITE!!!
Sign In or Register to comment.