I am doing a voxel based raytracer.
In other words, I first voxelize the scene using rasterization and I proceed to raytrace the volume in a 3D image to generate a final frame.
Currently I noticed a circular pattern aliasing and I am not sure what could be causing it.
This video shows the aliasing (sorry for the awkward camera movement my controls are not good right now). The magenta cube is the light's position.
https://www.youtube.com/watch?v=rtFDTQoKX_A&feature=youtu.be
Here's a still from the video:
EDIT: This is the main function of the fragment shader. I can post more if it;s needed, btu won;t for now because the fragment is quite big and I think most of the function names are slef explanatory:
void main()
{
float v_size = cube_dim/voxel_resolution;
vec3 r = -(vec3(f_coord.xy,1.f/tan(radians(40))));
r.y*=-1;
r.y /= aspect_ratio;
vec3 dir = vec3(view_m*vec4(normalize(r),0));
dir = normalize(dir);
r = camera_pos;
r.z*=-1;
float t = boxIntersection(r, dir, -vec3(cube_dim), cube_dim*2);
if(isinf(t))
discard;
if(!((r.x>=-cube_dim) && (r.x<=cube_dim) && (r.y>=-cube_dim) &&
(r.y<=cube_dim) && (r.z>=-cube_dim) && (r.z<=cube_dim)))
r += dir*t;
vec4 color = vec4(0);
while(incube(r, cube_dim))
{
r += dir*v_size*0.5;
vec4 val = imageLoad(normal_map, ivec3(((r)*0.5/cube_dim+vec3(0.5))*(voxel_resolution-1)));
if(val.w > 0)
{
break;
}
}
vec4 normal = imageLoad(normal_map, ivec3(((r)*0.5/cube_dim+vec3(0.5))*(voxel_resolution-1)));
color = imageLoad(diffuse_map, ivec3(((r)*0.5/cube_dim+vec3(0.5))*(voxel_resolution-1)));
fragment_color = blinn_phong(r, vec3(normal), color)*(10.f/log(length(r-light)));
}