Compare commits
5 Commits
1c672e0f42
...
b747dcfb21
Author | SHA1 | Date |
---|---|---|
Cat Flynn | b747dcfb21 | |
Cat Flynn | 424029f58b | |
Cat Flynn | 9b85cf18a2 | |
Cat Flynn | 10c1daf676 | |
Cat Flynn | 55d9620983 |
|
@ -1,4 +1,4 @@
|
||||||
const float INF = 30.0;
|
const float INF = 45.0;
|
||||||
const float PI = 3.14159;
|
const float PI = 3.14159;
|
||||||
const float E = 2.71828;
|
const float E = 2.71828;
|
||||||
const int BOUNCES = 5;
|
const int BOUNCES = 5;
|
||||||
|
|
|
@ -7,7 +7,7 @@ float getLogarithmicDepth(float distance)
|
||||||
{
|
{
|
||||||
// n roughly correlates to steepness of log curve
|
// n roughly correlates to steepness of log curve
|
||||||
// TODO: what does this mean in mathematical terms??
|
// TODO: what does this mean in mathematical terms??
|
||||||
float n = 4;
|
float n = 2;
|
||||||
float f = INF;
|
float f = INF;
|
||||||
float z = distance;
|
float z = distance;
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,34 @@ RayHit trace(inout Ray ray)
|
||||||
intersectSphere(ray, hit, _spheres[i]);
|
intersectSphere(ray, hit, _spheres[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int sphereCount = 10;
|
||||||
|
for (int i = 0; i < sphereCount; i++)
|
||||||
|
{
|
||||||
|
Sphere s;
|
||||||
|
float a = i/float(sphereCount)*2.0*PI;
|
||||||
|
float d = 17.0 + cos((1.3+a)*3.0) * 3.0;
|
||||||
|
float r = 4.0 + sin(a*3.0)*2.0;
|
||||||
|
s.cr = vec4(sin(a)*d,2.0*r+cos(a*5.0),cos(a)*d, r);
|
||||||
|
s.albedo = vec3(.2);
|
||||||
|
s.material = i % 3 == 0 ? MAT_CHROME : MAT_LAMBERT;
|
||||||
|
|
||||||
|
intersectSphere(ray, hit, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
sphereCount = 3;
|
||||||
|
for (int i = 0; i < sphereCount; i++)
|
||||||
|
{
|
||||||
|
Sphere s;
|
||||||
|
float a = i/float(sphereCount)*2.0*PI;
|
||||||
|
float d = 5.0 + cos((5.34+a)*5.0) * 3.0;
|
||||||
|
float r = 3.0 + sin(a*2.0)*1.5;
|
||||||
|
s.cr = vec4(sin(a)*d,4.0*r+cos(a*5.0),cos(a)*d, r);
|
||||||
|
s.albedo = vec3(.2);
|
||||||
|
s.material = i % 3 == 0 ? MAT_CHROME : MAT_LAMBERT;
|
||||||
|
|
||||||
|
intersectSphere(ray, hit, s);
|
||||||
|
}
|
||||||
|
|
||||||
ray.distance += hit.distance * float(hit.distance < INF);
|
ray.distance += hit.distance * float(hit.distance < INF);
|
||||||
|
|
||||||
return hit;
|
return hit;
|
||||||
|
|
|
@ -49,9 +49,9 @@ vec4 denoise(sampler2D tex, vec2 uv, float sigma, float kSigma, float threshold)
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
float sigma = 2.2;
|
float sigma = 2.0;
|
||||||
float kSigma = 10.0;
|
float kSigma = 7.0;
|
||||||
float threshold = 0.2;
|
float threshold = 0.18;
|
||||||
|
|
||||||
FragColor = denoise(ourTexture, TexCoord, sigma, kSigma, threshold);
|
FragColor = denoise(ourTexture, TexCoord, sigma, kSigma, threshold);
|
||||||
//FragColor = texture(ourTexture, TexCoord);
|
//FragColor = texture(ourTexture, TexCoord);
|
||||||
|
|
|
@ -99,6 +99,13 @@ void main()
|
||||||
depth += sampleDepth / float(samples);
|
depth += sampleDepth / float(samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// include the first sample we took
|
||||||
|
samples++;
|
||||||
|
// gamma correction
|
||||||
|
float scale = 1.0 / samples;
|
||||||
|
pixel.xyz = sqrt(scale * pixel.xyz);
|
||||||
|
|
||||||
pixel.xyz = mix(pixel.xyz, vec3(1.0), depth);
|
pixel.xyz = mix(pixel.xyz, vec3(1.0), depth);
|
||||||
|
|
||||||
// output to a specific pixel in the image
|
// output to a specific pixel in the image
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
#include "cam.h"
|
#include "cam.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
|
||||||
const int WIDTH = 420;
|
const int WIDTH = 500;
|
||||||
const int HEIGHT = 420;
|
const int HEIGHT = 500;
|
||||||
|
|
||||||
void updateUniforms(GLuint shaderProgram, float t);
|
void updateUniforms(GLuint shaderProgram, float t);
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ void updateUniforms(GLuint shaderProgram, float t)
|
||||||
updateCameraUniforms(shaderProgram, aspect, t);
|
updateCameraUniforms(shaderProgram, aspect, t);
|
||||||
|
|
||||||
// make and update spheres
|
// make and update spheres
|
||||||
const int sphereCount = 41;
|
const int sphereCount = 25;
|
||||||
struct Sphere spheres[sphereCount];
|
struct Sphere spheres[sphereCount];
|
||||||
makeSpheres(spheres, sphereCount, t);
|
makeSpheres(spheres, sphereCount, t);
|
||||||
updateSphereUniforms(shaderProgram, spheres, sphereCount);
|
updateSphereUniforms(shaderProgram, spheres, sphereCount);
|
||||||
|
|
|
@ -30,13 +30,13 @@ void makeSpheres(struct Sphere *spheres, int count, float t)
|
||||||
int rainbowSpheres = count - middleSpheres;
|
int rainbowSpheres = count - middleSpheres;
|
||||||
// distance from center
|
// distance from center
|
||||||
float d = 6.0;
|
float d = 6.0;
|
||||||
radius = 0.5;
|
radius = 0.7;
|
||||||
float x;
|
float x;
|
||||||
for (int i = 0; i < rainbowSpheres; i++)
|
for (int i = 0; i < rainbowSpheres; i++)
|
||||||
{
|
{
|
||||||
x = 2.0*CGLM_PI * (float)i/(float)rainbowSpheres;
|
x = 2.0*CGLM_PI * (float)i/(float)rainbowSpheres;
|
||||||
sc[0] = sin(x)*d;
|
sc[0] = sin(x)*d;
|
||||||
sc[1] = sin(x*3.0-5.0*sin(t));
|
sc[1] = radius*sin(x*3.0-5.0*sin(t));
|
||||||
sc[2] = cos(x)*d;
|
sc[2] = cos(x)*d;
|
||||||
|
|
||||||
float ic = i/(float)rainbowSpheres*CGLM_PI*2.0;
|
float ic = i/(float)rainbowSpheres*CGLM_PI*2.0;
|
||||||
|
|
Loading…
Reference in New Issue