Skip to content

Commit

Permalink
修正
Browse files Browse the repository at this point in the history
  • Loading branch information
takah29 committed Sep 22, 2021
1 parent 9c45b51 commit ee94740
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 37 deletions.
34 changes: 21 additions & 13 deletions docs/main_cornellbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@
}

vec3 sample_lens(in Camera camera, in float seed, in float dof_size) {
vec2 r = hash2(seed);
return camera.pos + (camera.right * r.r * cos(2. * PI * r.t) + camera.top * r.r * sin(2. * PI * r.t)) * dof_size;
vec2 u = hash2(seed);
float theta = 2. * PI * u.x;
float r = sqrt(u.y);
return camera.pos + (camera.right * r * cos(theta) + camera.top * r * sin(theta)) * dof_size;
}

vec3 get_brdf_ray(vec3 normal, const in vec3 ray_dir, const in Material mtl, inout bool specular_bounce,
Expand Down Expand Up @@ -215,7 +217,7 @@
vec3 ref;
if (hash1(seed) < fresnel) {
ref = reflect(ray_dir, normal);
}else{
} else {
ref = refract(ray_dir, normal, n2 / n1);
}

Expand Down Expand Up @@ -341,8 +343,10 @@
}

vec3 sample_lens(in Camera camera, in float seed, in float dof_size) {
vec2 r = hash2(seed);
return camera.pos + (camera.right * r.r * cos(2. * PI * r.t) + camera.top * r.r * sin(2. * PI * r.t)) * dof_size;
vec2 u = hash2(seed);
float theta = 2. * PI * u.x;
float r = sqrt(u.y);
return camera.pos + (camera.right * r * cos(theta) + camera.top * r * sin(theta)) * dof_size;
}

vec3 get_brdf_ray(vec3 normal, const in vec3 ray_dir, const in Material mtl, inout bool specular_bounce,
Expand Down Expand Up @@ -379,7 +383,7 @@
vec3 ref;
if (hash1(seed) < fresnel) {
ref = reflect(ray_dir, normal);
}else{
} else {
ref = refract(ray_dir, normal, n2 / n1);
}

Expand Down Expand Up @@ -835,8 +839,10 @@
}

vec3 sample_lens(in Camera camera, in float seed, in float dof_size) {
vec2 r = hash2(seed);
return camera.pos + (camera.right * r.r * cos(2. * PI * r.t) + camera.top * r.r * sin(2. * PI * r.t)) * dof_size;
vec2 u = hash2(seed);
float theta = 2. * PI * u.x;
float r = sqrt(u.y);
return camera.pos + (camera.right * r * cos(theta) + camera.top * r * sin(theta)) * dof_size;
}

vec3 get_brdf_ray(vec3 normal, const in vec3 ray_dir, const in Material mtl, inout bool specular_bounce,
Expand Down Expand Up @@ -873,7 +879,7 @@
vec3 ref;
if (hash1(seed) < fresnel) {
ref = reflect(ray_dir, normal);
}else{
} else {
ref = refract(ray_dir, normal, n2 / n1);
}

Expand Down Expand Up @@ -1355,11 +1361,13 @@
ray.o = sample_lens(camera, seed, dof_size);
ray.d = normalize(fp - ray.o);

seed = mod(seed * 1.1234567893490423, 13.);

// motion blur
set_light_pos(iTime + hash1(seed) / MOTIONBLURFPS);

color += path_trace(ray, seed);
seed = mod(seed * 1.1234567893490423, 13.);

}

color /= float(SAMPLES);
Expand Down Expand Up @@ -1542,9 +1550,9 @@

let renderer = new THREE.WebGLRenderer({ canvas: canvas, antialias: true, context: gl, preserveDrawingBuffer: true });
let resolution = new THREE.Vector3();
let mouse = new THREE.Vector4(679, 353, -681, -400);
let mouse = new THREE.Vector4(764, 179, -499, -236);
let mouseButton = new THREE.Vector4(0, 0, 0, 0);
let normalizedMouse = new THREE.Vector2(0.42140221402214023, 0.189873417721519);
let normalizedMouse = new THREE.Vector2(0.0014705882352941176, 0.1302149178255373);
let frameCounter = 0;

// Audio Init
Expand All @@ -1558,7 +1566,7 @@
buffers.push({
Name: '/home/taka/workspace/program/glsl/fractal-path-tracer/cornellbox/main_cornellbox.glsl',
File: '/home/taka/workspace/program/glsl/fractal-path-tracer/cornellbox/main_cornellbox.glsl',
LineOffset: 596,
LineOffset: 598,
Target: null,
ChannelResolution: Array(10).fill(new THREE.Vector3(0,0,0)),
PingPongTarget: null,
Expand Down
30 changes: 18 additions & 12 deletions docs/main_mandelbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,10 @@
}

vec3 sample_lens(in Camera camera, in float seed, in float dof_size) {
vec2 r = hash2(seed);
return camera.pos + (camera.right * r.r * cos(2. * PI * r.t) + camera.top * r.r * sin(2. * PI * r.t)) * dof_size;
vec2 u = hash2(seed);
float theta = 2. * PI * u.x;
float r = sqrt(u.y);
return camera.pos + (camera.right * r * cos(theta) + camera.top * r * sin(theta)) * dof_size;
}

vec3 get_brdf_ray(vec3 normal, const in vec3 ray_dir, const in Material mtl, inout bool specular_bounce,
Expand Down Expand Up @@ -214,7 +216,7 @@
vec3 ref;
if (hash1(seed) < fresnel) {
ref = reflect(ray_dir, normal);
}else{
} else {
ref = refract(ray_dir, normal, n2 / n1);
}

Expand Down Expand Up @@ -339,8 +341,10 @@
}

vec3 sample_lens(in Camera camera, in float seed, in float dof_size) {
vec2 r = hash2(seed);
return camera.pos + (camera.right * r.r * cos(2. * PI * r.t) + camera.top * r.r * sin(2. * PI * r.t)) * dof_size;
vec2 u = hash2(seed);
float theta = 2. * PI * u.x;
float r = sqrt(u.y);
return camera.pos + (camera.right * r * cos(theta) + camera.top * r * sin(theta)) * dof_size;
}

vec3 get_brdf_ray(vec3 normal, const in vec3 ray_dir, const in Material mtl, inout bool specular_bounce,
Expand Down Expand Up @@ -377,7 +381,7 @@
vec3 ref;
if (hash1(seed) < fresnel) {
ref = reflect(ray_dir, normal);
}else{
} else {
ref = refract(ray_dir, normal, n2 / n1);
}

Expand Down Expand Up @@ -833,8 +837,10 @@
}

vec3 sample_lens(in Camera camera, in float seed, in float dof_size) {
vec2 r = hash2(seed);
return camera.pos + (camera.right * r.r * cos(2. * PI * r.t) + camera.top * r.r * sin(2. * PI * r.t)) * dof_size;
vec2 u = hash2(seed);
float theta = 2. * PI * u.x;
float r = sqrt(u.y);
return camera.pos + (camera.right * r * cos(theta) + camera.top * r * sin(theta)) * dof_size;
}

vec3 get_brdf_ray(vec3 normal, const in vec3 ray_dir, const in Material mtl, inout bool specular_bounce,
Expand Down Expand Up @@ -871,7 +877,7 @@
vec3 ref;
if (hash1(seed) < fresnel) {
ref = reflect(ray_dir, normal);
}else{
} else {
ref = refract(ray_dir, normal, n2 / n1);
}

Expand Down Expand Up @@ -1570,9 +1576,9 @@

let renderer = new THREE.WebGLRenderer({ canvas: canvas, antialias: true, context: gl, preserveDrawingBuffer: true });
let resolution = new THREE.Vector3();
let mouse = new THREE.Vector4(1223, 688, -1219, -633);
let mouse = new THREE.Vector4(611, 302, -645, -329);
let mouseButton = new THREE.Vector4(0, 0, 0, 0);
let normalizedMouse = new THREE.Vector2(0.3033210332103321, 0.8240506329113924);
let normalizedMouse = new THREE.Vector2(0.5029411764705882, 0.10745891276864729);
let frameCounter = 0;

// Audio Init
Expand All @@ -1586,7 +1592,7 @@
buffers.push({
Name: '/home/taka/workspace/program/glsl/fractal-path-tracer/mandelbox/buffer_mandelbox.glsl',
File: '/home/taka/workspace/program/glsl/fractal-path-tracer/mandelbox/buffer_mandelbox.glsl',
LineOffset: 595,
LineOffset: 597,
Target: new THREE.WebGLRenderTarget(resolution.x, resolution.y, { type: framebufferType }),
ChannelResolution: Array(10).fill(new THREE.Vector3(0,0,0)),
PingPongTarget: new THREE.WebGLRenderTarget(resolution.x, resolution.y, { type: framebufferType }),
Expand Down
30 changes: 18 additions & 12 deletions docs/main_mandelbulb.html
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,10 @@
}

vec3 sample_lens(in Camera camera, in float seed, in float dof_size) {
vec2 r = hash2(seed);
return camera.pos + (camera.right * r.r * cos(2. * PI * r.t) + camera.top * r.r * sin(2. * PI * r.t)) * dof_size;
vec2 u = hash2(seed);
float theta = 2. * PI * u.x;
float r = sqrt(u.y);
return camera.pos + (camera.right * r * cos(theta) + camera.top * r * sin(theta)) * dof_size;
}

vec3 get_brdf_ray(vec3 normal, const in vec3 ray_dir, const in Material mtl, inout bool specular_bounce,
Expand Down Expand Up @@ -214,7 +216,7 @@
vec3 ref;
if (hash1(seed) < fresnel) {
ref = reflect(ray_dir, normal);
}else{
} else {
ref = refract(ray_dir, normal, n2 / n1);
}

Expand Down Expand Up @@ -339,8 +341,10 @@
}

vec3 sample_lens(in Camera camera, in float seed, in float dof_size) {
vec2 r = hash2(seed);
return camera.pos + (camera.right * r.r * cos(2. * PI * r.t) + camera.top * r.r * sin(2. * PI * r.t)) * dof_size;
vec2 u = hash2(seed);
float theta = 2. * PI * u.x;
float r = sqrt(u.y);
return camera.pos + (camera.right * r * cos(theta) + camera.top * r * sin(theta)) * dof_size;
}

vec3 get_brdf_ray(vec3 normal, const in vec3 ray_dir, const in Material mtl, inout bool specular_bounce,
Expand Down Expand Up @@ -377,7 +381,7 @@
vec3 ref;
if (hash1(seed) < fresnel) {
ref = reflect(ray_dir, normal);
}else{
} else {
ref = refract(ray_dir, normal, n2 / n1);
}

Expand Down Expand Up @@ -833,8 +837,10 @@
}

vec3 sample_lens(in Camera camera, in float seed, in float dof_size) {
vec2 r = hash2(seed);
return camera.pos + (camera.right * r.r * cos(2. * PI * r.t) + camera.top * r.r * sin(2. * PI * r.t)) * dof_size;
vec2 u = hash2(seed);
float theta = 2. * PI * u.x;
float r = sqrt(u.y);
return camera.pos + (camera.right * r * cos(theta) + camera.top * r * sin(theta)) * dof_size;
}

vec3 get_brdf_ray(vec3 normal, const in vec3 ray_dir, const in Material mtl, inout bool specular_bounce,
Expand Down Expand Up @@ -871,7 +877,7 @@
vec3 ref;
if (hash1(seed) < fresnel) {
ref = reflect(ray_dir, normal);
}else{
} else {
ref = refract(ray_dir, normal, n2 / n1);
}

Expand Down Expand Up @@ -1582,9 +1588,9 @@

let renderer = new THREE.WebGLRenderer({ canvas: canvas, antialias: true, context: gl, preserveDrawingBuffer: true });
let resolution = new THREE.Vector3();
let mouse = new THREE.Vector4(485, 297, -591, -224);
let mouse = new THREE.Vector4(611, 302, -645, -329);
let mouseButton = new THREE.Vector4(0, 0, 0, 0);
let normalizedMouse = new THREE.Vector2(0.16383763837638377, 0.6835443037974683);
let normalizedMouse = new THREE.Vector2(0.0014705882352941176, 0.14032869785082175);
let frameCounter = 0;

// Audio Init
Expand All @@ -1598,7 +1604,7 @@
buffers.push({
Name: '/home/taka/workspace/program/glsl/fractal-path-tracer/mandelbulb/buffer_mandelbulb.glsl',
File: '/home/taka/workspace/program/glsl/fractal-path-tracer/mandelbulb/buffer_mandelbulb.glsl',
LineOffset: 595,
LineOffset: 597,
Target: new THREE.WebGLRenderTarget(resolution.x, resolution.y, { type: framebufferType }),
ChannelResolution: Array(10).fill(new THREE.Vector3(0,0,0)),
PingPongTarget: new THREE.WebGLRenderTarget(resolution.x, resolution.y, { type: framebufferType }),
Expand Down

0 comments on commit ee94740

Please sign in to comment.