4

I would like to create a liquid dynamics. I searched a lot, created balls moving with device motion, but I don't know how to make the balls look like liquid.. I guess it's some mask but I didn't find how to do it. Could someone help me with that? Thanks.

sangony
  • 11,636
  • 4
  • 39
  • 55
Amit Attias
  • 143
  • 7
  • http://stackoverflow.com/q/21457967/2446155 – Andrew May 24 '14 at 02:23
  • Here's an example google found: http://ritios.challengepost.com/submissions/20581-spritekit-fluid-simulation – Andrew May 24 '14 at 02:27
  • 2
    Are you guys reading the pages you're linking or just feel really smart by giving some links you found on google? Both has nothing to do with what I asked. – Amit Attias May 24 '14 at 09:22

2 Answers2

5

Something looking like liquid in games usually follows the following pattern (there are many ways to do this, with filters, shaders, your own custom opengl stuff):

  1. A lot of balls next to each other

  2. Balls have an alpha gradient. So basically if you do a radial gradient in photoshop on the alpha channel with black color you get a very blurry ball. Or just draw a black ball in photoshop and blur it. You get the point.

  3. You hard contrast (threshold) everything. In effect what this does is at a certain threshold it does either 1.0 alpha or 0.0 alpha. So either on or off.

enter image description here

Theis Egeberg
  • 2,556
  • 21
  • 30
3

The idea was clear to me. Didn't know what's the actual filter. Figured it out, the SKSpriteNode is nodeWithImage, the image is a blur ball. Physics body is a ball with a smaller body than the image (so the balls can go a little over each other and become "one piece"). The filter of threshold is set on the scene, like that:

CIFilter *filter = [CIFilter filterWithName:@"CIColorPosterize"];
[filter setValue:@(2.0) forKey:@"inputLevels"];
[scene setFilter:filter];
[scene setShouldEnableEffects:YES];

That's it, if anyone ever reads it and has a problem they're more than welcome to message me for help.

Amit Attias
  • 143
  • 7
  • So when I enable effects on the scene, (with or without filters) when I add an object it basically smears across the screen and never goes away. Have any idea whats going on with that? – Ohmnastrum Jan 28 '15 at 22:43