Compare commits
2 commits
6161fdc460
...
367153bbf6
Author | SHA1 | Date | |
---|---|---|---|
367153bbf6 | |||
b5df780b75 |
2 changed files with 6 additions and 4 deletions
|
@ -33,6 +33,7 @@ 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];
|
||||
}
|
||||
|
@ -46,7 +47,8 @@ void main() {
|
|||
const vec3 sphere_pos = vec3(0., 0., 3.);
|
||||
const float rad = 1.;
|
||||
|
||||
for (int i = 0; i < MAX_ITERATIONS; i++) {
|
||||
int i = 0;
|
||||
for (; i < MAX_ITERATIONS; i++) {
|
||||
float distance = sphere_render(ray_pos, rad, sphere_pos);
|
||||
|
||||
// Check If within tolerances
|
||||
|
@ -55,8 +57,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
|
||||
/*
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue