This repository has been archived by the owner on Nov 26, 2022. It is now read-only.
-
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
Showing
24 changed files
with
1,110 additions
and
997 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[ ] build.bat for Windows | ||
[ ] Create Windows entry point i.e. win32_main.cpp | ||
[ ] Tile size independent multithreaded rendering | ||
- Height and width are must be multiples of the tile size currently |
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
Submodule rw
updated
5 files
+9 −1 | rw_math.h | |
+2 −2 | rw_th.h | |
+3 −3 | rw_time.h | |
+1 −1 | rw_transform.h | |
+1 −1 | rw_types.h |
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
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
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include "camera.h" | ||
#include <math.h> | ||
#include <float.h> | ||
|
||
#include "global.h" | ||
|
||
Camera camera_init(Vec3 position, Vec3 target, Vec3 up, float fov, float aperature) { | ||
Camera result; | ||
result.position = position; | ||
result.target = target; | ||
result.up = up; | ||
result.lens_radius = aperature/2.0f; | ||
// result.focus_dist = rwm_v3_length(position - target); | ||
// TODO(ray): Add depth of field later | ||
float focus_dist = 1.0f; | ||
Vec3 dir = rwm_v3_normalize(position - target); | ||
Vec3 right = rwm_v3_normalize(rwm_v3_cross(up, dir)); | ||
Vec3 new_up = rwm_v3_cross(dir, right); | ||
|
||
float theta = rwm_to_radians(fov); | ||
float half_height = tan(theta/2); | ||
float half_width = ASPECT * half_height; | ||
// result.lower_left = position - (half_width * right) - (half_height * new_up) - dir; | ||
result.lower_left = position - (half_width * focus_dist * right) - (half_height * focus_dist * new_up) - dir * focus_dist; | ||
result.horizontal = 2 * half_width * focus_dist * right; | ||
result.vertical = 2 * half_height * focus_dist * new_up; | ||
// result.position = rwm_v3_zero(); | ||
// result.lower_left = rwm_v3_init(-2.0, -1.0, -1.0); | ||
// result.horizontal = rwm_v3_init(4.0, 0.0, 0.0); | ||
// result.vertical = rwm_v3_init(0.0, 2.0, 0.0); | ||
return result; | ||
} | ||
|
||
Camera camera_init_default() { | ||
return camera_init( | ||
rwm_v3_init(0.0, 0.0, 0.0), // position | ||
rwm_v3_init(0.0, 0.0, -1.0), // target | ||
rwm_v3_init(0.0, 1.0, 0.0), // up | ||
90.0f, // fov | ||
2.0f // aperature | ||
); | ||
} | ||
|
||
// For simplicity, instead of using PBRT camera, use the RTiaW camera | ||
Ray camera_get_ray(Camera *camera, float res_x, float res_y) { | ||
// Normalize raster space coordinates | ||
float u = (float) res_x/(float) WIDTH; | ||
float v = (float) res_y/(float) HEIGHT; | ||
|
||
Ray result = ray_init( | ||
camera->position, | ||
camera->lower_left + (u*camera->horizontal) + (v*camera->vertical) - camera->position | ||
); | ||
result.type = RT_CAMERA; | ||
return result; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef __CAMERA_H__ | ||
#define __CAMERA_H__ | ||
|
||
#include <rw/rw_math.h> | ||
#include "ray.h" | ||
|
||
struct Camera { | ||
Vec3 position; | ||
Vec3 target; | ||
Vec3 up; | ||
float fov; | ||
|
||
// Computed | ||
Vec3 lower_left; | ||
Vec3 horizontal; | ||
Vec3 vertical; | ||
float lens_radius; | ||
float focus_dist; | ||
}; | ||
|
||
Camera camera_init(Vec3 position, Vec3 target, Vec3 up, float fov, float aperature); | ||
Camera camera_init_default(); | ||
|
||
// For simplicity, instead of using PBRT camera, use the RTiaW camera | ||
Ray camera_get_ray(Camera *camera, float res_x, float res_y); | ||
|
||
|
||
#endif |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef __GLOBAL_H__ | ||
#define __GLOBAL_H__ | ||
|
||
#define WIDTH 640 | ||
#define HEIGHT 480 | ||
#define ASPECT ((float)WIDTH/(float)HEIGHT) | ||
|
||
#define EPSILON 0.00001f | ||
#define BIAS 0.0001f | ||
#define REFRACT_BIAS 0.00001f | ||
|
||
#define MAX_DEPTH 2 | ||
#define SAMPLES_PER_PIXEL 4 | ||
|
||
#define USE_GLOBAL_ILLUMINATION 1 | ||
#define NUM_PT_SAMPLES 32 | ||
|
||
#define TILE_X 16 | ||
#define TILE_Y 16 | ||
#define NUM_THREADS 8 | ||
|
||
#endif |
Oops, something went wrong.