// Made with Amplify Shader Editor v1.9.8 // Available at the Unity Asset Store - http://u3d.as/y3X Shader "Combin Texture" { Properties { _MainTex("MainTex", 2D) = "white" {} _AlphaTex("AlphaTex", 2D) = "white" {} } SubShader { LOD 0 CGINCLUDE #pragma target 3.0 ENDCG Blend Off AlphaToMask Off Cull Back ColorMask RGBA ZWrite On ZTest LEqual Offset 0 , 0 Pass { Name "Custom RT Update" CGPROGRAM #define ASE_VERSION 19800 #include "UnityCustomRenderTexture.cginc" #pragma vertex ASECustomRenderTextureVertexShader #pragma fragment frag #pragma target 3.5 struct ase_appdata_customrendertexture { uint vertexID : SV_VertexID; }; struct ase_v2f_customrendertexture { float4 vertex : SV_POSITION; float3 localTexcoord : TEXCOORD0; // Texcoord local to the update zone (== globalTexcoord if no partial update zone is specified) float3 globalTexcoord : TEXCOORD1; // Texcoord relative to the complete custom texture uint primitiveID : TEXCOORD2; // Index of the update zone (correspond to the index in the updateZones of the Custom Texture) float3 direction : TEXCOORD3; // For cube textures, direction of the pixel being rendered in the cubemap }; uniform sampler2D _MainTex; uniform sampler2D _AlphaTex; ase_v2f_customrendertexture ASECustomRenderTextureVertexShader(ase_appdata_customrendertexture IN ) { ase_v2f_customrendertexture OUT; #if UNITY_UV_STARTS_AT_TOP const float2 vertexPositions[6] = { { -1.0f, 1.0f }, { -1.0f, -1.0f }, { 1.0f, -1.0f }, { 1.0f, 1.0f }, { -1.0f, 1.0f }, { 1.0f, -1.0f } }; const float2 texCoords[6] = { { 0.0f, 0.0f }, { 0.0f, 1.0f }, { 1.0f, 1.0f }, { 1.0f, 0.0f }, { 0.0f, 0.0f }, { 1.0f, 1.0f } }; #else const float2 vertexPositions[6] = { { 1.0f, 1.0f }, { -1.0f, -1.0f }, { -1.0f, 1.0f }, { -1.0f, -1.0f }, { 1.0f, 1.0f }, { 1.0f, -1.0f } }; const float2 texCoords[6] = { { 1.0f, 1.0f }, { 0.0f, 0.0f }, { 0.0f, 1.0f }, { 0.0f, 0.0f }, { 1.0f, 1.0f }, { 1.0f, 0.0f } }; #endif uint primitiveID = IN.vertexID / 6; uint vertexID = IN.vertexID % 6; float3 updateZoneCenter = CustomRenderTextureCenters[primitiveID].xyz; float3 updateZoneSize = CustomRenderTextureSizesAndRotations[primitiveID].xyz; float rotation = CustomRenderTextureSizesAndRotations[primitiveID].w * UNITY_PI / 180.0f; #if !UNITY_UV_STARTS_AT_TOP rotation = -rotation; #endif // Normalize rect if needed if (CustomRenderTextureUpdateSpace > 0.0) // Pixel space { // Normalize xy because we need it in clip space. updateZoneCenter.xy /= _CustomRenderTextureInfo.xy; updateZoneSize.xy /= _CustomRenderTextureInfo.xy; } else // normalized space { // Un-normalize depth because we need actual slice index for culling updateZoneCenter.z *= _CustomRenderTextureInfo.z; updateZoneSize.z *= _CustomRenderTextureInfo.z; } // Compute rotation // Compute quad vertex position float2 clipSpaceCenter = updateZoneCenter.xy * 2.0 - 1.0; float2 pos = vertexPositions[vertexID] * updateZoneSize.xy; pos = CustomRenderTextureRotate2D(pos, rotation); pos.x += clipSpaceCenter.x; #if UNITY_UV_STARTS_AT_TOP pos.y += clipSpaceCenter.y; #else pos.y -= clipSpaceCenter.y; #endif // For 3D texture, cull quads outside of the update zone // This is neeeded in additional to the preliminary minSlice/maxSlice done on the CPU because update zones can be disjointed. // ie: slices [1..5] and [10..15] for two differents zones so we need to cull out slices 0 and [6..9] if (CustomRenderTextureIs3D > 0.0) { int minSlice = (int)(updateZoneCenter.z - updateZoneSize.z * 0.5); int maxSlice = minSlice + (int)updateZoneSize.z; if (_CustomRenderTexture3DSlice < minSlice || _CustomRenderTexture3DSlice >= maxSlice) { pos.xy = float2(1000.0, 1000.0); // Vertex outside of ncs } } OUT.vertex = float4(pos, 0.0, 1.0); OUT.primitiveID = asuint(CustomRenderTexturePrimitiveIDs[primitiveID]); OUT.localTexcoord = float3(texCoords[vertexID], CustomRenderTexture3DTexcoordW); OUT.globalTexcoord = float3(pos.xy * 0.5 + 0.5, CustomRenderTexture3DTexcoordW); #if UNITY_UV_STARTS_AT_TOP OUT.globalTexcoord.y = 1.0 - OUT.globalTexcoord.y; #endif OUT.direction = CustomRenderTextureComputeCubeDirection(OUT.globalTexcoord.xy); return OUT; } float4 frag(ase_v2f_customrendertexture IN ) : COLOR { float4 finalColor; float2 texCoord3 = IN.localTexcoord.xy * float2( 2,1 ) + float2( 0,0 ); float temp_output_7_0 = step( 0.5 , IN.localTexcoord.xy.x ); float2 texCoord4 = IN.localTexcoord.xy * float2( 2,1 ) + float2( -1,0 ); finalColor = ( ( tex2D( _MainTex, texCoord3 ) * ( 1.0 - temp_output_7_0 ) ) + ( temp_output_7_0 * tex2D( _AlphaTex, texCoord4 ) ) ); return finalColor; } ENDCG } } CustomEditor "ASEMaterialInspector" Fallback Off } /*ASEBEGIN Version=19800 Node;AmplifyShaderEditor.TexCoordVertexDataNode;8;-1024,-176;Inherit;False;0;2;0;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.TextureCoordinatesNode;3;-960,-416;Inherit;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;2,1;False;1;FLOAT2;0,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.StepOpNode;7;-800,-176;Inherit;True;2;0;FLOAT;0.5;False;1;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.TextureCoordinatesNode;4;-960,112;Inherit;False;0;-1;2;3;2;SAMPLER2D;;False;0;FLOAT2;2,1;False;1;FLOAT2;-1,0;False;5;FLOAT2;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 Node;AmplifyShaderEditor.SamplerNode;1;-704,-416;Inherit;True;Property;_MainTex;MainTex;0;0;Create;True;0;0;0;False;0;False;-1;c57d05f5262e98a4c9a8a3d68eba069e;c57d05f5262e98a4c9a8a3d68eba069e;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;6;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4;FLOAT3;5 Node;AmplifyShaderEditor.SamplerNode;2;-736,112;Inherit;True;Property;_AlphaTex;AlphaTex;1;0;Create;True;0;0;0;False;0;False;-1;5c3ecef7c8b93dc408f4b3114f6a43ea;5c3ecef7c8b93dc408f4b3114f6a43ea;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;6;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4;FLOAT3;5 Node;AmplifyShaderEditor.OneMinusNode;10;-560,-144;Inherit;False;1;0;FLOAT;0;False;1;FLOAT;0 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;9;-400,48;Inherit;True;2;2;0;FLOAT;0;False;1;COLOR;0,0,0,0;False;1;COLOR;0 Node;AmplifyShaderEditor.SimpleMultiplyOpNode;11;-368,-240;Inherit;True;2;2;0;COLOR;0,0,0,0;False;1;FLOAT;0;False;1;COLOR;0 Node;AmplifyShaderEditor.SimpleAddOpNode;5;-96,0;Inherit;True;2;2;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;1;COLOR;0 Node;AmplifyShaderEditor.TemplateMultiPassMasterNode;0;224,-16;Float;False;True;-1;2;ASEMaterialInspector;0;2;Combin Texture;32120270d1b3a8746af2aca8bc749736;True;Custom RT Update;0;0;Custom RT Update;1;False;True;0;1;False;;0;False;;0;1;False;;0;False;;True;0;False;;0;False;;False;False;False;False;False;False;False;False;False;True;0;False;;False;True;0;False;;False;True;True;True;True;True;0;False;;False;False;False;False;False;False;False;True;False;0;False;;255;False;;255;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;0;False;;False;True;1;False;;True;3;False;;True;True;0;False;;0;False;;True;0;True;2;False;0;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;True;3;False;0;;0;0;Standard;0;0;1;True;False;;False;0 WireConnection;7;1;8;1 WireConnection;1;1;3;0 WireConnection;2;1;4;0 WireConnection;10;0;7;0 WireConnection;9;0;7;0 WireConnection;9;1;2;0 WireConnection;11;0;1;0 WireConnection;11;1;10;0 WireConnection;5;0;11;0 WireConnection;5;1;9;0 WireConnection;0;0;5;0 ASEEND*/ //CHKSM=C2B2551DCE96F7B10FF26624253BDB94E857B25F