Compare commits

...

1 Commits
HEAD ... yeet

Author SHA1 Message Date
alistair 731a56a9b8 works 4 years ago
  1. 3
      camera.c
  2. 7
      distfuncs.c
  3. 10
      main.c
  4. BIN
      test.pdf

3
camera.c

@ -295,12 +295,13 @@ process_pixel(int i, int j) @@ -295,12 +295,13 @@ process_pixel(int i, int j)
double fade_intensity = 10;
/*
if (p.travel_dist < DRAW_DIST) {
p.col.r -= fade_intensity * p.travel_dist / DRAW_DIST;
p.col.g -= fade_intensity * p.travel_dist / DRAW_DIST;
p.col.b -= fade_intensity * p.travel_dist / DRAW_DIST;
}
*/
p.col.r = clamp(p.col.r, 0, 255);
p.col.g = clamp(p.col.g, 0, 255);

7
distfuncs.c

@ -183,8 +183,8 @@ double sdf_box(struct vec *x) { @@ -183,8 +183,8 @@ double sdf_box(struct vec *x) {
struct colour yeet_pho(struct ray *ray, struct object *o) {
double specular = 0.8;
double diffuse = 0.55;
double ambient = 0.3;
double shin = 51;
double ambient = 0.1;
double shin = 5;
int light_type = SOFT_LIGHT;
@ -204,7 +204,6 @@ struct colour yeet_pho(struct ray *ray, struct object *o) { @@ -204,7 +204,6 @@ struct colour yeet_pho(struct ray *ray, struct object *o) {
struct vec *light_vec = normalise_vec_ip(subtract_vec_ip(scalar_multiply_vec(light, -1), ray->pos));
double diffuse_val = clamp(dot_product_vec(light_vec, surf_norm) * diffuse, 0, 1);
// r = 2 * (l . n) * n - L
@ -216,7 +215,7 @@ struct colour yeet_pho(struct ray *ray, struct object *o) { @@ -216,7 +215,7 @@ struct colour yeet_pho(struct ray *ray, struct object *o) {
double spec_val = clamp(pow(clamp(dot_product_vec(reflection, camera_vec),-1,1), shin) * specular, 0, 1);
struct colour c = get_hsl(o->base_col);
intensity = ambient + diffuse_val + spec_val;
intensity = ambient + spec_val;
light_col = get_hsl(light_col);
light_col.l = spec_val;
light_col = get_rgb(light_col);

10
main.c

@ -51,7 +51,7 @@ void handle_inputs(void) @@ -51,7 +51,7 @@ void handle_inputs(void)
r.dir = new_vec(4);
r.pos = new_vec(4);
const double dist = 0.1;
const double dist = 0.5;
struct vec ** in = malloc(sizeof(struct vec *) * 3);
in[0] = camera->x;
@ -60,22 +60,28 @@ void handle_inputs(void) @@ -60,22 +60,28 @@ void handle_inputs(void)
if (keyboardstate[SDL_SCANCODE_J]) {
manifoldstepaxees(camera->pos, camera->y, in, 3, -dist);
manifoldstepaxees(camera->light, camera->y, in, 3, -dist);
}
if (keyboardstate[SDL_SCANCODE_K]) {
manifoldstepaxees(camera->pos, camera->y, in, 3, dist);
manifoldstepaxees(camera->light, camera->y, in, 3, dist);
}
if (keyboardstate[SDL_SCANCODE_UP] ) {
manifoldstepaxees(camera->pos, camera->z, in, 3, -dist);
manifoldstepaxees(camera->light, camera->z, in, 3, -dist);
}
if (keyboardstate[SDL_SCANCODE_DOWN]) {
manifoldstepaxees(camera->pos, camera->z, in, 3, dist);
manifoldstepaxees(camera->light, camera->z, in, 3, dist);
}
if (keyboardstate[SDL_SCANCODE_LEFT] || keyboardstate[SDL_SCANCODE_H]) {
manifoldstepaxees(camera->pos, camera->x, in, 3, dist);
manifoldstepaxees(camera->light, camera->x, in, 3, dist);
}
if (keyboardstate[SDL_SCANCODE_RIGHT] || keyboardstate[SDL_SCANCODE_L]) {
manifoldstepaxees(camera->pos, camera->x, in, 3, -dist);
manifoldstepaxees(camera->light, camera->x, in, 3, dist);
}
r.dir->elements[0] = -1;
if (keyboardstate[SDL_SCANCODE_ESCAPE]) {
@ -146,7 +152,7 @@ void setup_camera_scene() @@ -146,7 +152,7 @@ void setup_camera_scene()
camera->y->elements[1] = 1;
camera->z->elements[2] = 1;
camera->light = new_vec4(0, 1000, -1000, 0);
camera->light = new_vec4(-5, -3, -1, 0);
// struct object white_sphere = new_box(new_vec3(-0.75, 0, 8), 0, 1);
// struct object other_white_sphere = new_sphere(new_vec3(0.75, 0, 8), 0, 1);

BIN
test.pdf

Binary file not shown.
Loading…
Cancel
Save