Skip to content

Instantly share code, notes, and snippets.

@smkplus
Last active October 22, 2024 12:19
Show Gist options
  • Save smkplus/2a5899bf415e2b6bf6a59726bb1ae2ec to your computer and use it in GitHub Desktop.
Save smkplus/2a5899bf415e2b6bf6a59726bb1ae2ec to your computer and use it in GitHub Desktop.

Revisions

  1. smkplus renamed this gist Sep 20, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. smkplus revised this gist Dec 3, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions UnityShaderFFS.md
    Original file line number Diff line number Diff line change
    @@ -200,6 +200,7 @@ https://qiita.com/r-ngtm/items/7ec3e3a9dfcc752cd02c

    # Unity Material Property Drawer
    https://tedsieblog.wordpress.com/2017/03/02/unity-material-property-drawer/

    https://qiita.com/r-ngtm/items/7ec3e3a9dfcc752cd02c

    # Shade More Efficiently
  3. smkplus revised this gist Dec 3, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions UnityShaderFFS.md
    Original file line number Diff line number Diff line change
    @@ -203,4 +203,6 @@ https://tedsieblog.wordpress.com/2017/03/02/unity-material-property-drawer/
    https://qiita.com/r-ngtm/items/7ec3e3a9dfcc752cd02c

    # Shade More Efficiently
    ![normaltoggleinspector2](https://user-images.githubusercontent.com/16706911/33527427-22420d48-d866-11e7-93dc-82ed05a4c5db.png)

    http://www.martinpalko.com/muli-compile-unity/
  4. smkplus revised this gist Dec 3, 2017. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion UnityShaderFFS.md
    Original file line number Diff line number Diff line change
    @@ -200,4 +200,7 @@ https://qiita.com/r-ngtm/items/7ec3e3a9dfcc752cd02c

    # Unity Material Property Drawer
    https://tedsieblog.wordpress.com/2017/03/02/unity-material-property-drawer/
    https://qiita.com/r-ngtm/items/7ec3e3a9dfcc752cd02c
    https://qiita.com/r-ngtm/items/7ec3e3a9dfcc752cd02c

    # Shade More Efficiently
    http://www.martinpalko.com/muli-compile-unity/
  5. smkplus revised this gist Dec 3, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions UnityShaderFFS.md
    Original file line number Diff line number Diff line change
    @@ -195,6 +195,7 @@ Fallback "Sprites/Default"
    ```
    # multi_compile
    https://qiita.com/Es_Program/items/79edf9f8fca786b365aa

    https://qiita.com/r-ngtm/items/7ec3e3a9dfcc752cd02c

    # Unity Material Property Drawer
  6. smkplus revised this gist Dec 3, 2017. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion UnityShaderFFS.md
    Original file line number Diff line number Diff line change
    @@ -66,6 +66,9 @@ _Vector("Vector", Vector) = (0,0,0,0)
    https://cmwdexint.com/2017/05/06/materialpropertydrawer-in-shader-gui-without-creating-shadergui/


    # Controlling fixed function states from materials


    ```
    Shader "Smkgames/Sprites"
    @@ -190,7 +193,9 @@ Fallback "Sprites/Default"
    // // Linear Dodge
    // Blend One One
    ```

    # multi_compile
    https://qiita.com/Es_Program/items/79edf9f8fca786b365aa
    https://qiita.com/r-ngtm/items/7ec3e3a9dfcc752cd02c

    # Unity Material Property Drawer
    https://tedsieblog.wordpress.com/2017/03/02/unity-material-property-drawer/
  7. smkplus revised this gist Dec 2, 2017. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion UnityShaderFFS.md
    Original file line number Diff line number Diff line change
    @@ -193,4 +193,5 @@ Fallback "Sprites/Default"


    # Unity Material Property Drawer
    https://tedsieblog.wordpress.com/2017/03/02/unity-material-property-drawer/
    https://tedsieblog.wordpress.com/2017/03/02/unity-material-property-drawer/
    https://qiita.com/r-ngtm/items/7ec3e3a9dfcc752cd02c
  8. smkplus revised this gist Dec 2, 2017. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion UnityShaderFFS.md
    Original file line number Diff line number Diff line change
    @@ -189,4 +189,8 @@ Fallback "Sprites/Default"
    //
    // // Linear Dodge
    // Blend One One
    ```
    ```


    # Unity Material Property Drawer
    https://tedsieblog.wordpress.com/2017/03/02/unity-material-property-drawer/
  9. smkplus revised this gist Dec 2, 2017. 1 changed file with 68 additions and 0 deletions.
    68 changes: 68 additions & 0 deletions UnityShaderFFS.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,71 @@
    ![16999105_467532653370479_4085466863356780898_n](https://user-images.githubusercontent.com/16706911/33512004-2e53fd6a-d73c-11e7-983b-a526761dc2f8.jpg)

    ```
    Shader "MaterialPropertyDrawer"
    {
    Properties
    {
    _MainTex("Texture", 2D) = "white" {}
    [HideInInspector] _MainTex2("Hide Texture", 2D) = "white" {}
    [NoScaleOffset] _MainTex3("No Scale/Offset Texture", 2D) = "white" {}
    [PerRendererData] _MainTex4("PerRenderer Texture", 2D) = "white" {}
    [Normal] _MainTex5("Normal Texture", 2D) = "white" {}
    _Color("Color", Color) = (1,0,0,1)
    [HDR] _HDRColor("HDR Color", Color) = (1,0,0,1)
    _Vector("Vector", Vector) = (0,0,0,0)
    //Can't go below zero
    [Gamma] _GVector("Gamma Vector", Vector) = (0,0,0,0)
    // Header creates a header text before the shader property.
    [Header(A group of things)]
    // Will set "_INVERT_ON" shader keyword when set
    [Toggle] _Invert("Auto keyword toggle", Float) = 0
    // Will set "ENABLE_FANCY" shader keyword when set.
    [Toggle(ENABLE_FANCY)] _Fancy("Keyword toggle", Float) = 0
    // Will show when ENABLE_FANCY is true //Feature request
    //[ShowIf(ENABLE_FANCY)] _ShowIf("Show If", Float) = 0
    // Blend mode values
    [Enum(UnityEngine.Rendering.BlendMode)] _Blend("Blend mode Enum", Float) = 1
    // A subset of blend mode values, just "One" (value 1) and "SrcAlpha" (value 5).
    [Enum(One,1,SrcAlpha,5)] _Blend2("Blend mode subset", Float) = 1
    // Each option will set _OVERLAY_NONE, _OVERLAY_ADD, _OVERLAY_MULTIPLY shader keywords.
    [KeywordEnum(None, Add, Multiply)] _Overlay("Keyword Enum", Float) = 0
    // ...later on in CGPROGRAM code:
    //#pragma multi_compile _OVERLAY_NONE, _OVERLAY_ADD, _OVERLAY_MULTIPLY
    // ...
    // A slider with 3.0 response curve
    [PowerSlider(3.0)] _Shininess("Power Slider", Range(0.01, 1)) = 0.08
    // An integer slider for specified range (0 to 255)
    [IntRange] _Alpha("Int Range", Range(0, 255)) = 100
    // Default small amount of space.
    [Space] _Prop1("Small amount of space", Float) = 0
    // Large amount of space.
    [Space(50)] _Prop2("Large amount of space", Float) = 0
    }
    ```

    https://cmwdexint.com/2017/05/06/materialpropertydrawer-in-shader-gui-without-creating-shadergui/


    ```
    Shader "Smkgames/Sprites"
  10. smkplus renamed this gist Nov 23, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  11. smkplus revised this gist Nov 23, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Unity_Default_Sprite.md
    Original file line number Diff line number Diff line change
    @@ -29,7 +29,7 @@ Shader "Smkgames/Sprites"
    SubShader
    {
    Tags { "RenderType" = "Opaque" "PerformanceChecks" = "False" }
    Tags { "RenderType" = "Opaque" }
    LOD 100
    Blend[_SrcBlend][_DstBlend]
    ZTest[_ZTest]
  12. smkplus revised this gist Nov 23, 2017. No changes.
  13. smkplus revised this gist Nov 23, 2017. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions Unity_Default_Sprite.md
    Original file line number Diff line number Diff line change
    @@ -89,6 +89,11 @@ ENDCG
    Fallback "Sprites/Default"
    }
    //Culling
    //https://gist.github.com/aras-p/b2a0952161cb0c2b2cc0#file-foo-md
    //Blending
    // // Normal
    // Blend SrcAlpha OneMinusSrcAlpha
    //
  14. smkplus revised this gist Nov 23, 2017. 1 changed file with 4 additions and 8 deletions.
    12 changes: 4 additions & 8 deletions Unity_Default_Sprite.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@

    ```
    Shader "Smkgames/Sprites"
    {
    @@ -89,19 +89,14 @@ ENDCG
    Fallback "Sprites/Default"
    }
    //Culling
    //https://gist.github.com/TJHeuvel/c4f8d218a0d774682560a8f348a90dff#comments

    //Blending Description

    // // Normal
    // Blend SrcAlpha OneMinusSrcAlpha
    //
    // // Soft Additive
    // Blend OneMinusDstColor One
    //
    // // Multiply
    Blend DstColor Zero
    // Blend DstColor Zero
    //
    // // 2x Multiply
    // Blend DstColor SrcColor
    @@ -120,4 +115,5 @@ Fallback "Sprites/Default"
    // Blend One OneMinusSrcColor
    //
    // // Linear Dodge
    // Blend One One
    // Blend One One
    ```
  15. smkplus revised this gist Nov 23, 2017. 1 changed file with 35 additions and 34 deletions.
    69 changes: 35 additions & 34 deletions Unity_Default_Sprite.md
    Original file line number Diff line number Diff line change
    @@ -1,40 +1,41 @@

    Shader "Smkgames/Sprite"
    {
    Properties
    {
    [Header(Main Color)]
    [Toggle] _UseColor("Enabled?", Float) = 1
    _Color("Main Color", Color) = (1,1,1,1)
    [Space(5)]

    [Header(Base(RGB))]
    [Toggle] _UseMainTex("Enabled?", Float) = 1
    _MainTex("Base (RGB)", 2D) = "white" {}
    //[NoScaleOffset] _MainTex("Base (RGB)", 2D) = "white" {}
    [Space(5)]

    [Header(Blend State)]
    [Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend("SrcBlend", Float) = 1 //"One"
    [Enum(UnityEngine.Rendering.BlendMode)] _DstBlend("DestBlend", Float) = 0 //"Zero"
    [Space(5)]

    [Header(Other)]
    [Enum(UnityEngine.Rendering.CullMode)] _Cull("Cull", Float) = 2 //"Back"
    [Enum(UnityEngine.Rendering.CompareFunction)] _ZTest("ZTest", Float) = 4 //"LessEqual"
    [Enum(Off,0,On,1)] _ZWrite("ZWrite", Float) = 1.0 //"On"
    [Enum(UnityEngine.Rendering.ColorWriteMask)] _ColorWriteMask("ColorWriteMask", Float) = 15 //"All"
    }

    SubShader
    Shader "Smkgames/Sprites"
    {
    Tags { "RenderType" = "Opaque" "PerformanceChecks" = "False" }
    LOD 100
    Blend[_SrcBlend][_DstBlend]
    ZTest[_ZTest]
    ZWrite[_ZWrite]
    Cull[_Cull]
    ColorMask[_ColorWriteMask]
    Properties
    {
    [Header(Main Color)]
    [Toggle] _UseColor("Enabled?", Float) = 1
    _Color("Main Color", Color) = (1,1,1,1)
    [Space(5)]

    [Header(Base(RGB))]
    [Toggle] _UseMainTex("Enabled?", Float) = 1
    _MainTex("Base (RGB)", 2D) = "white" {}
    //[NoScaleOffset] _MainTex("Base (RGB)", 2D) = "white" {}
    [Space(5)]

    [Header(Blend State)]
    [Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend("SrcBlend", Float) = 1 //"One"
    [Enum(UnityEngine.Rendering.BlendMode)] _DstBlend("DestBlend", Float) = 0 //"Zero"
    [Space(5)]

    [Header(Other)]
    [Enum(UnityEngine.Rendering.CullMode)] _Cull("Cull", Float) = 2 //"Back"
    [Enum(UnityEngine.Rendering.CompareFunction)] _ZTest("ZTest", Float) = 4 //"LessEqual"
    [Enum(Off,0,On,1)] _ZWrite("ZWrite", Float) = 1.0 //"On"
    [Enum(UnityEngine.Rendering.ColorWriteMask)] _ColorWriteMask("ColorWriteMask", Float) = 15 //"All"
    }

    SubShader
    {
    Tags { "RenderType" = "Opaque" "PerformanceChecks" = "False" }
    LOD 100
    Blend[_SrcBlend][_DstBlend]
    ZTest[_ZTest]
    ZWrite[_ZWrite]
    Cull[_Cull]
    ColorMask[_ColorWriteMask]
    Pass
    {

  16. smkplus revised this gist Nov 23, 2017. 1 changed file with 34 additions and 34 deletions.
    68 changes: 34 additions & 34 deletions Unity_Default_Sprite.md
    Original file line number Diff line number Diff line change
    @@ -1,40 +1,40 @@

    Shader "Smkgames/Sprite"
    {
    Properties
    {
    [Header(Main Color)]
    [Toggle] _UseColor("Enabled?", Float) = 1
    _Color("Main Color", Color) = (1,1,1,1)
    [Space(5)]

    [Header(Base(RGB))]
    [Toggle] _UseMainTex("Enabled?", Float) = 1
    _MainTex("Base (RGB)", 2D) = "white" {}
    //[NoScaleOffset] _MainTex("Base (RGB)", 2D) = "white" {}
    [Space(5)]

    [Header(Blend State)]
    [Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend("SrcBlend", Float) = 1 //"One"
    [Enum(UnityEngine.Rendering.BlendMode)] _DstBlend("DestBlend", Float) = 0 //"Zero"
    [Space(5)]

    [Header(Other)]
    [Enum(UnityEngine.Rendering.CullMode)] _Cull("Cull", Float) = 2 //"Back"
    [Enum(UnityEngine.Rendering.CompareFunction)] _ZTest("ZTest", Float) = 4 //"LessEqual"
    [Enum(Off,0,On,1)] _ZWrite("ZWrite", Float) = 1.0 //"On"
    [Enum(UnityEngine.Rendering.ColorWriteMask)] _ColorWriteMask("ColorWriteMask", Float) = 15 //"All"
    }

    SubShader
    {
    Tags { "RenderType" = "Opaque" "PerformanceChecks" = "False" }
    LOD 100
    Blend[_SrcBlend][_DstBlend]
    ZTest[_ZTest]
    ZWrite[_ZWrite]
    Cull[_Cull]
    ColorMask[_ColorWriteMask]
    Properties
    {
    [Header(Main Color)]
    [Toggle] _UseColor("Enabled?", Float) = 1
    _Color("Main Color", Color) = (1,1,1,1)
    [Space(5)]

    [Header(Base(RGB))]
    [Toggle] _UseMainTex("Enabled?", Float) = 1
    _MainTex("Base (RGB)", 2D) = "white" {}
    //[NoScaleOffset] _MainTex("Base (RGB)", 2D) = "white" {}
    [Space(5)]

    [Header(Blend State)]
    [Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend("SrcBlend", Float) = 1 //"One"
    [Enum(UnityEngine.Rendering.BlendMode)] _DstBlend("DestBlend", Float) = 0 //"Zero"
    [Space(5)]

    [Header(Other)]
    [Enum(UnityEngine.Rendering.CullMode)] _Cull("Cull", Float) = 2 //"Back"
    [Enum(UnityEngine.Rendering.CompareFunction)] _ZTest("ZTest", Float) = 4 //"LessEqual"
    [Enum(Off,0,On,1)] _ZWrite("ZWrite", Float) = 1.0 //"On"
    [Enum(UnityEngine.Rendering.ColorWriteMask)] _ColorWriteMask("ColorWriteMask", Float) = 15 //"All"
    }

    SubShader
    {
    Tags { "RenderType" = "Opaque" "PerformanceChecks" = "False" }
    LOD 100
    Blend[_SrcBlend][_DstBlend]
    ZTest[_ZTest]
    ZWrite[_ZWrite]
    Cull[_Cull]
    ColorMask[_ColorWriteMask]
    Pass
    {

  17. smkplus renamed this gist Nov 23, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  18. smkplus revised this gist Nov 23, 2017. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion Sprite Default Unity
    Original file line number Diff line number Diff line change
    @@ -88,7 +88,8 @@ ENDCG
    Fallback "Sprites/Default"
    }

    //[Culling](https://gist.github.com/TJHeuvel/c4f8d218a0d774682560a8f348a90dff#comments)
    //Culling
    //https://gist.github.com/TJHeuvel/c4f8d218a0d774682560a8f348a90dff#comments

    //Blending Description

  19. smkplus revised this gist Nov 23, 2017. 1 changed file with 33 additions and 1 deletion.
    34 changes: 33 additions & 1 deletion Sprite Default Unity
    Original file line number Diff line number Diff line change
    @@ -86,4 +86,36 @@ ENDCG
    }
    }
    Fallback "Sprites/Default"
    }
    }

    //[Culling](https://gist.github.com/TJHeuvel/c4f8d218a0d774682560a8f348a90dff#comments)

    //Blending Description

    // // Normal
    // Blend SrcAlpha OneMinusSrcAlpha
    //
    // // Soft Additive
    // Blend OneMinusDstColor One
    //
    // // Multiply
    Blend DstColor Zero
    //
    // // 2x Multiply
    // Blend DstColor SrcColor
    //
    // // Darken
    // BlendOp Min
    // Blend One One // When using Min operation, these factors are ignored
    //
    // // Lighten
    // BlendOp Max
    // Blend One One // When using Max operation, these factors are ignored
    //
    // // Screen
    // Blend OneMinusDstColor One
    // Or
    // Blend One OneMinusSrcColor
    //
    // // Linear Dodge
    // Blend One One
  20. smkplus revised this gist Nov 23, 2017. No changes.
  21. smkplus created this gist Nov 23, 2017.
    89 changes: 89 additions & 0 deletions Sprite Default Unity
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,89 @@

    Shader "Smkgames/Sprite"
    {
    Properties
    {
    [Header(Main Color)]
    [Toggle] _UseColor("Enabled?", Float) = 1
    _Color("Main Color", Color) = (1,1,1,1)
    [Space(5)]

    [Header(Base(RGB))]
    [Toggle] _UseMainTex("Enabled?", Float) = 1
    _MainTex("Base (RGB)", 2D) = "white" {}
    //[NoScaleOffset] _MainTex("Base (RGB)", 2D) = "white" {}
    [Space(5)]

    [Header(Blend State)]
    [Enum(UnityEngine.Rendering.BlendMode)] _SrcBlend("SrcBlend", Float) = 1 //"One"
    [Enum(UnityEngine.Rendering.BlendMode)] _DstBlend("DestBlend", Float) = 0 //"Zero"
    [Space(5)]

    [Header(Other)]
    [Enum(UnityEngine.Rendering.CullMode)] _Cull("Cull", Float) = 2 //"Back"
    [Enum(UnityEngine.Rendering.CompareFunction)] _ZTest("ZTest", Float) = 4 //"LessEqual"
    [Enum(Off,0,On,1)] _ZWrite("ZWrite", Float) = 1.0 //"On"
    [Enum(UnityEngine.Rendering.ColorWriteMask)] _ColorWriteMask("ColorWriteMask", Float) = 15 //"All"
    }

    SubShader
    {
    Tags { "RenderType" = "Opaque" "PerformanceChecks" = "False" }
    LOD 100
    Blend[_SrcBlend][_DstBlend]
    ZTest[_ZTest]
    ZWrite[_ZWrite]
    Cull[_Cull]
    ColorMask[_ColorWriteMask]
    Pass
    {

    CGPROGRAM
    #pragma vertex vert
    #pragma fragment frag
    #pragma fragmentoption ARB_precision_hint_fastest
    #include "UnityCG.cginc"

    struct appdata_t
    {
    float4 vertex : POSITION;
    float4 color : COLOR;
    float2 texcoord : TEXCOORD0;
    };

    struct v2f
    {
    half2 texcoord : TEXCOORD0;
    float4 vertex : SV_POSITION;
    fixed4 color : COLOR;
    };

    sampler2D _MainTex;
    fixed4 _Color;
    float _Speed;
    float _UseColor;
    float _UseMainTex;


    v2f vert(appdata_t IN)
    {
    v2f OUT;
    OUT.vertex = UnityObjectToClipPos(IN.vertex);
    OUT.texcoord = IN.texcoord;
    OUT.color = IN.color;
    return OUT;
    }

    float4 frag (v2f i) : COLOR
    {

    float2 uv = i.texcoord.xy;
    float4 tex = lerp(float4(1,1,1,1),tex2D(_MainTex, uv)*i.color,_UseMainTex);

    return lerp(tex,tex*_Color,_UseColor);
    }
    ENDCG
    }
    }
    Fallback "Sprites/Default"
    }