Implement light sampling and improve filter
This commit is contained in:
@@ -2,3 +2,4 @@
|
||||
*.exr
|
||||
./*.png
|
||||
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}
|
||||
@@ -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
|
||||
|
||||
+373
-478
File diff suppressed because it is too large
Load Diff
+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