uci-rendering / psdr-cuda

Path-space differentiable renderer
BSD 3-Clause "New" or "Revised" License
155 stars 11 forks source link

C++ example code #6

Closed neon5d closed 2 years ago

neon5d commented 2 years ago

Hello,

I tried to create a C++ example code to duplicate the python example. I am stuck at accessing SpectrumC data as in the below code. How to access SpectrumC data to read out image pixels? and also do you have any C++ example code? Thank you,

void main() { psdr::Scene scene;

scene.load_file("data/scenes/cbox_bunny.xml", false);
scene.configure();

psdr::DirectIntegrator integrator(2, 2);

int sensor_id = 0;
psdr::SpectrumC image = integrator.renderC(scene, sensor_id);

// save image to a file }

andyyankai commented 2 years ago

you will need to include <psdr/fwd.h> with psdr namespace You can also simple cout << SpectrumC, it is either type enoki::FloatC or enoki::Vector3fC depend on channel

neon5d commented 2 years ago

Thank you for your reply. It seems not what I want to know. SpectrumC is a GPU dynamic array. I don't know how to accumulate it. It is very hard to program without an example or documentation.

void main() { psdr::Scene scene;

scene.load_file("data/scenes/cbox_bunny.xml", false); scene.configure();

psdr::DirectIntegrator integrator(2, 2);

int sensor_id = 0; psdr::SpectrumC image = integrator.renderC(scene, sensor_id);

// This doesn't work for (int i=0; I< 20; i++) { image += integrator.renderC(scene, sensor_id); }

}

andyyankai commented 2 years ago

for this part, you can check enoki c++ interface: https://enoki.readthedocs.io/en/master/gpu.html#c-interface You also want to check how to use scatter_add/scatter function in enoki for such accumulate method.

neon5d commented 2 years ago

Thank you. I'll try it.