Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7562f0c96 | ||
|
|
33324d728a | ||
|
|
b3f51f305a | ||
|
|
058f9f8a3e | ||
|
|
9cb3b83b9b | ||
|
|
33de0c2799 |
+2
-1
@@ -1,4 +1,5 @@
|
||||
*.exe
|
||||
*.exr
|
||||
./*.png
|
||||
ray_trace
|
||||
ray_trace
|
||||
.vscode
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
EXT = .exe
|
||||
CFLAGS = -O2 -DNDEBUG -I3p -I3p/glad/include -I3p/glfw-3.4.bin.WIN64/include -L3p/glfw-3.4.bin.WIN64/lib-mingw-w64
|
||||
CFLAGS = -O2 -DNDEBUG -I3p -I3p/glad/include -I3p/glfw-3.4.bin.WIN64/include -L3p/glfw-3.4.bin.WIN64/lib-mingw-w64 -ggdb
|
||||
LDFLAGS = -lglfw3 -lopengl32 -lgdi32
|
||||
else
|
||||
UNAME_S := $(shell uname -s)
|
||||
|
||||
+1
-1
@@ -80,7 +80,7 @@ sphere
|
||||
|
||||
sphere
|
||||
emission_color {1 1 1}
|
||||
emission_power 5
|
||||
emission_power 10
|
||||
metallic 0
|
||||
reflectance 0
|
||||
roughness 1
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ cube
|
||||
|
||||
cube
|
||||
emission_color {1 1 1}
|
||||
emission_power 1
|
||||
emission_power 10
|
||||
metallic 0
|
||||
reflectance 1
|
||||
roughness 0
|
||||
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
cube
|
||||
emission_color {0 0 0}
|
||||
emission_power 0
|
||||
metallic 0
|
||||
reflectance 0
|
||||
roughness 1
|
||||
albedo {1 1 1}
|
||||
origin {0 0 0}
|
||||
size {5 0 5}
|
||||
|
||||
cube
|
||||
emission_color {0 0 0}
|
||||
emission_power 0
|
||||
metallic 0
|
||||
reflectance 0
|
||||
roughness 1
|
||||
albedo {0.63 0.065 0.05}
|
||||
origin {0 0 0}
|
||||
size {5 5 0}
|
||||
|
||||
cube
|
||||
emission_color {0 0 0}
|
||||
emission_power 0
|
||||
metallic 0
|
||||
reflectance 0
|
||||
roughness 1
|
||||
albedo {0.14 0.45 0.091}
|
||||
origin {0 0 5}
|
||||
size {5 5 0}
|
||||
|
||||
cube
|
||||
emission_color {0 0 0}
|
||||
emission_power 0
|
||||
metallic 0
|
||||
reflectance 0
|
||||
roughness 1
|
||||
albedo {1 1 1}
|
||||
origin {0 5 0}
|
||||
size {5 0 5}
|
||||
|
||||
cube
|
||||
emission_color {0 0 0}
|
||||
emission_power 0
|
||||
metallic 0
|
||||
reflectance 0
|
||||
roughness 1
|
||||
albedo {1 1 1}
|
||||
origin {5 0 0}
|
||||
size {0 5 5}
|
||||
|
||||
cube
|
||||
emission_color {0 0 0}
|
||||
emission_power 0
|
||||
metallic 0
|
||||
reflectance 0
|
||||
roughness 0
|
||||
albedo {1 1 1}
|
||||
origin {3 0 1}
|
||||
size {1.5 3.2 1.7}
|
||||
|
||||
cube
|
||||
emission_color {0 0 0}
|
||||
emission_power 0
|
||||
metallic 0
|
||||
reflectance 0
|
||||
roughness 0
|
||||
albedo {1 1 1}
|
||||
origin {1 0 3}
|
||||
size {1 1.4 1.2}
|
||||
|
||||
cube
|
||||
emission_color {1.0 0.843 0.682}
|
||||
emission_power 10
|
||||
metallic 0
|
||||
reflectance 0
|
||||
roughness 0
|
||||
albedo {1 1 1}
|
||||
origin {2 4.99 2}
|
||||
size {1 0 1}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
cube
|
||||
emission_color {0 0 0}
|
||||
emission_power 0
|
||||
metallic 0
|
||||
reflectance 0
|
||||
roughness 1
|
||||
albedo {1 1 1}
|
||||
origin {0 0 0}
|
||||
size {5 0 5}
|
||||
|
||||
cube
|
||||
emission_color {0 0 0}
|
||||
emission_power 0
|
||||
metallic 0
|
||||
reflectance 0
|
||||
roughness 1
|
||||
albedo {0.63 0.065 0.05}
|
||||
origin {0 0 0}
|
||||
size {5 5 0}
|
||||
|
||||
cube
|
||||
emission_color {0 0 0}
|
||||
emission_power 0
|
||||
metallic 0
|
||||
reflectance 0
|
||||
roughness 1
|
||||
albedo {0.14 0.45 0.091}
|
||||
origin {0 0 5}
|
||||
size {5 5 0}
|
||||
|
||||
cube
|
||||
emission_color {0 0 0}
|
||||
emission_power 0
|
||||
metallic 0
|
||||
reflectance 0
|
||||
roughness 1
|
||||
albedo {1 1 1}
|
||||
origin {0 5 0}
|
||||
size {5 0 5}
|
||||
|
||||
cube
|
||||
emission_color {0 0 0}
|
||||
emission_power 0
|
||||
metallic 0
|
||||
reflectance 0
|
||||
roughness 1
|
||||
albedo {1 1 1}
|
||||
origin {5 0 0}
|
||||
size {0 5 5}
|
||||
|
||||
cube
|
||||
emission_color {0 0 0}
|
||||
emission_power 0
|
||||
metallic 0
|
||||
reflectance 0
|
||||
roughness 1
|
||||
albedo {1 1 1}
|
||||
origin {3 0 0.5}
|
||||
size {1.5 3.2 4}
|
||||
|
||||
cube
|
||||
emission_color {1.0 0.843 0.682}
|
||||
emission_power 20
|
||||
metallic 0
|
||||
reflectance 0
|
||||
roughness 0
|
||||
albedo {1 1 1}
|
||||
origin {2 4.99 2}
|
||||
size {1 0 1}
|
||||
+15
-4
@@ -21,8 +21,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#include "camera.h"
|
||||
|
||||
static bool first_mouse = true;
|
||||
static float yaw = -90.0f;
|
||||
static float pitch = 0.0f;
|
||||
static float yaw = 0;
|
||||
static float pitch = -3.5;
|
||||
static float last_x = 800.0f / 2.0;
|
||||
static float last_y = 600.0f / 2.0;
|
||||
static float fov = 30.0f;
|
||||
@@ -30,10 +30,21 @@ static float fov = 30.0f;
|
||||
static float delta_time = 0.0f;
|
||||
static float last_frame = 0.0f;
|
||||
|
||||
static Vector3 camera_pos = {5, 5, 5};
|
||||
static Vector3 camera_front = {-1, -1, -1};
|
||||
static Vector3 camera_pos = {-3, 2.5, 2.5};
|
||||
static Vector3 camera_front = {1, 0, 0};
|
||||
static Vector3 camera_up = {0, 1, 0};
|
||||
|
||||
#include <stdio.h>
|
||||
void print_camera(void)
|
||||
{
|
||||
fprintf(stderr, "camera:\n");
|
||||
fprintf(stderr, " pos={%f %f %f}\n", camera_pos.x, camera_pos.y, camera_pos.z);
|
||||
fprintf(stderr, " front={%f %f %f}\n", camera_front.x, camera_front.y, camera_front.z);
|
||||
fprintf(stderr, " up={%f %f %f}\n", camera_up.x, camera_up.y, camera_up.z);
|
||||
fprintf(stderr, " yaw=%f\n", yaw);
|
||||
fprintf(stderr, " pitch=%f\n", pitch);
|
||||
}
|
||||
|
||||
Vector3 get_camera_pos(void)
|
||||
{
|
||||
return camera_pos;
|
||||
|
||||
@@ -39,6 +39,8 @@ void free_cubemap(Cubemap *c)
|
||||
}
|
||||
}
|
||||
|
||||
#include "vector.h"
|
||||
|
||||
Vector3 sample_cubemap(Cubemap *c, Vector3 dir)
|
||||
{
|
||||
float abs_x = absf(dir.x);
|
||||
@@ -49,7 +51,7 @@ Vector3 sample_cubemap(Cubemap *c, Vector3 dir)
|
||||
|
||||
float u;
|
||||
float v;
|
||||
float eps = 0;
|
||||
float eps = 0.0001;
|
||||
|
||||
if (abs_x > abs_y && abs_x > abs_z) {
|
||||
// X dominant
|
||||
|
||||
+711
-292
File diff suppressed because it is too large
Load Diff
@@ -26,7 +26,6 @@ For more information, please refer to <http://unlicense.org/>
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "profile.h"
|
||||
|
||||
// TODO: Clean up this file
|
||||
|
||||
|
||||
+4
-2
@@ -114,8 +114,10 @@ static bool intersect_sphere(Ray r, Sphere s, float *t)
|
||||
float discr = b*b - 4*a*c;
|
||||
|
||||
if (discr > 0) {
|
||||
float s0 = (- b + sqrt(discr)) / (2 * a);
|
||||
float s1 = (- b - sqrt(discr)) / (2 * a);
|
||||
float u = -0.5 * b / a;
|
||||
float v = 0.5 * sqrt(discr) / a;
|
||||
float s0 = u + v;
|
||||
float s1 = u - v;
|
||||
if (s0 > s1) {
|
||||
float tmp = s0;
|
||||
s0 = s1;
|
||||
|
||||
+11
-1
@@ -71,5 +71,15 @@ static uint64_t wyhash64(void) {
|
||||
|
||||
float random_float(void)
|
||||
{
|
||||
return (float) wyhash64() / UINT64_MAX;
|
||||
return (float) rand() / RAND_MAX;
|
||||
}
|
||||
|
||||
bool is_space(char c)
|
||||
{
|
||||
return c == ' ' || c == '\r' || c == '\t' || c == '\n';
|
||||
}
|
||||
|
||||
bool is_digit(char c)
|
||||
{
|
||||
return c >= '0' && c <= '9';
|
||||
}
|
||||
+2
-2
@@ -31,7 +31,7 @@ For more information, please refer to <http://unlicense.org/>
|
||||
|
||||
char *load_file(const char *file, size_t *size);
|
||||
|
||||
inline bool is_space(char c) { return c == ' ' || c == '\r' || c == '\t' || c == '\n'; }
|
||||
inline bool is_digit(char c) { return c >= '0' && c <= '9'; }
|
||||
bool is_space(char c);
|
||||
bool is_digit(char c);
|
||||
|
||||
float random_float(void);
|
||||
@@ -76,6 +76,11 @@ bool isnanv(Vector3 v)
|
||||
return isnan(v.x) || isnan(v.y) || isnan(v.z);
|
||||
}
|
||||
|
||||
bool isinfv(Vector3 v)
|
||||
{
|
||||
return isinf(v.x) || isinf(v.y) || isinf(v.z);
|
||||
}
|
||||
|
||||
bool iszerof(float f)
|
||||
{
|
||||
return f < 0.0001 && f > -0.0001;
|
||||
|
||||
@@ -68,6 +68,7 @@ float absf(float x);
|
||||
float clamp(float x, float min, float max);
|
||||
Vector3 maxv(Vector3 a, Vector3 b);
|
||||
bool isnanv(Vector3 v);
|
||||
bool isinfv(Vector3 v);
|
||||
bool iszerof(float f);
|
||||
bool iszerov(Vector3 v);
|
||||
float avgv(Vector3 v);
|
||||
|
||||
Reference in New Issue
Block a user