Posts

Showing posts with the label particles

Compute Shaders, a basic particle system drawn with a vertex fragment shader

A post for reference really... Not a lot of magic here - except we're using a Graphic procedural - a point- to draw particles. To do this we calculate the position of the particles in the compute shader, then a standard vert-frag shader assigned to a material reads from the gpu buffer and draws the points accordingly. We're also getting the mouse position on screen converted to World Space & having the particles follow that coordinate.  The C# is as follows, careful with the comments i've left...blogger's formatting is a bit wonky - using System.Collections; using System.Collections.Generic; using UnityEngine; #pragma warning disable 0649 public class particle_dave : MonoBehaviour {     private Vector2 cursorPos;     // struct of a particle, fairly simple attributes     struct Particle     {         public Vector3 position;         public Vector3 vel...

combining png file textures and the Streaming Assets folder

Below is some code that takes whatever pngs you put in the Streaming Assets folder, puts them all into one texture and assigns them to a File Texture  input for a Visual FX graph. Certain things like resolution have been hardcoded into this script, so you might want to alter those numbers. You'll want to use the flipbook image so that each image can be used seperately (or not), as sprites. This should work with normal particles as well, if altered a bit.     using System.Collections; using System.Collections.Generic; using UnityEngine; using System.IO; using UnityEngine.UI; using UnityEngine.Networking; using UnityEngine.VFX; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; public class multiTextureScan : MonoBehaviour {     public VisualEffect _visualEffect;     public Dictionary<string, Texture2D> textures = new Dictionary<string, Texture2D>();     // Source textures.     pub...

vfx graph particles disappear when camera moves

 So my particles kept vanishing when I moved or rotated the camera. It turns out the bounds of my particles weren't being set - despite having set a "set position" AA box beneath. Make sure you set the bounds as well!! Plugging in the same AA Box should do the trick. Think of it like setting the Flip fluid domain in Houdini, only the fluid will vanish if you step out of it haha.