~shockham/airei

dc4febe9c228d5c130c85a39ea01d880e997ea00 — shockham 3 years ago 44878c5
Bounding box magic
2 files changed, 13 insertions(+), 8 deletions(-)

M index.html
M src/shaders/frag.glsl
M index.html => index.html +3 -0
@@ 7,6 7,9 @@
        margin: auto;
        height: 100%;
    }
    body {
        background: #333;
    }
    </style>
  </head>
  <body>

M src/shaders/frag.glsl => src/shaders/frag.glsl +10 -8
@@ 31,6 31,14 @@ float box(vec3 p, vec3 b) {
  vec3 d = abs(p) - b;
  return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0));
}
float bbox(vec3 p, vec3 b, float e) {
  p = abs(p  )-b;
  vec3 q = abs(p+e)-e;
  return min(min(
      length(max(vec3(p.x,q.y,q.z),0.0))+min(max(p.x,max(q.y,q.z)),0.0),
      length(max(vec3(q.x,p.y,q.z),0.0))+min(max(q.x,max(p.y,q.z)),0.0)),
      length(max(vec3(q.x,q.y,p.z),0.0))+min(max(q.x,max(q.y,p.z)),0.0));
}

float disp(vec3 p, float amt) {
    return sin(amt*p.x)*sin(amt*p.y)*sin(amt*p.z);


@@ 63,16 71,10 @@ vec3 rep(in vec3 p, in vec3 c) {
}

float scene(vec3 p) {
    vec3 q = rep(p, vec3(1.0, 0.0, 1.0));
    vec3 q = rep(p, vec3(2.0, 0.0, 2.0));
    vec3 rp = rotateY(time / 4.0 + (sin(time) * 0.1)) * q;

	float o_octa = min(
		sphere(rp, 1.0),
        octa(
            rp + disp(rp, displ * abs(cos(time / 8.0))),
            round + 0.8 + cos(time / 3.69) * 0.5
        )
	);
	float o_octa = bbox(rp, vec3(0.6), 0.08 * (1.0 + sin(time + length(p.xy) / 1.53)));

    return o_octa;
}