1
$\begingroup$

I am trying to generate soft shadows using voxel cone tracing.

Which gives me the next images:

enter image description here

enter image description here

In the first image you can see an artifact of a sequence of horizontal shadows alternating with illuminated areas, which looks quite odd.

On the second image you can see that the left side is shadowed and the right isn't, although both sides are equidistant to the light, so they should be equally illuminated. In addition to that, in the second image you can see that in the columns, the shadows are jaggy and the outline is clear (no soft shadows).

I am trying to solve these 3 problems.

The way I am currently generating my shadows from my 3D texture is:

void main()
{
    fragment_color = blinn_phong();

    float v_size = cube_dim/voxel_resolution;
    vec3 r = f_pos + f_norm*v_size*2;
    vec3 dir = normalize(light-r);
    vec3 start = r;
    float l=0;
    float acc=0;
    vec4 val;
    while(incube(r, cube_dim) && (l<=length(start-light)) && acc<1)
    {
        l=length(start-r);
        r += dir*v_size*0.5;
        val = textureLod(normal_map, (r-vec3(0.5))*0.5/cube_dim+vec3(0.5), l*0.0001);
        acc += val.w;
    }
    fragment_color *= (1-acc);
}
$\endgroup$
  • $\begingroup$ Does that 1d banding only affect the edges of your voxel map? it looks suspiciously like texture clamping. $\endgroup$ – PaulHK Jul 27 '18 at 9:30
  • $\begingroup$ @PaulHK that's the only place where I have seen it, but it shouldn't cause texture clamping because the light is inside the voxel map, so the light only needs to travel inside the voxel map. $\endgroup$ – Makogan Jul 27 '18 at 17:56
  • 1
    $\begingroup$ In voxel raymarching there can be a number of issues. Your step size is too big and some rays miss voxels. Your offset is small so the self shadowing occurs when ray at starting point immediately hits voxel. Whole ray length from start to end is too short. Quality can depend on number of samples, quality of samples and voxel size. $\endgroup$ – narthex Jul 27 '18 at 20:04

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.