Skip to content

Instantly share code, notes, and snippets.

@CharlieHess
Created April 5, 2023 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CharlieHess/9f76a33748508458fc983b0518e28e5d to your computer and use it in GitHub Desktop.
Save CharlieHess/9f76a33748508458fc983b0518e28e5d to your computer and use it in GitHub Desktop.
Rotating particles using particleVelocity
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