— 光属性のアルモジナ(VRChat勢) (@arumogina) August 27, 2019
Shader "Custom/Base" { Properties{ _MainTex("MainTex",2D) = "white"{} _A("A",Float) = 0.5 _B("B",Float) = 0.5 } SubShader{ Tags{"RenderType"="Opaque" "Queue" = "Geometry"} //透明部分のあるテクスチャを使う場合 //Tags{"Queue" = "Transparent" "RenderType" = "Transparent"} //Blend SrcAlpha OneMinusSrcAlpha Pass{ CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct appdata { float4 vertex:POSITION; float4 uv:TEXCOORD0; }; struct v2f { float4 pos:SV_POSITION; float4 uv:TEXCOORD0; }; float _A; float _B; float2 square(float2 p){ return float2(abs(p.x) + abs(p.y),_A); } float2 circle(float2 p){ return float2(length(p),_B); } v2f vert(appdata v){ v2f o; o.pos = UnityObjectToClipPos(v.vertex); o.uv = v.uv; return o; } sampler2D _MainTex; float4 frag(v2f i) :SV_Target { float2 p = 2*i.uv-1; float a = sin(_Time.y * 5.0) * 0.5 + 0.5; float2 d = lerp(circle(p),square(p),a); float c = lerp(1,0,step(d.x,d.y)); return float4(c,c,c,1); } ENDCG }//Pass }//SubShader FallBack "Diffuse" }