// Upgrade NOTE: upgraded instancing buffer 'Props' to new syntax. Shader "pieces/MyUnlitIndirect" { Properties { _Color ("Color", Vector) = (1.0, 0.0, 0.0, 1.0) _MainTex ("_MainTex", 2D) = "white" {} _MainTex2 ("_MainTex2", 2D) = "white" {} _MainTex3D ("_MainTex3D", 3D) = "white" {} _Th ("_Th", Range(0,1)) = 0.5 } SubShader { Tags { "RenderType"="Opaque" } //Tags { "RenderType"="Transparent" "Queue"="Transparent" } //Blend SrcAlpha OneMinusSrcAlpha LOD 100 cull off Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag // make fog work #pragma multi_compile_fog #pragma multi_compile_instancing #include "UnityCG.cginc" struct appdata { float4 vertex : POSITION; float2 uv : TEXCOORD0; UNITY_VERTEX_INPUT_INSTANCE_ID }; struct v2f { float2 uv : TEXCOORD0; float4 wPos : TEXCOORD1; // UNITY_FOG_COORDS(1) float4 vertex : SV_POSITION; UNITY_VERTEX_INPUT_INSTANCE_ID }; sampler2D _MainTex; sampler2D _MainTex2; sampler3D _MainTex3D; float4x4 _LocalMatrix; float4 _MainTex_ST; float _Th; UNITY_INSTANCING_BUFFER_START(Props) UNITY_DEFINE_INSTANCED_PROP(fixed4, _Color) // Make _Color an instanced property (i.e. an array) #define _Color_arr Props UNITY_DEFINE_INSTANCED_PROP(fixed4, _Uv) // Make _Color an instanced property (i.e. an array) #define _Uv_arr Props UNITY_INSTANCING_BUFFER_END(Props) v2f vert (appdata v) { v2f o; //インスタンス ID がシェーダー関数にアクセス可能になります。頂点シェーダーの最初に使用する必要があります UNITY_SETUP_INSTANCE_ID (v); //頂点シェーダーで入力構造体から出力構造体へインスタンス ID をコピーします。 //フラグメントシェーダーでは、インスタンスごとのデータにアクセスするときのみ必要です UNITY_TRANSFER_INSTANCE_ID (v, o); //_LocalMatrix float4 globalPos = mul(_LocalMatrix,v.vertex);// float4 pPos = mul(UNITY_MATRIX_VP,globalPos); o.wPos = ComputeScreenPos(pPos); o.vertex = UnityObjectToClipPos(v.vertex); o.uv = TRANSFORM_TEX(v.uv, _MainTex); //UNITY_TRANSFER_FOG(o,o.vertex); return o; } fixed4 frag (v2f i) : SV_Target { UNITY_SETUP_INSTANCE_ID (i); // 変数にアクセス fixed4 c = UNITY_ACCESS_INSTANCED_PROP(_Color_arr, _Color); fixed4 col = tex2D(_MainTex, i.uv); clip(col.a-0.5); //i.uv.x=1-i.uv.x; float2 uvv = i.wPos.xy/i.wPos.w; fixed4 outCol = tex3D(_MainTex3D,float3(uvv,c.w)); //outCol.xyz *= c.rgb; return outCol; //return col;//tex; } ENDCG } } }