Created
April 5, 2023 14:26
-
-
Save CharlieHess/9f76a33748508458fc983b0518e28e5d to your computer and use it in GitHub Desktop.
Rotating particles using particleVelocity
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
Shader "Custom/ParticleRotation" { | |
Properties { | |
_MainTex ("Particle Texture", 2D) = "white" {} | |
_TintColor ("Tint Color", Color) = (1, 1, 1, 1) | |
} | |
SubShader { | |
Tags {"Queue"="Transparent" "RenderType"="Transparent"} | |
LOD 100 | |
CGPROGRAM | |
#pragma surface surf Lambert vertex:vert | |
sampler2D _MainTex; | |
float4 _TintColor; | |
struct Input { | |
float2 uv_MainTex; | |
float3 particleVelocity; | |
}; | |
void vert (inout appdata_full v, out Input o) { | |
UNITY_INITIALIZE_OUTPUT(Input, o); | |
o.particleVelocity = v.vertex.y * v.tangent.xyz; | |
v.vertex.y = 0; | |
} | |
void surf (Input IN, inout SurfaceOutput o) { | |
float4 c = tex2D(_MainTex, IN.uv_MainTex) * _TintColor; | |
o.Albedo = c.rgb; | |
o.Alpha = c.a; | |
o.Normal = float3(IN.particleVelocity.xy, 0); | |
} | |
ENDCG | |
} | |
FallBack "Diffuse" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment