use first pass depth and normal data

This commit is contained in:
ktyl 2021-08-13 19:12:39 +01:00
parent b312d390da
commit 9b61093de4
6 changed files with 31 additions and 26 deletions

View File

@ -1,5 +1,5 @@
const float INF = 100.0;
const float INF = 17.0;
const float PI = 3.14159;
const float E = 2.71828;
const int SAMPLES = 1;
const int BOUNCES = 4;
const int BOUNCES = 8;

View File

@ -43,13 +43,24 @@ void main()
vec2 uv = pixelUv(pixelCoords, dims);
for (int i = 0; i < SAMPLES; i++)
{
// load data from first pass
vec4 d = imageLoad(_g0, ivec2(gl_GlobalInvocationID.xy));
float depth = d.w;
vec3 normal = d.xyz*2.0-1.0; // unpack normal packaged into texture
// create a ray from the uv
Ray ray = createCameraRay(uv);
RayHit firstHit;
firstHit.position = ray.origin+ray.direction*depth;
firstHit.distance = depth;
firstHit.normal = normal;
firstHit.albedo = vec3(1.0,1.0,1.0);
// do a trace using precomputed depth and surface normal values
//RayHit hit = trace(ray);
// trace the rays path around the scene
for (int j = 0; j < BOUNCES; j++)
for (int j = 1; j < BOUNCES; j++)
{
RayHit hit = trace(ray);
@ -57,12 +68,7 @@ void main()
if (length(ray.energy) < 0.001) break;
}
}
pixel.xyz /= SAMPLES;
vec4 d = imageLoad(_g0, ivec2(gl_GlobalInvocationID.xy));
float depth = d.w;
vec3 normal = d.xyz*2.0-1.0; // unpack normal packaged into texture
//pixel.xyz = mix(pixel.xyz, normal, 1.0-depth);
pixel.xyz = mix(pixel.xyz, vec3(1.0), depth);

View File

@ -35,7 +35,7 @@ void main()
// n roughly correlates to steepness of log curve
// TODO: what does this mean in mathematical terms??
float n = 3;
float n = 1.0;
float f = INF;
float z = hit.distance;

View File

@ -1,4 +1,3 @@
#include "main.h"
#include "gfx.h"
#include "clock.h"

View File

@ -26,7 +26,7 @@ void makeSpheres(struct Sphere *spheres, int count)
{
x = 2.0*CGLM_PI * (float)i/(float)count;
sc[0] = sin(x)*d;
sc[1] = sin(x*3.0-t);
sc[1] = sin(x*3.0-5.0*sin(t));
sc[2] = cos(x)*d;
float ic = i/(float)count*CGLM_PI*2.0;

View File

@ -14,10 +14,10 @@
* [ ] do a 'fract
* [-] depth
* [x] acquire value
* [ ] acquire randomness
* [ ] acceleration time !
* [ ] auxiliary textures
* [ ] depth buffer
* [x] acquire randomness
* [-] acceleration time !
* [-] auxiliary textures
* [x] depth buffer
* [ ] frame blending
* [ ] maybe do some fractals
* [ ] mandelbrot