<p>I am trying to generate soft shadows using voxel cone tracing.</p>

<p>Which gives me the next images:</p>

<p><a href="https://i.sstatic.net/qoXFk.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/qoXFk.jpg" alt="enter image description here"></a></p>

<p><a href="https://i.sstatic.net/pAykT.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/pAykT.jpg" alt="enter image description here"></a></p>

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

<p>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).</p>

<p>I am trying to solve these 3 problems.</p>

<p>The way I am currently generating my shadows from my 3D texture is:</p>

<pre><code>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) &amp;&amp; (l&lt;=length(start-light)) &amp;&amp; acc&lt;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);
}
</code></pre>

CC BY-SA 4.0
2018-07-27T09:30:36.830Z
Does that 1d banding only affect the edges of your voxel map? it looks suspiciously like texture clamping.
PaulHK
CC BY-SA 4.0
2018-07-27T17:56:39.087Z
@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.
Makogan
CC BY-SA 4.0
2018-07-27T20:04:46.460Z
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.
mdkdy
<opengl><rendering><shadow><global-illumination><voxelization>
Voxel cone tracing artifacts (what causes them and how to solve them)?
Makogan
# Voxel cone tracing artifacts (what causes them and how to solve them)?

(Asked by: username_0 on 2018-07-27)

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

Which gives me the next images:

[![enter image description here](https://i.sstatic.net/qoXFk.jpg)](https://i.sstatic.net/qoXFk.jpg)

[![enter image description here](https://i.sstatic.net/pAykT.jpg)](https://i.sstatic.net/pAykT.jpg)

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

```

**Tags:** opengl, rendering, shadow, global-illumination, voxelization

> **Comments:**
> **username_1**: Does that 1d banding only affect the edges of your voxel map? it looks suspiciously like texture clamping.  
> **username_0**: @username_1 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.  
> **username_2**: 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.  

---

## 0 answers

