def main(): # Register MeasuredBTF register_bsdf('measuredbtf', lambda props: MeasuredBTF(props)) # Filename filename_src = args.input filename_dst = args.output # Load an XML file Thread.thread().file_resolver().append(os.path.dirname(filename_src)) scene = load_file(filename_src) # Rendering scene.integrator().render(scene, scene.sensors()[0]) # Save image film = scene.sensors()[0].film() bmp = film.bitmap(raw=True) bmp.convert(Bitmap.PixelFormat.RGB, Struct.Type.UInt8, srgb_gamma=True).write(filename_dst)
value = self.m_retro_transmittance.eval(si, active) return (bs, ek.select(active, value, 0)) def eval(self, ctx, si, wo, active): return 0 def pdf(self, ctx, si, wo, active): return 0 def to_string(self): return "MMAPsBSDF[retro_transmittance = %s]".format( self.m_retro_transmittance.to_string()) register_bsdf("mmapsbsdf", lambda props: MMAPsBSDF(props)) xmlname = sys.argv[1] outpath = os.path.join('outputs', sys.argv[2]) os.makedirs(outpath, exist_ok=True) filename = 'xml/{}.xml'.format(xmlname) Thread.thread().file_resolver().append(os.path.dirname(filename)) angle_min, angle_max = -15, 15 dangle = 1 / 3 current_angle = angle_min cam2origin = 100 while current_angle <= angle_max: cam_x = sin(radians(current_angle)) * cam2origin
def pdf(self, ctx, si, wo, active): if not ctx.is_enabled(BSDFFlags.DiffuseReflection): return Vector3f(0) cos_theta_i = Frame3f.cos_theta(si.wi) cos_theta_o = Frame3f.cos_theta(wo) pdf = warp.square_to_cosine_hemisphere_pdf(wo) return ek.select((cos_theta_i > 0.0) & (cos_theta_o > 0.0), pdf, 0.0) def to_string(self): return "MyDiffuseBSDF[reflectance = %s]".format( self.m_reflectance.to_string()) # Register our BSDF such that the XML file loader can instantiate it when loading a scene register_bsdf("mydiffusebsdf", lambda props: MyDiffuseBSDF(props)) # Load an XML file which specifies "mydiffusebsdf" as material filename = 'path/to/my/scene.xml' Thread.thread().file_resolver().append(os.path.dirname(filename)) scene = load_file(filename) scene.integrator().render(scene, scene.sensors()[0]) film = scene.sensors()[0].film() film.set_destination_file('my-diffuse-bsdf.exr') film.develop()