-
Hi, I want to use custom defined Integrator here to render depth, normal, albedo. But the aov_integrator failed as the Integrator def render_aov(self, scene: mi.Scene,sensor: mi.Sensor,seed=0,spp=0):
from matplotlib import pyplot as plt
import numpy as np
with dr.suspend_grad():
sampler, spp = self.prepare(sensor=sensor,seed=seed, spp=spp, aovs=self.aovs())
ray, weight, pos, _ = self.sample_rays(scene, sensor, sampler)
# compute the intersection
si = scene.ray_intersect(ray)
active = si.is_valid()
si = dr.select(si.is_valid(), si, dr.zeros(mi.SurfaceInteraction3f))
bsdf = si.bsdf()
roughness = bsdf.eval_roughness(si, active)
albedo = bsdf.eval_diffuse_reflectance(si,active)
# Create a film block to store albedo with RGB channels
block = sensor.film().create_block()
block.set_coalesce(block.coalesce() and spp >= 4)
# create a film block to store roughness metallic ect. with one channel
block_size = sensor.film().size()
block_offset = mi.ScalarPoint2i(0, 0)
block_1 = mi.ImageBlock(size=block_size, offset=block_offset, channel_count=2)
block_1.set_coalesce(block.coalesce() and spp >= 4)
# Store the albedo and roughness in the film block
albedo_alpha = dr.select(active, mi.Float(1), mi.Float(0))
roughness_alpha = dr.select(active, mi.Float(1), mi.Float(0))
block.put(pos, ray.wavelengths, albedo, albedo_alpha)
block_1.put(pos, ray.wavelengths, roughness, roughness_alpha)
# Develop the film to get the final images
sensor.film().put_block(block)
sensor.film().put_block(block_1)
albedo_image = sensor.film().develop()
roughness_image = sensor.film().develop()
return {
'albedo': albedo_bitmap,
'roughness': roughness_bitmap
}
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
By the way, the reason why I customly render aovs in python is when I use the mitsuba offitial here aov_integrator interface plugin
The integrator.render() function here raised a error:
It looks like the mitsuba offitial aov_integrator interface has not match the custom integrator by this work's integrator. |
Beta Was this translation helpful? Give feedback.
-
Hi @Start1er The SDF integrator that you've been linking to (this one), was written for an older version of Mitsuba. Since the time that this was implemented, the interfaces have changed a bit, hence the error messages you've been seeing. The lastest release, does support |
Beta Was this translation helpful? Give feedback.
Hi @Start1er
The SDF integrator that you've been linking to (this one), was written for an older version of Mitsuba. Since the time that this was implemented, the interfaces have changed a bit, hence the error messages you've been seeing.
The lastest release, does support
aovs
in custom Python integrators natively throughmi.render()
. So you don't need to re-implement arender_aov
, but you should rather change your custom integrator to use the new interfaces. Have a look at the integrators in this folder if you need examples of the new interfaces.