Anubis. Plane, distance to a point (Shaders)

Hi, community!
Here’s an example of using the parameters (n, d) of a plane in shaders to find the distance from a point to the plane and do some funny stuff with the result :slight_smile:

A picture of funny stuff:

If someone didn’t get what’s on the picture, it’s Anubis (a god of the Ancient Egypt).

Why Anubis?. Warning! Watching this video can damage your brain! :smile:

As I don’t know how to work with modelling software, I modelled all the scene manually, using only codepen’s editor :blush: So you can see my mad skillz :metal:

Here is a working example:

All the trick is in this part of the fragment shader:

if (dot(, > divisorPlane.w){
  float dist = dot(, + divisorPlane.w;
  float stripes = sin(dist * 3.1415926 - time * 3.1415926 * 2.) * 0.5 + 0.5; = mix(gl_FragColor.grb, stripeColor, step(stripes, 0.5));

divisorPlane, stripeColor and time are uniforms.


Great stuff as always! :+1:

1 Like

Thanks, Michael :handshake:

Great stuff indeed!

1 Like