Clusterで使えるShaderめーも

# 開発環境
- Unity 2019.4.22f1
- Cluster Creator Kit 1.13

# Color 
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/63863/9d4f72b2-aa89-584d-9a08-8fcb511f6348.png)

~~~c
Shader "Unlit/ColorUnlitShader"
{
    Properties
    {
        _Color ("Main Color", Color) = (1,1,1,1)
    }

    SubShader
    {
        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"
            
            fixed4 _Color;

            float4 vert (float4 vertex : POSITION) : SV_POSITION
            {
                return UnityObjectToClipPos(vertex);
            }

            fixed4 frag () : SV_Target
            {
                return _Color;
            }
            ENDCG
        }
    }
}
~~~

# Normal 

<blockquote class="twitter-tweet"><p lang="ja" dir="ltr">Shaderのお勉強 <a href="https://twitter.com/hashtag/ShaderLab?src=hash&amp;ref_src=twsrc%5Etfw">#ShaderLab</a> <a href="https://twitter.com/hashtag/Cluster?src=hash&amp;ref_src=twsrc%5Etfw">#Cluster</a> <a href="https://twitter.com/hashtag/Unity?src=hash&amp;ref_src=twsrc%5Etfw">#Unity</a> <a href="https://t.co/plR3gNeWtR">pic.twitter.com/plR3gNeWtR</a></p>&mdash; がちもとさん@メタバース熊本 (@sotongshi) <a href="https://twitter.com/sotongshi/status/1463109852306173955?ref_src=twsrc%5Etfw">November 23, 2021</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

~~~c
Shader "Unlit/NormalUnlitShader"
{
    Properties
    {

    }

    SubShader
    {
        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"

            struct v2f {
                half3 worldNormal : TEXCOORD0;
                float4 pos : SV_POSITION;
            };

            v2f vert (float4 vertex : POSITION, float3 normal : NORMAL)
            {
                v2f o;
                o.pos = UnityObjectToClipPos(vertex);
                o.worldNormal = UnityObjectToWorldNormal(normal);
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                fixed4 c = 0;
                c.rgb = i.worldNormal*0.5 + 0.5;
                return c;
            }
            ENDCG
        }
    }
}

~~~

# シマシマ

<blockquote class="twitter-tweet"><p lang="ja" dir="ltr">しましましぇーだー！<a href="https://twitter.com/hashtag/ShaderLab?src=hash&amp;ref_src=twsrc%5Etfw">#ShaderLab</a> <a href="https://twitter.com/hashtag/Cluster?src=hash&amp;ref_src=twsrc%5Etfw">#Cluster</a> <a href="https://twitter.com/hashtag/Unity?src=hash&amp;ref_src=twsrc%5Etfw">#Unity</a> <a href="https://t.co/JgPTYYJ9H0">pic.twitter.com/JgPTYYJ9H0</a></p>&mdash; がちもとさん@メタバース熊本 (@sotongshi) <a href="https://twitter.com/sotongshi/status/1463167599139860496?ref_src=twsrc%5Etfw">November 23, 2021</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

~~~c
Shader "Unlit/ShimaShimaUnlitShader"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 100

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            // make fog work
            #pragma multi_compile_fog

            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                UNITY_FOG_COORDS(1)
                float4 vertex : SV_POSITION;
            };

            sampler2D _MainTex;
            float4 _MainTex_ST;

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                UNITY_TRANSFER_FOG(o,o.vertex);
                return o;
            }

            void Unity_Multiply_float (float A, float B, out float Out)
            {
                Out = A * B;
            }

            void Unity_Add_float (float A, float B, out float Out)
            {
                Out = A + B;
            }

            void Unity_Fraction_float (float In, out float Out)
            {
                Out = frac(In);
            }

            void Unity_Step_float (float Edge, float In, out float Out)
            {
                Out = step(Edge, In);
            }
            
            fixed4 frag (v2f i) : SV_Target
            {
                float2 _UV_Out = i.uv;
                float _Split_R = _UV_Out[0];
                float _Split_G = _UV_Out[1];
                
                float _Multiply_Out;
                Unity_Multiply_float(_Split_R, 3, _Multiply_Out);
                
                float _Add_Out;
                Unity_Add_float(_Multiply_Out, _Time.y, _Add_Out);
                
                float _Fraction_Out;
                Unity_Fraction_float(_Add_Out, _Fraction_Out);
                
                float _Step_Out;
                Unity_Step_float(_Fraction_Out, 0.5, _Step_Out);
                
                return _Step_Out;
            }
            ENDCG
        }
    }
}
~~~

# 実験
https://cluster.mu/w/eeadc663-e574-483b-906f-58c4acf11426/entry

# 参考
<blockquote class="twitter-tweet"><p lang="ja" dir="ltr">Amplify Shader EditorならClusterで動く？<br>🙅ShaderGraph<br>🙆ShaderForge<br>ワールドに多彩な表現をもたらす「シェーダー」の紹介【Amplify Shader Editor編】 <a href="https://t.co/eMApE6FuzL">https://t.co/eMApE6FuzL</a> <a href="https://twitter.com/cluster_jp?ref_src=twsrc%5Etfw">@cluster_jp</a>より <a href="https://twitter.com/hashtag/Cluster?src=hash&amp;ref_src=twsrc%5Etfw">#Cluster</a> <a href="https://twitter.com/hashtag/Unity?src=hash&amp;ref_src=twsrc%5Etfw">#Unity</a></p>&mdash; がちもとさん@メタバース熊本 (@sotongshi) <a href="https://twitter.com/sotongshi/status/1463305068724174851?ref_src=twsrc%5Etfw">November 24, 2021</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

<blockquote class="twitter-tweet"><p lang="ja" dir="ltr">【検証】clusterで動くシェーダーを求めて｜カティア <a href="https://twitter.com/hashtag/note?src=hash&amp;ref_src=twsrc%5Etfw">#note</a> <a href="https://t.co/UXPWZyOEto">https://t.co/UXPWZyOEto</a> <a href="https://twitter.com/hashtag/Cluster?src=hash&amp;ref_src=twsrc%5Etfw">#Cluster</a> <a href="https://twitter.com/hashtag/Unity?src=hash&amp;ref_src=twsrc%5Etfw">#Unity</a></p>&mdash; がちもとさん@メタバース熊本 (@sotongshi) <a href="https://twitter.com/sotongshi/status/1463305865155387394?ref_src=twsrc%5Etfw">November 24, 2021</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

<blockquote class="twitter-tweet"><p lang="ja" dir="ltr">ShaderGraphのノードと生成されるサンプルコードが書いてある<a href="https://t.co/G7ktp26h1C">https://t.co/G7ktp26h1C</a><a href="https://twitter.com/hashtag/Unity?src=hash&amp;ref_src=twsrc%5Etfw">#Unity</a> <a href="https://twitter.com/hashtag/ShaderGraph?src=hash&amp;ref_src=twsrc%5Etfw">#ShaderGraph</a></p>&mdash; がちもとさん@メタバース熊本 (@sotongshi) <a href="https://twitter.com/sotongshi/status/1463391451513950210?ref_src=twsrc%5Etfw">November 24, 2021</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>