mitsuba-renderer / mitsuba3

Mitsuba 3: A Retargetable Forward and Inverse Renderer
https://www.mitsuba-renderer.org/
Other
2.09k stars 246 forks source link

The CUDA variant produces artifacts when rendering curves with hair BSDF #1324

Open mandyxmq opened 1 month ago

mandyxmq commented 1 month ago

Summary

I wonder if the team might already be aware of this issue: when rendering the curve shape and hair BSDF, the CUDA variant seems to produce artifacts that are not present in either the LLVM or the scalar variants.

System configuration

System information:

OS: Ubuntu 22.04 GPU: RTX 4090 CUDA version: 12.2 NVidia driver: 535.183.01

I tested on both the stable version of Mitsuba and using the newest commit from the master branch, and I got the same behavior.

Description

The following images are rendered using the scalar_rgb, llvm_ad_rgb, and cuda_ad_rgb variants respectively. The artifacts are also there when evaluating the first reflection lobe of the hair BSDF. The problem seems to come from curve intersection on GPU.

curve_scalar curve_llvm curve_cuda

Steps to reproduce

The following is the scene description to reproduce the results above, and I've attached the curve geometry file.

<scene version="2.1.0">

    <default name="spp" value="16"/>
    <default name="resx" value="512"/>
    <default name="resy" value="512"/>

<!-- Camera and Rendering Parameters -->

    <integrator type="direct"/>
    <sensor type="perspective">
        <string name="fov_axis" value="x"/>
        <float name="fov" value="10"/>
        <transform name="to_world">
            <lookat origin="0, 1, 0" target="0, 0, 0" up="0, 0, 1"/>
        </transform>
        <sampler type="independent" name="sampler">
            <integer name="sample_count" value="$spp"/>
        </sampler>
        <film type="hdrfilm" name="film">
            <integer name="width" value="$resx"/>
            <integer name="height" value="$resy"/>
        </film>
    </sensor>

<!-- Materials -->

    <bsdf type="hair"  id="hair">
        <rgb name="sigma_a" value="0.0, 0.1, 0.8"/>
        <float name="azimuthal_roughness" value="0.8"/>
        <float name="longitudinal_roughness" value="0.3"/>
        <float name="int_ior" value="1.55"/>
        <float name="ext_ior" value="1.0"/>
        <float name="scale_tilt" value="0.0"/>
    </bsdf> 

<!-- Emitters -->
    <emitter type="point">
        <rgb name="intensity" value="100"/>
        <point name="position" x="0" y="2" z="2"/>
    </emitter>

<!-- Shapes -->
    <shape type="bsplinecurve">
        <ref id="hair" name="bsdf"/>
        <string name="filename" value="curves.txt"/>
    </shape>

</scene>

curves.txt

njroussel commented 1 month ago

Hi @mandyxmq

Thank you for the very simple reproducer.

I am able to reproduce the results you're seeing. I also noticed that when Mitsuba is compiled in DEBUG mode, the error is visibly gone. I'm honestly stumped as to what could be the problem here. We'll need to dig into this more. But for now, if you need it to work correctly on the GPU, DEBUG mode should do the trick (of course, it will be quite a bit slower though).