Search Unity

Enable/Disable Blending state in shader using properties

Discussion in 'Shaders' started by CorruptScanline, Feb 23, 2014.

  1. CorruptScanline

    CorruptScanline

    Joined:
    Mar 26, 2009
    Posts:
    217
    Id like to be able to completely enable/disable blending per material, similar to the way you can change the blendmode through properties now. I have created a feature request with more info here:
    http://feedback.unity3d.com/suggest...ble-blending-state-in-shader-using-properties

    Perhaps I'm missing something though, and this can be done, or maybe theres a workaround? I guess one option would be to use AssetPostProcessor to maintain duplicate versions, but thats not very clean.
     
  2. mayorc1978

    mayorc1978

    Joined:
    Dec 30, 2013
    Posts:
    36
    You are using MULTICOMPILE, and the blending can be modified inside the CG Program so yes, you should be able to modify this behaviour per material without the need to switching shader.
    Using a simple toggle Button or in this case (as shown in your feedback request) an EnumPopup.

    https://docs.unity3d.com/Documentation/ScriptReference/EditorGUILayout.EnumPopup.html

    You must use a Custom Material Editor:
    You can read how to here:
    http://docs.unity3d.com/Documentation/Components/SL-CustomMaterialEditors.html

    EDIT: Actually reading back what you asked this might not be possible, as your #if/#endif groups have #pragmas in the middle, I don't think this will work with other preprocessor directives.
    But you could give it a try.
     
    Last edited: Feb 25, 2014
unityunity