def get_runtime(): runtime = Runtime() sampler.get_sample_asm(runtime, "get_sample") camera.ray_asm(runtime, "generate_ray") dyn_arrays = ren.dyn_arrays() renmas.shapes.linear_isect_asm(runtime, "scene_isect", dyn_arrays) return runtime
def test_linear(): runtime, ds = isect_ray_sphere_array() random_spheres(1000) shapes = ren.lst_shapes() ray = ren.random_ray() ray_ds(ds, ray, "r1") dyn_arrays = ren.dyn_arrays() ds["nspheres"] = dyn_arrays[renmas.shapes.Sphere].size ds["ptr_spheres"] = dyn_arrays[renmas.shapes.Sphere].get_addr() runtime.run("isect") hp = renmas.shapes.isect(ray, shapes, 999999.0) if hp is not None: print(hp.t, ds["hp.t"])
def build_runtime(): runtime = Runtime() sam = renmas.samplers.RandomSampler(800, 800, n=200000, pixel=0.8) sam.get_sample_asm(runtime, "get_sample") ren.get_camera().ray_asm(runtime, "generate_ray") renmas.shapes.linear_isect_asm(runtime, "scene_isect", ren.dyn_arrays()) renmas.shapes.visible_asm(runtime, "visible", "scene_isect") renmas.core.generate_shade(runtime, "shade", "visible") ren.get_film().add_sample_asm(runtime, "add_sample") asm = renmas.utils.get_asm() mc = asm.assemble(ASM) ds = runtime.load("path_tracer", mc) return (sam, runtime)
ray = ren.random_ray() ds["ray1.origin"] = v4(ray.origin) ds["ray1.dir"] = v4(ray.dir) ds["num"] = len(lst_shapes) ds["addrs"] = adrese runtime.run("test") print(ds["hp.t"], ds["clocks"]) hp = isect(ray, lst_shapes) print(hp.t) runtime2 = Runtime() renmas.shapes.linear_isect_asm(runtime2, "ray_scene", ren.dyn_arrays()) ASM2 = """ #DATA """ ASM2 += asm_structs + """ ray ray1 hitpoint hp uint32 hit = 0 uint32 clocks uint32 count = 100 #CODE
def visible(runtime): dyn_arrays = ren.dyn_arrays() renmas.shapes.linear_isect_asm(runtime, "scene_isect", dyn_arrays) renmas.shapes.visible_asm(runtime, "visible", "scene_isect")
uint32 vis #CODE movaps xmm0, oword [p1] movaps xmm1, oword [p2] call visible movaps oword [origin], xmm0 movaps oword [direction], xmm1 mov dword [vis], eax #END """ gen_random_shapes(10) #gen_sphere() shapes = ren.lst_shapes() dyn_arrays = ren.dyn_arrays() runtime = Runtime() renmas.shapes.linear_isect_asm(runtime, "scene_isect", dyn_arrays) renmas.shapes.visible_asm(runtime, "visible", "scene_isect") asm = renmas.utils.get_asm() mc = asm.assemble(ASM) ds = runtime.load("visible", mc) runtime.run("visible") p1 = renmas.maths.Vector3(2.2, 1.3, 1.1) p2 = renmas.maths.Vector3(0.2, 3.8, 4.1) #p1 = renmas.maths.Vector3(10.0, 5.0, 8.0)
hitpoint hp uint32 hit #CODE ; eax = pointer_to_ray, ebx = pointer_to_hitpoint mov eax, r1 mov ebx, hp call scene_isect mov dword [hit], eax #END """ gen_random_shapes(10) shapes = ren.lst_shapes() dyn_arrays = ren.dyn_arrays() runtime = Runtime() renmas.shapes.linear_isect_asm(runtime, "scene_isect", dyn_arrays) asm = renmas.utils.get_asm() mc = asm.assemble(ASM) ds = runtime.load("isect", mc) ray = ren.random_ray() ray_ds(ds, ray, "r1") runtime.run("isect") hp = renmas.shapes.isect(ray, shapes, 999999.0) if hp is not None:
call add_sample jmp _next_sample _end_sampling: mov dword [end_sam], 0 #END """ ren.prepare_for_rendering() runtime = Runtime() ren.get_sampler().get_sample_asm(runtime, "get_sample") ren.get_camera().ray_asm(runtime, "generate_ray") renmas.shapes.linear_isect_asm(runtime, "scene_isect", ren.dyn_arrays()) renmas.shapes.visible_asm(runtime, "visible", "scene_isect") renmas.core.generate_shade(runtime, "shade", "visible") ren.get_film().add_sample_asm(runtime, "add_sample") asm = renmas.utils.get_asm() mc = asm.assemble(ASM) ds = runtime.load("path_tracer", mc) def build_runtime(): runtime = Runtime() sam = renmas.samplers.RandomSampler(800, 800, n=200000, pixel=0.8) sam.get_sample_asm(runtime, "get_sample") ren.get_camera().ray_asm(runtime, "generate_ray") renmas.shapes.linear_isect_asm(runtime, "scene_isect", ren.dyn_arrays())
ray = ren.random_ray() ds["ray1.origin"] = v4(ray.origin) ds["ray1.dir"] = v4(ray.dir) ds["num"] = len(lst_shapes) ds["addrs"] = adrese runtime.run("test") print(ds["hp.t"], ds["clocks"]) hp = isect(ray, lst_shapes) print(hp.t) runtime2 = Runtime() renmas.shapes.linear_isect_asm(runtime2, "ray_scene", ren.dyn_arrays()) ASM2 = """ #DATA """ ASM2 += asm_structs + """ ray ray1 hitpoint hp uint32 hit = 0 uint32 clocks uint32 count = 100 #CODE rdtsc