# Circular pattern aliasing in voxel ray tracer

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)));
}

• Could you take a still image from your video and add it to the question? You're always more likely to get answers if people can see the problem without having to click through to external links. – Dan Hulme Jul 18 '18 at 8:22
• This looks a bit like the typical self-intersection issues you sometimes get with ray tracers, were the intersection point of a ray is sometimes slightly inside the object you are testing (rounding error), so resuming from that point can result in a instant hit on the same object. I'm guessing those rings are shadows ? – PaulHK Jul 18 '18 at 9:29
• @PaulHK I am not sure that is the case. I am adding an offset to the rays at the start, to ensure that they begin outside of the object. – Makogan Jul 18 '18 at 20:08
• show your code, and take a still of the pattern – opa Jul 19 '18 at 14:18
• If you change your shadow colour to say red, does the ringed artefacts also turn red ? Just watched your video again and it seems the artefact gets stronger the further away from the centre of the mesh the camera goes. What is the dimensions of your scene ? – PaulHK Jul 20 '18 at 2:38