1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| float4x4 GetObjectToWorldMatrix(float3 pos) { float4x4 objectMatrix = float4x4( _Size, 0, 0, pos.x, 0, _Size, 0, pos.y, 0, 0, _Size, pos.z, 0, 0, 0, 1); return mul(_LocalToWorldMatrix, objectMatrix); }
v2f vert (appdata v, uint instanceID : SV_InstanceID) { v2f o; Particle particle = _ParticleBuffer[instanceID]; float4x4 objectToWorldMatrix = GetObjectToWorldMatrix(particle.position); float4 positionWS = mul(objectToWorldMatrix, v.vertex); o.pos = TransformWorldToHClip(positionWS); o.uv = _ParticleBuffer[instanceID].uv; return o; }
half4 frag (v2f i) : SV_Target { half4 color = tex2D(_OriginTex, i.uv); half4 targetColor = tex2D(_TargetTex, i.uv); color = lerp(color, targetColor, _Lerp); return color; }
|