Creating a fluid-like shader

Started by
0 comments, last by phil_t 9 years, 1 month ago

I'm toying with an idea in my head for a 2D game that involves a fluid like substance on the screen that changes color and moves as sprites move over (or "through") it. In my research I came across a few other games that do something similar to what I'm thinking.

One that I quite like is an old game called Plasma Pong. Here is an example.

From what I understand in this game he is using proper fluid dynamics, which is probably overkill for what I'm thinking. But the effect is similar. I'm thinking perhaps a pixel shader applied to a full screen quad. Then use a render target to set pixels for the position and color of the sprites on the screen. The pixel shader can then use this render target texture to change the "plasma" so it moves and changes color.

Would an approach like this work? I'm not a shader expert so just not sure where to start with this.

Advertisement

It's going to be hard for people to give you any kind of concrete suggestions - I don't think your scenario is described clearly enough.


I'm thinking perhaps a pixel shader applied to a full screen quad. Then use a render target to set pixels for the position and color of the sprites on the screen. The pixel shader can then use this render target texture to change the "plasma" so it moves and changes color.

Would an approach like this work? I'm not a shader expert so just not sure where to start with this.

That description is fairly vague, so it's hard to say. A pixel shader only colors a particular pixel, it can't move any geometry.

What I think you're getting at: Basically a particle system where particles positions and other particle instance data is updated on the GPU, and tracked in a render target.

So, as you said, one render target stores position/color/velocity data. Then a pixel shader runs and updates the position/color/velocity based on some data from the game. This doesn't need to be a full screen quad, just large enough to contain enough pixels to correspond to the max number of particles you want. Using a render target like this is a bit of "hack", but it is the way you'd do it on DX9, for instance. There is probably a cleaner way to do this on DX11.

Then the *vertex shader* for the sprites would use this information to position the sprite.

Google for GPU particle systems, and you may find something useful.

This topic is closed to new replies.

Advertisement