<p>TL;DR -- who has discovered, in the past, a backward-only path tracer that generates caustics not needing extra convergence of any kind? I'm collecting similar algorithms, in order to fully understand physically accurate path tracing.</p>
<p>Edit: Seems like James Kajiya is likely the person who discovered this algorithm first.</p>
<p>The post:</p>
<p>I am working on a Vulkan path tracer. The result is not physically correct, in the sense that it doesn't define a BDRF or PDF, etc. However, it does support caustics. Basically, I bounce the sampler ray around the scene, and if it hits a (semi-)transparent object, it gets redirected via refraction rather than a random reflection. So basically, it doesn't require a heavy load of computation in order for the algorithm to do its thing -- making beautiful caustics.</p>
<p><a href="https://i.sstatic.net/HDyTB.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/HDyTB.jpg" alt="enter image description here" /></a></p>
<p><a href="https://i.sstatic.net/9ySk8.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/9ySk8.jpg" alt="enter image description here" /></a></p>
<p><a href="https://i.sstatic.net/KLJiF.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/KLJiF.png" alt="enter image description here" /></a></p>
<p><a href="https://i.sstatic.net/27LYU.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/27LYU.jpg" alt="enter image description here" /></a></p>
<p><a href="https://i.sstatic.net/ZEcn4.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ZEcn4.jpg" alt="enter image description here" /></a></p>
<p>Here the caustics form a rainbow-like pattern because of chromatic aberration. Fog has been implemented in the 5th figure.</p>
<p>The full source is at: <a href="https://github.com/sjhalayka/cornell_box_textured" rel="nofollow noreferrer">https://github.com/sjhalayka/cornell_box_textured</a></p>
<p>In particular, the raygen shader is at: <a href="https://github.com/sjhalayka/cornell_box_textured/blob/main/raygen.rgen" rel="nofollow noreferrer">https://github.com/sjhalayka/cornell_box_textured/blob/main/raygen.rgen</a></p>
<p>The source code is based off of Sascha Willems' raytracingreflections code. The model (scene) was generated by Rob Rau.</p>
<p>So, please, understand that I'm fairly new at path tracing. Can you please point me toward some well-known backward-only caustics algorithms?</p>
<p>Thanks for your time and expertise.</p>
<p>The relevant code is:</p>
<pre><code>vec3 hitPos = o + d * rayPayload.distance;

// If partially transparent
if(rayPayload.opacity != 1.0)
{
    // Incoming ray
    if(dot(d, rayPayload.normal) &lt;= 0.0)
    {
        o = hitPos.xyz - rayPayload.normal * 0.01;
        d = refract(d, rayPayload.normal, eta);
    }
    else // Outgoing ray
    {
        vec3 temp_dir = refract(d, -rayPayload.normal, 1.0/eta);

        if(temp_dir != vec3(0.0))
        {
            o = hitPos.xyz + rayPayload.normal * 0.01;
            d = temp_dir;
        }
        else
        {
            // Total internal reflection
            o = hitPos.xyz - rayPayload.normal * 0.01;
            d = reflect(d, -rayPayload.normal);
        }
    }
}
else // Fully opaque
{
    o = hitPos + rayPayload.normal*0.01;
    vec3 d_cos = cos_weighted(rayPayload.normal, prng_state);
    d = mix(d_cos, reflect(d, rayPayload.normal), rayPayload.reflector);
}


</code></pre>

CC BY-SA 4.0
2023-09-01T14:25:31.150Z
Hi Yves. Let me make it more apparent.
shawn_halayka
<glsl><c++><vulkan>
Vulkan backward-only path tracer with caustics
shawn_halayka
# Vulkan backward-only path tracer with caustics

(Asked by: username_0 on 2023-09-01)

TL;DR -- who has discovered, in the past, a backward-only path tracer that generates caustics not needing extra convergence of any kind? I'm collecting similar algorithms, in order to fully understand physically accurate path tracing.
Edit: Seems like James Kajiya is likely the person who discovered this algorithm first.
The post:
I am working on a Vulkan path tracer. The result is not physically correct, in the sense that it doesn't define a BDRF or PDF, etc. However, it does support caustics. Basically, I bounce the sampler ray around the scene, and if it hits a (semi-)transparent object, it gets redirected via refraction rather than a random reflection. So basically, it doesn't require a heavy load of computation in order for the algorithm to do its thing -- making beautiful caustics.





Here the caustics form a rainbow-like pattern because of chromatic aberration. Fog has been implemented in the 5th figure.
The full source is at: https://github.com/sjhalayka/cornell_box_textured
In particular, the raygen shader is at: https://github.com/sjhalayka/cornell_box_textured/blob/main/raygen.rgen
The source code is based off of Sascha Willems' raytracingreflections code. The model (scene) was generated by Rob Rau.
So, please, understand that I'm fairly new at path tracing. Can you please point me toward some well-known backward-only caustics algorithms?
Thanks for your time and expertise.
The relevant code is:
vec3 hitPos = o + d * rayPayload.distance;

// If partially transparent
if(rayPayload.opacity != 1.0)
{
    // Incoming ray
    if(dot(d, rayPayload.normal) <= 0.0)
    {
        o = hitPos.xyz - rayPayload.normal * 0.01;
        d = refract(d, rayPayload.normal, eta);
    }
    else // Outgoing ray
    {
        vec3 temp_dir = refract(d, -rayPayload.normal, 1.0/eta);

        if(temp_dir != vec3(0.0))
        {
            o = hitPos.xyz + rayPayload.normal * 0.01;
            d = temp_dir;
        }
        else
        {
            // Total internal reflection
            o = hitPos.xyz - rayPayload.normal * 0.01;
            d = reflect(d, -rayPayload.normal);
        }
    }
}
else // Fully opaque
{
    o = hitPos + rayPayload.normal*0.01;
    vec3 d_cos = cos_weighted(rayPayload.normal, prng_state);
    d = mix(d_cos, reflect(d, rayPayload.normal), rayPayload.reflector);
}

**Tags:** glsl, c++, vulkan
> **Comments:**
> **username_0**: Hi Yves. Let me make it more apparent.  

---

## 0 answers

