diff --git a/raymarcher.glsl b/raymarcher.glsl index c9aa4f6..1b5953b 100644 --- a/raymarcher.glsl +++ b/raymarcher.glsl @@ -33,7 +33,6 @@ float remap11(float val) { return ((val - .5) * 2.); } -// returns a vec3 of the vector transformed by the matrix vec3 mat3_vec_mul(vec3 m[3], vec3 v) { return v.x * m[0] + v.y * m[1] + v.z * m[2]; } @@ -47,8 +46,7 @@ void main() { const vec3 sphere_pos = vec3(0., 0., 3.); const float rad = 1.; - int i = 0; - for (; i < MAX_ITERATIONS; i++) { + for (int i = 0; i < MAX_ITERATIONS; i++) { float distance = sphere_render(ray_pos, rad, sphere_pos); // Check If within tolerances @@ -57,8 +55,8 @@ void main() { } ray_pos += (distance * ray_dir); + color = vec4(mix(color1, color2, float(i) / float(MAX_ITERATIONS)), 1.); } - color = vec4(mix(color1, color2, float(i) / float(MAX_ITERATIONS)), 1.); // Image stuff for later /* diff --git a/shader.mjs b/shader.mjs index 919e5f2..be42fe4 100644 --- a/shader.mjs +++ b/shader.mjs @@ -125,8 +125,8 @@ function updateCamera(gl, program) { // Rotation const rot = gl.getUniformLocation(program, "camera_rot"); - let M1 = calcRotationMatrix([0, -1, 0], mouse_pos[0]); - let M2 = calcRotationMatrix([-1, 0, 0], mouse_pos[1]); + let M1 = calcRotationMatrix([0, 1, 0], mouse_pos[0]); + let M2 = calcRotationMatrix([1, 0, 0], mouse_pos[1]); let rot_mat = glMatrix.mat3.create(); glMatrix.mat3.mul(rot_mat, M1, M2);