Shader 2- Living Liquid

For my second shader, I realised that the basic water ripples and waves would be too simple if I'm only going to make three shaders. I added random shapes that rise out of the water periodically, and I have begun adding reactive water ripples, however I haven't gotten them to work yet. The shader tiles in world postion, with panning textures creating the ripples.



I packed the wave ripples and the random object normals into two texture samples, so each one has the red and green channels of their respective normal maps. I then derived the blue/ z channel of the normals for both, and I used a time based function along with the random shapes masks to mask them out. This gives the shapes their slow rise and fall.
 

I used some gerstner wave logic I found in a tutorial to create a gerstner wave function, which I created three instances of and added together to create random waves. The result is a linear travelling wave made up of only z normal information, to move the mesh exclusively upwards in world space. The time multiplication gives the wave its speed, the normalised vec2 gives its direction and the final multiplication gives it its height. The calculations are done in pi to remain consistent with the sin operator.


I got the player location using the level blueprint in order to mask out the rising obects close to the player. My reasoning is that the liquid is wary of the player, and does not want them to touch its shapes. This is done with a sphere mask, using world position and a material collection made to store the player location. I may also use it to store the player rotation, to add another piece of functionality to the liquid.


The shapes mask uses the mask I created in Designer and looping time (using cosine) to make the objects' height oscillate slowly. I find myself using this piece of logic quite frequently, but I'm sure this is common with node setups. 


I have not made enough progress with reactive ripples yet, so I cannot explain it in full, but the basic idea is to use render targets to store various heights of the water; the current height, the previous height, and the height before that. Materials that calculate the water ripples' height, normals, location and velocity are then drawn into the render targets, which are then applied to texture samples in the main material. I used the tutorial from the unreal website, but it does not work yet.



I also made the dark fiber shader interactive using a simple blueprint setup, so that when the player presses the right mouse button, the eyes turn pink, pop out and start following the player.


I have realised this week just how much I need to catch up on in terms of tech art, and the maths and logic required to create reactive ripples has threatened to overwhelm me, but learning so much logic will take time, and I will be doing a lot of research and thinking over the next few days.

Comments

Popular Posts