added extra files

This commit is contained in:
Sven Vogel 2023-04-14 18:04:27 +02:00
parent d26de46d92
commit 3ffffb9bf5
7 changed files with 28 additions and 20 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

BIN
extra/example-scene.blend Normal file

Binary file not shown.

BIN
extra/example-scene.blend1 Normal file

Binary file not shown.

BIN
extra/reference.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

View File

@ -0,0 +1 @@

View File

@ -3,6 +3,7 @@
#include "rand/random.glsl"
#include "raytracing/raytracing.glsl"
#include "raytracing/camera.glsl"
#include "bsdf.glsl"
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) {
u = normalize(up);
vec3 n2 = vec3(1) - u;
vec3 n3 = vec3(1) - u.zxy;
vec3 n2 = normalize(cross(up, vec3(0, 1.0, 1.0)));
vec3 n3 = cross(u, n2);
vec3 w2 = normalize(n2 - (project(u, n2)));
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);
}
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() {
init_random_state(floatBitsToInt(program_metadata.seconds));
@ -71,23 +94,7 @@ void main() {
Ray camera_ray = construct_camera_ray_pinhole(uv);
vec3 color = vec3(0);
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);
}
}
vec3 color = trace_direct(camera_ray);
// index of the current pixel as array index
uint pixel_index = get_pixel_index();

View File

@ -54,7 +54,7 @@ Hit intersect_scene(in Ray ray) {
if (result.x > ray.near && result.x < hit.depth) {
hit.uv = result.yz;
hit.depth = result.x;
hit.nor = n;
hit.nor = normalize(n);
}
}