Skip to content

Commit

Permalink
Update 01~08.md(210414)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyongti committed Apr 14, 2021
1 parent 85d70e2 commit d4122c1
Show file tree
Hide file tree
Showing 12 changed files with 282 additions and 164 deletions.
31 changes: 16 additions & 15 deletions 00.overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,31 @@

### 02. 우리의 목표

이 교재의 목적은 우리와 같이 코딩을 접한지 얼마 되지 않은 사람들, 컴퓨터 그래픽에 생소한 사람들이 컴퓨터 그래픽을 쉽게 접할 수 있도록 하는 것이다. 따라서 우리는 (교재의 이름은 mini-'raytracing'이지만)레이트레이싱을 구현하기 보다는 (연산이 적고 이해하기 쉬운)phong 셰이더를 이용하여 이미지를 렌더링할 것이다. 만약 그래픽에 대해 더 자세히 알고 싶다면 아래에 링크를 따라가 보는 것을 추천한다.
이 교재의 목적은 우리와 같이 코딩을 접한지 얼마 되지 않은 사람들, 컴퓨터 그래픽에 생소한 사람들이 컴퓨터 그래픽을 쉽게 접할 수 있도록 하는 것이다. 따라서 우리는 (교재의 이름은 mini-'raytracing'이지만)레이트레이싱을 구현하기 보다는 (연산이 적고 이해하기 쉬운)phong lighting model을 이용하여 이미지를 렌더링할 것이다. 만약 그래픽에 대해 더 자세히 알고 싶다면 아래에 링크를 따라가 보는 것을 추천한다.

- [Khan academy](https://www.khanacademy.org/computing/pixar/rendering/rendering1/v/rendering-1) : 레이트레이싱의 기초에 대해 강의하는 동영상. 정말 기초 중의 기초.

- [scratchapixel](https://www.scratchapixel.com/index.php?redirect) : 컴퓨터 그래픽 전반에 대한 이론을 자세하게 설명한 사이트. 혹시 벡터나 행렬이 익숙하지 않다면, Geometry파트를 꼭 읽어보기 바란다.

- [phong shading](https://learnopengl.com/Lighting/Basic-Lighting) : pixar에서 일하시는 굉장한 분이 만든 모델을 설명한 사이트. 우리는 이 사이트를 참고하여 이 교재를 작성했다.
- [phong lighting model(Opengl)](https://learnopengl.com/Lighting/Basic-Lighting) : pixar에서 일하시는 굉장한 분이 만든 모델을 설명한 사이트. 우리는 이 사이트를 참고하여 이 교재를 작성했다.

- [ray tracing in one weekend](https://raytracing.github.io/books/RayTracingInOneWeekend.html) : path-tracing 방식을 이용하여 (진짜 레이트레이싱)구현하는 법에 대한 설명이 있는 사이트.

- [Khan academy](https://www.khanacademy.org/computing/pixar/rendering/rendering1/v/rendering-1) : 레이트레이싱의 기초에 대해 강의하는 동영상. 정말 기초 중의 기초.

### 03. 목차

01. rgb_ppm
02. vector
03. 카메라/ 캔버스
04.
05. 법선
06. 히트 레코드
07. 오브젝트
08. 퐁 렌더링
09. 그림자
10. ~ 13. 도형들
13. 변환/ 회전 3x3
14. 카메라 회전/ 이동
01. [rgb_ppm](./01.rgb_ppm.md)
02. [vector](./02.vector.md)
03. [카메라/캔버스](./03.ray_and_camera.md)
04. [](./04.sphere.md)
05. [법선](./05.normal.md)
6. [히트 레코드](06.hit_record.md)
7. [오브젝트](07.object.md)
8. [퐁 렌더링](08.phong_lighting.md)
9. [그림자](09.hard_shadow.md)
10. [카메라 업그레이드] - 작성중
11. [~ 13. 도형들] - 작성중
12. [변환/ 회전 3x3] - 작성중

보너스 파트

Expand Down
13 changes: 13 additions & 0 deletions 02.vector.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ t_vec3 vdivide(t_vec3 vec, double t);
double vdot(t_vec3 vec, t_vec3 vec2);
t_vec3 vcross(t_vec3 vec, t_vec3 vec2);
t_vec3 vunit(t_vec3 vec);
t_vec3 vmin(t_vec3 vec1, t_vec3 vec2);

#endif
```
Expand Down Expand Up @@ -310,6 +311,18 @@ t_vec3 vunit(t_vec3 vec)
vec.z /= len;
return (vec);
}

// 두 벡터의 원소를 비교하여 작은 값들만 반환
t_vec3 vmin(t_vec3 vec1, t_vec3 vec2)
{
if (vec1.x > vec2.x)
vec1.x = vec2.x;
if (vec1.y > vec2.y)
vec1.y = vec2.y;
if (vec1.z > vec2.z)
vec1.z = vec2.z;
return (vec1);
}
```
***Code6 : [/src/utils/vec3_utils.c]***
Expand Down
1 change: 0 additions & 1 deletion 05.normal.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ double hit_sphere(t_sphere *sp, t_ray *ray)
...
//제거
if (hit_sphere(sphere, ray))
return (discriminant > 0);
//제거 끝
//추가
Expand Down
21 changes: 11 additions & 10 deletions 07.object.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,19 @@ Object 리스트 안에 type은 object 리스트를 봤을 때 현재 리스트

## 7.3. object 적용

object 리스트를 구현했으니 hit함수를 추가하여 object를 받을 수 있게 하자. 그리고 ray_color도 t_sphere에만 한정되지 않는 함수로 바꾸어 주자.
object 리스트를 구현했으니 hit함수를 추가하여 object를 받을 수 있게 하자. 그리고 ray_color와 hit_sphere도 t_sphere에만 한정되지 않는 함수로 바꾸어 주자.

```c
t_point3 ray_at(t_ray *ray, double t);
// 추가
t_color3 ray_color(t_ray *ray, t_object *world); // 수정.
t_point3 ray_at(t_ray *ray, double t);
// 추가
t_color3 ray_color(t_ray *ray, t_object *world); // 수정.

// trace/hit/
t_bool hit(t_object *obj, t_ray *ray, t_hit_record *rec);
t_bool hit_obj(t_object *obj, t_ray *ray, t_hit_record *rec);
// 추가 끝
double hit_sphere(t_sphere *sp, t_ray *ray, t_hit_record *rec);
// trace/hit/
t_bool hit(t_object *obj, t_ray *ray, t_hit_record *rec);
t_bool hit_obj(t_object *obj, t_ray *ray, t_hit_record *rec);
t_bool hit_sphere(t_object *world, t_ray *ray, t_hit_record *rec);
// 추가 끝
...
```
***Code2 : [miniRT/include/trace.h]***
Expand Down Expand Up @@ -100,7 +101,7 @@ t_bool hit_obj(t_object *world, t_ray *ray, t_hit_record *rec)
hit_result = FALSE;
if (world->type == SP)
hit_result = hit_sphere(world->element, ray, rec);
hit_result = hit_sphere(world, ray, rec); //hit_sphere의 첫번째 인자도 t_sphere *에서 t_object *로 수정해주자.
return (hit_result);
}
// 추가 끝
Expand Down
Loading

0 comments on commit d4122c1

Please sign in to comment.