I'm making a GLSL Ray-tracer with LWJGL, following Ray Tracing in One Weekend. And when I render with 100000 samples per pixel, I get the following image: some spheres
Whenever I render with about 2-3000 samples or more, some line-look-alike noise appears, as seen in the picture and it gets more and more pronounced with more samples. I suspect that the reason for this may be my random()
function for generating rays may not be fully uniform. I use this:
float random(vec2 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
and I use it that way: random(pixel_coords + random_seed)
, where ivec2 pixel_coords = ivec2(gl_GlobalInvocationID.xy);
, and random_seed
is a float uniform, set with rand.nextFloat()
for every call of the shader (so it is unique for every sample, but the same for all pixels in one sample image).
Can this not be a problem with the random number generation, but something else? Are there any more-perfect ways to generate randomness?