add multiple samples per pixel

This commit is contained in:
ktyl 2023-02-24 01:15:25 +00:00
parent 7367a2abaf
commit 48e78fedda
1 changed files with 15 additions and 6 deletions

View File

@ -78,16 +78,25 @@ void main()
int bounces = (1-sky) * BOUNCES;
pixel.xyz = mix(pixel.xyz, _skyColor, sky);
// trace the ray's path around the scene
for (int j = 0; j < bounces; j++)
// sample
int samples = 2;
for (int i = 0; i < samples; i++)
{
RayHit hit = trace(ray);
float sampleDepth = 0;
depth = getLogarithmicDepth(ray.distance);
// trace the ray's path around the scene
for (int j = 0; j < bounces; j++)
{
RayHit hit = trace(ray);
pixel.xyz += ray.energy * shade(ray, hit);
depth = getLogarithmicDepth(ray.distance);
if (length(ray.energy) < 0.001) break;
pixel.xyz += ray.energy * shade(ray, hit);
if (length(ray.energy) < 0.001) break;
}
depth += sampleDepth / float(samples);
}
pixel.xyz = mix(pixel.xyz, vec3(1.0), depth);