def render_scene(self, scene, ozy_scene): def render_callback(state,message,context): if(state == ozy.OZY_PROGRESS_RENDER_BEGIN): pass if(state == ozy.OZY_PROGRESS_BUCKET_DONE): num_buckets = context.ozy_result.get_num_buckets_x()*context.ozy_result.get_num_buckets_y() progress = context.ozy_result.get_num_completed_buckets()/num_buckets self.update_progress(progress) if(progress < 1.0): pass context.ozy_result.save_to_file("/tmp/ozy_out","exr",ozy.OZY_COLORSPACE_LINEAR) context.blender_result.load_from_file("/tmp/ozy_out.exr") self.update_result(context.blender_result) if(state == ozy.OZY_PROGRESS_RENDER_DONE): context.ozy_result.save_to_file("/tmp/ozy_out","exr",ozy.OZY_COLORSPACE_LINEAR) context.blender_result.load_from_file("/tmp/ozy_out.exr") self.end_result(context.blender_result) shot = ozy.Shot() shot.width = self.size_x shot.height = self.size_y shot.bucket_resolution = 3 shot.subsamples_per_thread = scene.ozymandias.subsamples shot.enable_pass(ozy.PASS_FINAL) shot.enable_pass(ozy.PASS_NORMAL) if(scene.ozymandias.direct_light_sampling == 'BOTH'): shot.direct_light_sampling = ozy.OZY_DIRECT_LIGHT_SAMPLING_BOTH elif(scene.ozymandias.direct_light_sampling == 'BRDF'): shot.direct_light_sampling = ozy.OZY_DIRECT_LIGHT_SAMPLING_BRDF elif(scene.ozymandias.direct_light_sampling == 'LIGHT'): shot.direct_light_sampling = ozy.OZY_DIRECT_LIGHT_SAMPLING_LIGHT #TODO(Vidar):enable/disable passes based on the blender UI #shot.enable_pass(ozy.PASS_COLOR) shot.enable_pass(ozy.PASS_DEPTH) workers = ozy.Workers(8) ozy_result = ozy.Result() blender_result = self.begin_result(0, 0, self.size_x, self.size_y,"") ozy.render(ozy_result,shot,ozy_scene,workers,render_callback, OzyContext('/tmp/ozy',blender_result,ozy_result)) ozy_result.destroy() workers.destroy()
def render_preview(self, scene, ozy_scene): def render_callback(state,message,context): if(state == ozy.OZY_PROGRESS_RENDER_DONE): rect = context.ozy_result.get_pass(ozy.PASS_FINAL) layer = context.blender_result.layers[0] layer.passes[0].rect = rect self.end_result(context.blender_result) shot = ozy.Shot() shot.width = self.size_x shot.height = self.size_y shot.bucket_resolution = 2 shot.subsamples_per_thread = 4 shot.enable_pass(ozy.PASS_FINAL) workers = ozy.Workers(8) ozy_result = ozy.Result() blender_result = self.begin_result(0, 0, self.size_x, self.size_y,"") ozy.render(ozy_result,shot,ozy_scene,workers,render_callback, OzyContext('/tmp/ozy',blender_result,ozy_result)) ozy_result.destroy() workers.destroy()
scene.obj_set_verts(obj,[-1.0,-1.0,20.0, 1.0,-1.0,20.0, 1.0, 1.0,20.0]) scene.obj_set_normals(obj,[0.0,0.0,-1.0]) scene.obj_set_tris(obj,[0,1,2]) scene.obj_set_tri_normals(obj,[0,0,0]) scene.obj_set_tri_materials(obj,[material]) scene.obj_set_transform(obj,[1.0,0.0,0.0,0.0, 0.0,1.0,0.0,0.0, 0.0,0.0,1.0,0.0, 0.0,0.0,0.0,1.0]) scene.set_camera([1.0,0.0,0.0,0.0, 0.0,1.0,0.0,0.0, 0.0,0.0,1.0,0.0, 0.0,0.0,0.0,1.0], 0.9) info = ozy.ShaderInfo('test') if info.is_valid(): print('valid shader') print('num parameters:', info.num_params()) param = info.get_param(0) print(param.get_basetype()) else: print('invalid shader') ozy.render(result, shot, scene, workers, func1, Context(result,'/tmp/ozy')) result.destroy() scene.destroy() workers.destroy()