Skip to content

Best Practice for implementing 1D Gonioreflectometer data in a custom BSDF #1689

@Daavid739

Description

@Daavid739

Hello,

I would like to ask for the best practice on how to implement measured BRDF data from a gonioreflectometer in a custom Python BSDF plugin.

Context & Data:
My data was measured with a gonioreflectometer at a fixed outgoing/camera angle (θo). The incoming light angle (θi) was varied from 0 to 89 degrees.

This gives me two 1D NumPy arrays:

thetas_i_deg.npy: An array of shape (90,) with the incoming angles [0.0, 1.0, ..., 89.0].
brdf_data_1D.npy: An array of shape (90,) with the corresponding measured BRDF value for each incoming angle.

My Approach & Problem:
My approach is to create a custom BSDF class. In the init method, I load both .npy arrays. For importance sampling, I pre-calculate a PDF and an inverse CDF table. The eval method then takes the incoming direction si.wi, calculates the angle theta_i, rounds it to the nearest integer to get an index, and uses dr.gather to look up the corresponding value from the brdf_data_1D array.

However, when I try to render a scene with this plugin using the llvm_ad_rgb variant, the kernel crashes with a DeadKernelError. A minimal version of the same plugin with a simple eval method (returning a constant color) works perfectly.

My Question:
Is this approach of using two parallel 1D arrays and looking up the value with dr.gather based on the nearest angle the correct "best practice" for this kind of data? Or is there a more robust, recommended way to structure the data or implement the lookup that would avoid this instability with the differentiable renderer?

Thank you for your guidance. I can provide a minimal reproducible example (MRE) that demonstrates the crash if needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions