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,6 +78,12 @@ void main()
int bounces = (1-sky) * BOUNCES;
pixel.xyz = mix(pixel.xyz, _skyColor, sky);
// sample
int samples = 2;
for (int i = 0; i < samples; i++)
{
float sampleDepth = 0;
// trace the ray's path around the scene
for (int j = 0; j < bounces; j++)
{
@ -90,6 +96,9 @@ void main()
if (length(ray.energy) < 0.001) break;
}
depth += sampleDepth / float(samples);
}
pixel.xyz = mix(pixel.xyz, vec3(1.0), depth);
// output to a specific pixel in the image