Last active
January 1, 2021 23:20
-
-
Save bdunderscore/3481fcb92180cde9535ee8a45f99a276 to your computer and use it in GitHub Desktop.
Instanced version of the Mobile/Particles/Additive shader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Instanced version of the Mobile/Particles/Additive shader | |
// Copyright (c) 2021 bd_. MIT license | |
// Based on Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt) | |
Shader "bd_/MobileParticleAdditiveInstanced" | |
{ | |
Properties | |
{ | |
_MainTex ("Particle Texture", 2D) = "white" {} | |
} | |
SubShader | |
{ | |
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" "PreviewType" = "Plane" } | |
Blend SrcAlpha One | |
Cull Off Lighting Off ZWrite Off | |
LOD 100 | |
Pass | |
{ | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
// make fog work | |
#pragma multi_compile_fog | |
#pragma multi_compile_instancing | |
#include "UnityCG.cginc" | |
UNITY_INSTANCING_BUFFER_START(Props) | |
UNITY_INSTANCING_BUFFER_END(Props) | |
struct appdata | |
{ | |
float4 vertex : POSITION; | |
fixed4 color : COLOR; | |
float2 uv : TEXCOORD0; | |
UNITY_VERTEX_INPUT_INSTANCE_ID | |
}; | |
struct v2f | |
{ | |
float2 uv : TEXCOORD0; | |
fixed4 color : COLOR; | |
UNITY_FOG_COORDS(1) | |
float4 vertex : SV_POSITION; | |
}; | |
sampler2D _MainTex; | |
float4 _MainTex_ST; | |
v2f vert (appdata v) | |
{ | |
v2f o; | |
UNITY_SETUP_INSTANCE_ID(v); | |
o.vertex = UnityObjectToClipPos(v.vertex); | |
o.uv = TRANSFORM_TEX(v.uv, _MainTex); | |
o.color = v.color; | |
UNITY_TRANSFER_FOG(o,o.vertex); | |
return o; | |
} | |
fixed4 frag (v2f i) : SV_Target | |
{ | |
// sample the texture | |
fixed4 col = tex2D(_MainTex, i.uv) * i.color; | |
// apply fog | |
UNITY_APPLY_FOG(i.fogCoord, col); | |
return col; | |
} | |
ENDCG | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment