ANIMATING WATER WITH A FRAGMENT SHADER IN IOS8

Make gorgeous water effects to your sprite textures in Spirte Kit with the new SKShader class available in iOS8 . Here comes the class code for a simple fragment shader like in this video

It’s very simple to add a shader to your game. You just have to implement a new SKShader class, set some properties and assign it to a sprite of your choice.
This is a example how a shader can be setup:

Just set the shader file and define the variable names that should be available  inside the shader script via the uniform property of the SKShader class.
I’ve done it here with the texture that should be the background of the water container.
I also assigned the same shader to the stone sprite in the moment when it contacts with the water as you can see in the video .
The uniform property „movement“ is to vary the shader behaviour a bit.

This is the code inside the shader file „shader_water_movement.fsh“

The shader result will look like this
skshader-tutorial

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

*
*
Website