added extra files
This commit is contained in:
parent
d26de46d92
commit
3ffffb9bf5
Binary file not shown.
After Width: | Height: | Size: 112 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 1.9 MiB |
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "rand/random.glsl"
|
#include "rand/random.glsl"
|
||||||
#include "raytracing/raytracing.glsl"
|
#include "raytracing/raytracing.glsl"
|
||||||
#include "raytracing/camera.glsl"
|
#include "raytracing/camera.glsl"
|
||||||
|
#include "bsdf.glsl"
|
||||||
|
|
||||||
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
||||||
|
|
||||||
|
@ -32,8 +33,8 @@ vec3 project(in vec3 a, in vec3 b) {
|
||||||
void construct_orthonormal_basis(in vec3 up, out vec3 u, out vec3 v, out vec3 w) {
|
void construct_orthonormal_basis(in vec3 up, out vec3 u, out vec3 v, out vec3 w) {
|
||||||
u = normalize(up);
|
u = normalize(up);
|
||||||
|
|
||||||
vec3 n2 = vec3(1) - u;
|
vec3 n2 = normalize(cross(up, vec3(0, 1.0, 1.0)));
|
||||||
vec3 n3 = vec3(1) - u.zxy;
|
vec3 n3 = cross(u, n2);
|
||||||
|
|
||||||
vec3 w2 = normalize(n2 - (project(u, n2)));
|
vec3 w2 = normalize(n2 - (project(u, n2)));
|
||||||
vec3 w3 = normalize(n3 - project(u, n3) - project(w2, n3));
|
vec3 w3 = normalize(n3 - project(u, n3) - project(w2, n3));
|
||||||
|
@ -64,6 +65,28 @@ vec3 generate_diffuse_ray_direction(in vec3 nor) {
|
||||||
return normalize(u * hemisphere.x + v * hemisphere.y + w * hemisphere.z);
|
return normalize(u * hemisphere.x + v * hemisphere.y + w * hemisphere.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vec3 trace_direct(in Ray direct_ray) {
|
||||||
|
Hit hit = intersect_scene(direct_ray);
|
||||||
|
|
||||||
|
if (hit.depth < direct_ray.far) {
|
||||||
|
|
||||||
|
Ray ray;
|
||||||
|
ray.origin = direct_ray.origin + direct_ray.direction * hit.depth;
|
||||||
|
ray.direction = generate_diffuse_ray_direction(hit.nor);
|
||||||
|
ray.near = 1e-3;
|
||||||
|
ray.far = 1.0;
|
||||||
|
|
||||||
|
Hit hit = intersect_scene(ray);
|
||||||
|
if (hit.depth == 1.0) {
|
||||||
|
return vec3(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return vec3(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return vec3(0);
|
||||||
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
init_random_state(floatBitsToInt(program_metadata.seconds));
|
init_random_state(floatBitsToInt(program_metadata.seconds));
|
||||||
|
|
||||||
|
@ -71,23 +94,7 @@ void main() {
|
||||||
|
|
||||||
Ray camera_ray = construct_camera_ray_pinhole(uv);
|
Ray camera_ray = construct_camera_ray_pinhole(uv);
|
||||||
|
|
||||||
vec3 color = vec3(0);
|
vec3 color = trace_direct(camera_ray);
|
||||||
|
|
||||||
Hit result = intersect_scene(camera_ray);
|
|
||||||
|
|
||||||
if (result.depth < camera_ray.far) {
|
|
||||||
Ray ao;
|
|
||||||
ao.origin = camera_ray.origin + camera_ray.direction * result.depth;
|
|
||||||
ao.direction = generate_diffuse_ray_direction(result.nor);
|
|
||||||
ao.near = 1e-3;
|
|
||||||
ao.far = 1e3;
|
|
||||||
|
|
||||||
Hit r2 = intersect_scene(ao);
|
|
||||||
|
|
||||||
if (r2.depth > 1.0) {
|
|
||||||
color = vec3(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// index of the current pixel as array index
|
// index of the current pixel as array index
|
||||||
uint pixel_index = get_pixel_index();
|
uint pixel_index = get_pixel_index();
|
||||||
|
|
|
@ -54,7 +54,7 @@ Hit intersect_scene(in Ray ray) {
|
||||||
if (result.x > ray.near && result.x < hit.depth) {
|
if (result.x > ray.near && result.x < hit.depth) {
|
||||||
hit.uv = result.yz;
|
hit.uv = result.yz;
|
||||||
hit.depth = result.x;
|
hit.depth = result.x;
|
||||||
hit.nor = n;
|
hit.nor = normalize(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue