I'm starting to think about how to implement a visualization similar to 'Flowing Winds' (which you can see at http://hint.fm/wind/ ) in Unity. What I'm looking for is ideas from the Unity horde, or folks that are interested in collaborating. In a nutshell, Flowing Winds is a flash visualization of wind data in the continental U.S. It uses a 2D vector array of windspeed data and creates wind 'particles' which then move for a set amount of time, leaving (essentially) a fading trail renderer behind them. I don't think there's any feasible way to do this as an actual texture - it's very expensive to update textures every frame in Unity, and it wouldn't take advantage of the 3D nature of Unity. Thus, the only ways I can see is with procedural meshes, procedural particle systems, or shaders. With procedural meshes, I'd keep a list of historical positions for each 'particle' and build a set of billboarded quads back along the track, with fading done through UVs or vertex colors. Not super efficient, probably not scalable. With particle systems, the billboarding is done for you, so I guess you could procedurally array a few particles of different colors to fake a trail. Not super realistic, and probably not scalable. Any brilliant ideas with meshes or particles? My guess is that shaders are the way to go here, but shader writing is my big Unity blind spot. It would be very helpful if someone could point me in the right directions - what terms I should read up on, or shaders I should check out, or just where to start learning the kind of advanced shader writing I'd need for something like this. And of course, if you have any ideas that I haven't mentioned here, please chime in! Thanks, Julien
You can get some interesting persistence effects by setting your camera to "Don't Clear". So, move your particles as you see fit (as particles or quads) per frame. Underneath them have a single, frame-filling quad, colored black with some amount of transparency. this will multiply down the previous frame's color values.
Definitely an interesting idea, and pretty simple. The problem I see is that that only works with a static camera. You couldn't allow the user to move around easily, and definitely couldn't allow 3D panning and tilting. If I'm going to go to the trouble of doing this in Unity, I want it to be in a 3D scene with some other data
Yup, that's certainly a limit unless you can render to texture. I think any shader solution would also depend on render to texture or some simialr way of storing data from frame to frame, though I am not an expert. You might take a look at LineRenderer or Vectrosity, which can do trails quite well and can be more efficient that LineRenderer. You can render partial lines, which means you can reveal lines, rather than repopulating the line's points every frame.
There is a nice way to do GPU particle simulations using DirectX 9 level hardware. This article covers most of the ideas: http://directtovideo.wordpress.com/2009/10/06/a-thoroughly-modern-particle-system/ You may be able to adapt this to your needs.
Im a little unclear what you want to do but im going to take a guess thats its to do a simulation of wind speeds, writing the result to a texture and then displaying the texture? You are right when you say this would be best done in a shaders. In fact this type of simulation is perfect for GPU programing. You will need to use render textures to do this with a shader which are a unity pro feature. I think finding shader examples that simulate wind speeds would be hard, however there are plenty of examples of fluid simulation which could easily be adapted to you needs. For example http://http.developer.nvidia.com/GPUGems/gpugems_ch38.html I also have a project on my blog of a shallow water simulation which is much simpler than standard fluid simulation and covers many of the features you would need to implement. http://scrawkblog.wordpress.com/2013/02/01/height-map-erosion-by-shallow-water-model
Thank you both for your suggestions! I've worked with LineRenderers, and I just worry that they're not going to be scalable, but you're right, they're worth testing at least. Vectrosity looks interesting, doing things more on the GL layer - I'll take a poke at it tomorrow. And yeah, you'd definitely have to save information frame-to-frame - something I'll keep in mind. GPU particles is where I was guessing I would have to go (especially after seeing the DX11 contest winner, http://unity3d.com/contest/dx11 ), so I'll definitely give that article a look too.
Hey scrawk, Didn't see your post when I replied - we must have been typing at the same time. I don't actually need to do any fluid simulation - the data is already provided by the meteorology folks as a giant array of Vector2 or Vector3. What I need to do is create a particle and pull it's velocity each frame from the array, leaving a fading trail behind. Ideally I would do this in 3 dimensions rather than writing to a texture - if I'm gonna do this in Unity, it would be pretty cool to show, say, the winds around a hurricane in 3D. However, if doing it in 2D to a render texture is much easier, and would be a good stepping stone for me in my shader education, I'm happy to do it It's getting pretty late here, so I'll check out your blog post tomorrow and probably have some questions for you. Thanks!
Hey, yer I didnt think you needed to do the full simulation however fluid simulation is two part. First the velocity field is calculated, which you already have. Second the water 'particles' are transported along the velocity field which is similar to the process you are looking at. I am fairly confident this is the way they did it. Im not saying a line render is the wrong way to go, its your project and your would know best what you need, but if you look at how many lines are in those flow maps and every line would need to be represented by some sort of geometry. It would be a nightmare to manage. Anyway good luck with the project and I hope you post your progress as it looks like it could be a amazing project.
Hey, I just started looking through the stuff you sent me. It might take me a while to get through the GPU Gems article, it's pretty in-depth I saw the project attached to your blog post (I'm guessing that's what you wanted me to check out) - I'll try to take a look at that this evening. This is definitely a good start, but I'm always open to any other good ideas or things to read
Yes, the "erosion by shallow water model" project is the one I was suggesting having a look at. It may seem to be totally unrelated to what you want to do but the way the project is set up, its use of shaders and render textures is very similar to what you would need to do. The way the water moves along the velocity field would be the same as wind moving along a velocity field. And Yes the GPU gems article is very in-deth. These are rather advanced topics and you may well find a much simpler way to do it. I am quite interested in these sorts of topics myself and I may recreate the project myself. If you get stuck let me know and I will give you the code if Ive done it.
Hey, just wanted to give a quick update. We've been working on this off and on in our spare time for a while. So far we've come up with 2 iterations. The first was just to use the built-in particle system, and to do all the calculations in the CPU and then update the particles once per frame. We have one giant array for the velocities at each position, and another array that keeps track of particle positions (so we don't have to poll the positions every frame. We don't actually run the particle system - we generate our particles and then pause it, using basically a static pool of particles. When one particle runs out of 'lifetime' we simply move it to a new point on the map, as if a new particle were created. We then run a big loop through the particles each frame, adjusting position, color, etc. and pushing the particles. Performance is decent - we can get 50k-100k particles on a decent mid-range machine. If people are curious, I can post screenshots at some point. For round 2 (which is arguably much more impressive), we're using DX11 and compute shaders, and are running it all on top of TC Particles. Unfortunately, I just haven't had the time for shader training, and you can't argue with a ready made solution As in the first solution, we generate our array of velocities over the globe, and this time turn it into a Texture3D that we pass to the compute shader. We're faking particle trails by just having elongated particles - I was really surprised by how good it turned out, considering. Longer term we'll want to actually poke down into the TC Particles code to add better trails, along with the ability to display on a globe rather than flat plane. Here's a preview, and you can click below for a video. (You really should check out the video - the screenshot doesn't do it justice) http://vimeo.com/hackshaven/fim-wind-vectors
Hi Julien.Lynge, if possible could you please share the work? or could you pls guide me on the scripting part....Need help desperately. Thanks, Kalyan.
@Kalyan, What specifically are you looking for? We're using TC Particles under the hood to do most of the work, and unfortunately since it's a pay product we can't share it or our modifications. Other than that, all we have is a pretty simple loader script that grabs an array of Vector2s from disk (from one of our NOAA weather models), and that's what gives appropriate movement to the particles. I'd suggest grabbing TC Particles and looking through their examples - that should get you most of the way there.
Can Any one help me in achieving the above effect in UNITY. Pls guys, in desperate need.pls guide me...:sad:
It's doable 60fps on any hardware - use a flow map shader & reasonable streaky texture. Enough whinging though. You being sad makes no difference. https://www.google.co.uk/search?q=unity flow map&oq=unity flow map&aqs=chrome..69i57j0l2j69i60.3675j0j4&sourceid=chrome&es_sm=122&ie=UTF-8