-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dc69032
commit 4957d95
Showing
3 changed files
with
24 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: sdiego <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2020/02/26 14:12:41 by sdiego #+# #+# */ | ||
/* Updated: 2020/10/07 19:20:33 by sdiego ### ########.fr */ | ||
/* Updated: 2020/10/07 19:50:13 by sdiego ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -126,6 +126,7 @@ typedef struct s_camera | |
double half_height; | ||
double pixel_size; | ||
int aliasing; | ||
int sepia; | ||
} t_camera; | ||
/* | ||
typedef struct s_x | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: sdiego <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2020/03/08 18:08:48 by sdiego #+# #+# */ | ||
/* Updated: 2020/10/07 18:41:12 by sdiego ### ########.fr */ | ||
/* Updated: 2020/10/07 19:51:11 by sdiego ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -21,6 +21,7 @@ t_camera camera(double hsize, double vsize, double fov) | |
c.hsize = hsize; | ||
c.vsize = vsize; | ||
c.aliasing = 0; | ||
c.sepia = 0; | ||
c.fov = fov; | ||
c.transform = identity_matrix(); | ||
half_view = tanf(c.fov / 2); | ||
|
@@ -80,6 +81,16 @@ typedef struct s_treads | |
int finish; | ||
} t_treads; | ||
|
||
t_color sepia(t_color color) | ||
{ | ||
t_color sepia; | ||
|
||
sepia.r = (0.396 * color.r) + (0.769 * color.g) + (0.189 * color.b); | ||
sepia.g = (0.349 * color.r) + (0.686 * color.g) + (0.168 * color.b); | ||
sepia.b = (0.272 * color.r) + (0.534 * color.g) + (0.131 * color.b); | ||
return (sepia); | ||
} | ||
|
||
void aliasing(t_treads *treads, int x, int y, int remaining) | ||
{ | ||
t_ray r; | ||
|
@@ -99,6 +110,8 @@ void aliasing(t_treads *treads, int x, int y, int remaining) | |
i++; | ||
} | ||
col = divide_col(col, 10); | ||
if (treads->camera->sepia == 1) | ||
col = sepia(col); | ||
treads->sdl->img[y * treads->camera->hsize + x] = col_to_int(col); | ||
} | ||
|
||
|
@@ -120,6 +133,8 @@ void draw(t_treads *treads) | |
{ | ||
r = ray_for_pixel(treads->camera, x, y); | ||
col = color_at(treads->world, r, remaining); | ||
if (treads->camera->sepia == 1) | ||
col = sepia(col); | ||
treads->sdl->img[y * treads->camera->hsize + x] = col_to_int(col); | ||
} | ||
else | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: sdiego <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2020/02/26 14:12:33 by sdiego #+# #+# */ | ||
/* Updated: 2020/10/07 19:18:40 by sdiego ### ########.fr */ | ||
/* Updated: 2020/10/07 19:50:36 by sdiego ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -37,6 +37,11 @@ int key_press(t_sdl *sdl, t_camera *camera) | |
camera->aliasing = camera->aliasing == 0 ? 1 : 0; | ||
sdl->progress = 0; | ||
} | ||
else if (sdl->e.key.keysym.sym == SDLK_2) | ||
{ | ||
camera->sepia = camera->sepia == 0 ? 1 : 0; | ||
sdl->progress = 0; | ||
} | ||
return (0); | ||
} | ||
|
||
|