Compare commits
7 Commits
Author | SHA1 | Date |
---|---|---|
ktyl | ce6376df81 | |
ktyl | 16c3e46930 | |
Cat Flynn | 82fe146549 | |
Cat Flynn | 6ca53a5329 | |
Cat Flynn | 892bec867c | |
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 E = 2.71828;
|
||||
const int BOUNCES = 5;
|
||||
|
|
|
@ -7,7 +7,7 @@ float getLogarithmicDepth(float distance)
|
|||
{
|
||||
// n roughly correlates to steepness of log curve
|
||||
// TODO: what does this mean in mathematical terms??
|
||||
float n = 4;
|
||||
float n = 2;
|
||||
float f = INF;
|
||||
float z = distance;
|
||||
|
||||
|
|
|
@ -11,6 +11,34 @@ RayHit trace(inout Ray ray)
|
|||
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);
|
||||
|
||||
return hit;
|
||||
|
|
|
@ -49,9 +49,9 @@ vec4 denoise(sampler2D tex, vec2 uv, float sigma, float kSigma, float threshold)
|
|||
|
||||
void main()
|
||||
{
|
||||
float sigma = 2.2;
|
||||
float kSigma = 10.0;
|
||||
float threshold = 0.2;
|
||||
float sigma = 2.5;
|
||||
float kSigma = 7.0;
|
||||
float threshold = 0.3;
|
||||
|
||||
FragColor = denoise(ourTexture, TexCoord, sigma, kSigma, threshold);
|
||||
//FragColor = texture(ourTexture, TexCoord);
|
||||
|
|
|
@ -99,6 +99,13 @@ void main()
|
|||
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);
|
||||
|
||||
// output to a specific pixel in the image
|
||||
|
|
|
@ -135,7 +135,7 @@ void updateUniforms(GLuint shaderProgram, float t)
|
|||
updateCameraUniforms(shaderProgram, aspect, t);
|
||||
|
||||
// make and update spheres
|
||||
const int sphereCount = 41;
|
||||
const int sphereCount = 25;
|
||||
struct Sphere spheres[sphereCount];
|
||||
makeSpheres(spheres, sphereCount, t);
|
||||
updateSphereUniforms(shaderProgram, spheres, sphereCount);
|
||||
|
|
15
src/sphere.c
15
src/sphere.c
|
@ -2,17 +2,6 @@
|
|||
|
||||
void makeSpheres(struct Sphere *spheres, int count, float t)
|
||||
{
|
||||
vec3 albedos[] =
|
||||
{
|
||||
{0.0,0.0,1.0},
|
||||
{0.0,1.0,0.0},
|
||||
{0.0,1.0,1.0},
|
||||
{1.0,0.0,0.0},
|
||||
{1.0,0.0,1.0},
|
||||
{1.0,1.0,0.0},
|
||||
{1.0,1.0,1.0}
|
||||
};
|
||||
|
||||
vec3 sc = {0.0,0.0,1.0};
|
||||
|
||||
int sphereIdx = 0;
|
||||
|
@ -30,13 +19,13 @@ void makeSpheres(struct Sphere *spheres, int count, float t)
|
|||
int rainbowSpheres = count - middleSpheres;
|
||||
// distance from center
|
||||
float d = 6.0;
|
||||
radius = 0.5;
|
||||
radius = 0.7;
|
||||
float x;
|
||||
for (int i = 0; i < rainbowSpheres; i++)
|
||||
{
|
||||
x = 2.0*CGLM_PI * (float)i/(float)rainbowSpheres;
|
||||
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;
|
||||
|
||||
float ic = i/(float)rainbowSpheres*CGLM_PI*2.0;
|
||||
|
|
Loading…
Reference in New Issue