def asm_code(ren): # eax - ray # ebx - hitpoint code = "#DATA \n" + ren.color_mgr.spectrum_struct() + Ray.struct() + ShadePoint.struct() + """ ray ray1 shadepoint hp1 uint32 ret #CODE macro mov eax, ray1 macro mov ebx, hp1 call ray_scene_intersection mov dword [ret], eax #END """ return code
def asm_code(ren): # eax - ray # ebx - hitpoint code = "#DATA \n" + ren.color_mgr.spectrum_struct() + Ray.struct( ) + ShadePoint.struct() + """ ray ray1 shadepoint hp1 uint32 ret #CODE macro mov eax, ray1 macro mov ebx, hp1 call ray_scene_intersection mov dword [ret], eax #END """ return code
mat.add(lamb) factory = Factory() sp = factory.shade_point() sp.normal = factory.vector3(0, 1, 0) sp.wi = factory.vector3(2, 2, 2) print(mat.brdf(sp)) runtime = Runtime() mat.brdf_asm([runtime], col_mgr.assembler) bits = platform.architecture()[0] if bits == '64bit': ASM = "#DATA \n" + col_mgr.zero_spectrum().struct() + ShadePoint.struct( ) + """ shadepoint sp1 uint64 ptr_brdf #CODE macro mov eax, sp1 call qword [ptr_brdf] #END """ else: ASM = "#DATA \n" + col_mgr.zero_spectrum().struct() + ShadePoint.struct( ) + """ shadepoint sp1 uint32 ptr_brdf #CODE macro mov eax, sp1 call dword [ptr_brdf]
factory = Factory() sp = factory.shade_point() sp.normal = factory.vector3(0, 1, 0) sp.wi = factory.vector3(2, 2, 2) print(mat.brdf(sp)) runtime = Runtime() mat.brdf_asm([runtime], col_mgr.assembler) bits = platform.architecture()[0] if bits == "64bit": ASM = ( "#DATA \n" + col_mgr.zero_spectrum().struct() + ShadePoint.struct() + """ shadepoint sp1 uint64 ptr_brdf #CODE macro mov eax, sp1 call qword [ptr_brdf] #END """ ) else: ASM = ( "#DATA \n" + col_mgr.zero_spectrum().struct() + ShadePoint.struct() + """
light = factory.create_light(mgr=ren.color_mgr, typ='point', source='A',\ position=(9,10,9), direction=(2,2,2)) ren.add('point_light1', light) ren.prepare() direct_lighting = DirectLighting(ren) sp = factory.shade_point(hit=(5,5,5)) sp.material = 0 ret = direct_lighting.estimate_direct(sp) runtime = Runtime() direct_lighting.estimate_direct_asm([runtime], 'estimate_dir') print(ret) structs = ren.color_mgr.zero_spectrum().struct() + ShadePoint.struct() ASM = "#DATA \n" + structs + """ #DATA spectrum spec1 shadepoint sp1 #CODE macro mov eax, sp1 call estimate_dir macro mov ebx, spec1 macro spectrum ebx = eax #END """ mc = ren.assembler.assemble(ASM) ds = runtime.load('test', mc)
light = factory.create_light(mgr=mgr, typ='point', source='A',\ position=(9,10,9), direction=(2,2,2)) hp = factory.shade_point() s = light.L(hp) print(hp.wi) print(hp.light_position) print(hp.light_spectrum) runtime = Runtime() light.L_asm([runtime], mgr.assembler) structs = mgr.spectrum_struct() + ShadePoint.struct() ASM = "#DATA \n" + structs + """ shadepoint sp1 #CODE macro mov eax, sp1 """ ASM += 'call ' + light.L_asm_label + """ #END """ mc = mgr.assembler.assemble(ASM) #mc.print_machine_code() ds = runtime.load('test', mc) ds['sp1.hit'] = hp.hit.to_ds() runtime.run('test') print('--------------------------')