本文整理汇总了Python中tdasm.Runtime.address_module方法的典型用法代码示例。如果您正苦于以下问题:Python Runtime.address_module方法的具体用法?Python Runtime.address_module怎么用?Python Runtime.address_module使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tdasm.Runtime
的用法示例。
在下文中一共展示了Runtime.address_module方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_transmission_sampling
# 需要导入模块: from tdasm import Runtime [as 别名]
# 或者: from tdasm.Runtime import address_module [as 别名]
def test_transmission_sampling(self):
factory = renmas2.Factory()
ren = renmas2.Renderer()
runtime = Runtime()
mat = renmas2.core.material.Material(ren.converter.zero_spectrum())
eta_in = 1.3
eta_out = 1.0
sampling = renmas2.materials.PerfectTransmissionSampling(eta_in, eta_out)
mat.add(sampling)
eta_in = ren.converter.zero_spectrum().set(1.3)
eta_out = ren.converter.zero_spectrum().set(1.0)
fresnel = renmas2.materials.FresnelDielectric(eta_in, eta_out)
spec = ren.converter.create_spectrum((0.5, 0.5, 0.5))
perf_spec = renmas2.materials.PerfectTransmission(spec, fresnel, 1.0)
mat.add(perf_spec)
ref_sam = renmas2.materials.PerfectSpecularSampling()
mat.add(ref_sam)
spec2 = ren.converter.create_spectrum((0.9, 0.9, 0.9))
fresnel2 = renmas2.materials.FresnelDielectric(eta_in, eta_out)
perf_ref = renmas2.materials.PerfectSpecular(spec2, fresnel2, 1.0)
mat.add(perf_ref)
normal = factory.vector(2, 4.5, 5)
normal.normalize()
hit_point = factory.vector(3, 5, 6)
wo = factory.vector(-2, 1, 0)
wo.normalize()
hp = renmas2.shapes.HitPoint(1.5, hit_point, normal, 0)
hp.wo = wo
hp.fliped = False
ren.macro_call.set_runtimes([runtime])
mat.next_direction_bsdf_asm([runtime], ren.structures, ren.assembler)
mc = ren.assembler.assemble(self.asm_code1(ren))
ds = runtime.load("test", mc)
ds["next_dir_ptr"] = runtime.address_module(mat.nd_asm_name)
ds["hp.normal"] = (normal.x, normal.y, normal.z, 0.0)
ds["hp.t"] = 1.5
ds["hp.hit"] = (hit_point.x, hit_point.y, hit_point.z, 0.0)
ds["hp.wo"] = (wo.x, wo.y, wo.z, 0.0)
ds["hp.fliped"] = 0
runtime.run("test")
mat.next_direction_bsdf(hp)
print ("Python")
print (hp.wi)
print (hp.ndotwi)
print (hp.specular)
print (hp.f_spectrum)
print ("ASM")
print (ds["hp.wi"])
print (ds["hp.ndotwi"])
print (ds["hp.specular"])
print (ds["hp.f_spectrum.values"])
示例2: test_phong1
# 需要导入模块: from tdasm import Runtime [as 别名]
# 或者: from tdasm.Runtime import address_module [as 别名]
def test_phong1(self):
factory = renmas2.Factory()
ren = renmas2.Renderer()
runtime = Runtime()
mat = renmas2.core.material.Material(ren.converter.zero_spectrum())
spec = ren.converter.create_spectrum((0.2, 0.3, 0.1))
ren.macro_call.set_runtimes([runtime])
phong = factory.create_phong(spec, 2.0)
mat.add(phong)
t = 2.3
hit_point = factory.vector(2.2, 3.1, 4.4)
normal = factory.vector(2.9, 1.2, 4.5)
normal.normalize()
ray = factory.create_ray(origin=(4,4,4), direction=(6,7,8))
hp = renmas2.shapes.HitPoint(t, hit_point, normal, 0, ray)
wi = factory.vector(-6,8,-3.8)
wi.normalize()
hp.wo = ray.dir * -1.0
hp.wi = wi
hp.ndotwi = normal.dot(wi)
mat.f_asm([runtime], ren.assembler, ren.structures)
mc = ren.assembler.assemble(self.asm_code1(ren))
ds = runtime.load("test", mc)
self.populate_ds(ds, hp)
ds["brdf_ptr"] = runtime.address_module(mat.f_asm_name)
runtime.run("test")
spectrum = mat.f(hp)
print(spectrum)
print(ds["hp.f_spectrum.values"])
示例3: test_hemisphere_cos
# 需要导入模块: from tdasm import Runtime [as 别名]
# 或者: from tdasm.Runtime import address_module [as 别名]
def test_hemisphere_cos(self):
factory = renmas2.Factory()
ren = renmas2.Renderer()
runtime = Runtime()
mat1 = ren.shader.material("default")
sam = renmas2.materials.HemisphereCos(1.5)
mat1.add(sam)
normal = factory.vector(2, 4, 5)
normal.normalize()
hit_point = factory.vector(3, 5, 6)
hp = renmas2.shapes.HitPoint(1.5, hit_point, normal, 0)
ren.macro_call.set_runtimes([runtime])
mat1.next_direction_asm([runtime], ren.structures, ren.assembler)
mc = ren.assembler.assemble(self.asm_code1(ren))
ds = runtime.load("test", mc)
ds["next_dir_ptr"] = runtime.address_module(mat1.nd_asm_name)
ds["hp.normal"] = (normal.x, normal.y, normal.z, 0.0)
ds["hp.t"] = 1.5
ds["hp.hit"] = (hit_point.x, hit_point.y, hit_point.z)
runtime.run("test")
print(ds['hp.wi'])
print(ds['hp.ndotwi'])
print(ds['hp.pdf'])
mat1.next_direction(hp)
print(hp.ndotwi)
print(hp.wi)
print(hp.pdf)
示例4: test_hemisphere_cos
# 需要导入模块: from tdasm import Runtime [as 别名]
# 或者: from tdasm.Runtime import address_module [as 别名]
def test_hemisphere_cos(self):
factory = renmas2.Factory()
ren = renmas2.Renderer()
runtime = Runtime()
spec = ren.converter.create_spectrum((0.2, 0.3, 0.1))
mat1 = renmas2.core.material.Material(ren.converter.zero_spectrum())
phong = factory.create_phong(spec, 2.0)
lam_sampling = renmas2.materials.LambertianSampling()
mat1.add(phong)
mat1.add(lam_sampling)
normal = factory.vector(2, 4, 5)
normal.normalize()
hit_point = factory.vector(3, 5, 6)
hp = renmas2.shapes.HitPoint(1.5, hit_point, normal, 0)
ren.macro_call.set_runtimes([runtime])
mat1.next_direction_asm([runtime], ren.structures, ren.assembler)
mc = ren.assembler.assemble(self.asm_code1(ren))
ds = runtime.load("test", mc)
ds["next_dir_ptr"] = runtime.address_module(mat1.nd_asm_name)
ds["hp.normal"] = (normal.x, normal.y, normal.z, 0.0)
ds["hp.t"] = 1.5
ds["hp.hit"] = (hit_point.x, hit_point.y, hit_point.z)
runtime.run("test")
print(ds['hp.wi'])
print(ds['hp.ndotwi'])
print(ds['hp.pdf'])
mat1.next_direction(hp)
print(hp.ndotwi)
print(hp.wi)
print(hp.pdf)
示例5: test_lamb1
# 需要导入模块: from tdasm import Runtime [as 别名]
# 或者: from tdasm.Runtime import address_module [as 别名]
def test_lamb1(self):
factory = renmas2.Factory()
ren = renmas2.Renderer()
runtime = Runtime()
mat = renmas2.core.material.Material(ren.converter.zero_spectrum())
#mat.f_asm([runtime], ren.assembler, ren.structures)
mat1 = ren.shader.material("default")
mat1.f_asm([runtime], ren.assembler, ren.structures)
mc = ren.assembler.assemble(self.asm_code1(ren))
ds = runtime.load("test", mc)
ds["brdf_ptr"] = runtime.address_module(mat1.f_asm_name)
runtime.run("test")
print(ds["hp.f_spectrum.values"])
示例6: test_perfect_specular
# 需要导入模块: from tdasm import Runtime [as 别名]
# 或者: from tdasm.Runtime import address_module [as 别名]
def test_perfect_specular(self):
factory = renmas2.Factory()
ren = renmas2.Renderer()
runtime = Runtime()
mat = renmas2.core.material.Material(ren.converter.zero_spectrum())
spec = ren.converter.create_spectrum((1.0, 1.0, 1.0))
ren.macro_call.set_runtimes([runtime])
eta_in = ren.converter.zero_spectrum().set(1.5)
eta_out = ren.converter.zero_spectrum().set(1.0)
fresnel = renmas2.materials.FresnelDielectric(eta_in, eta_out)
perf_spec = renmas2.materials.PerfectSpecular(spec, fresnel, 1.0)
mat.add(perf_spec)
t = 2.3
hit_point = factory.vector(2.2, 3.1, 4.4)
normal = factory.vector(2.9, 1.2, 4.5)
normal.normalize()
hp = renmas2.shapes.HitPoint(t, hit_point, normal, 0)
wi = factory.vector(6,-27,3.8)
wi.normalize()
wo = factory.vector(2, 2, 4)
wo.normalize()
hp.wo = wo
hp.wi = wi
hp.ndotwi = normal.dot(wi)
print (hp.ndotwi)
hp.fliped = True
hp.specular = 89
mat.f_asm([runtime], ren.assembler, ren.structures)
mc = ren.assembler.assemble(self.asm_code1(ren))
ds = runtime.load("test", mc)
self.populate_ds(ds, hp)
ds["brdf_ptr"] = runtime.address_module(mat.f_asm_name)
runtime.run("test")
spectrum = mat.f(hp)
print("shlick", self.shlick(1.5, hp.ndotwi))
print("Python")
print(spectrum)
print("---------------------------------------")
print("Asm")
print(ds["hp.f_spectrum.values"])
示例7: test_transmission_sampling
# 需要导入模块: from tdasm import Runtime [as 别名]
# 或者: from tdasm.Runtime import address_module [as 别名]
def test_transmission_sampling(self):
factory = renmas2.Factory()
ren = renmas2.Renderer()
runtime = Runtime()
mat = renmas2.core.material.Material(ren.converter.zero_spectrum())
eta_in = 1.3
eta_out = 1.0
sampling = renmas2.materials.PerfectTransmissionSampling(eta_in, eta_out)
normal = factory.vector(2, 4.5, 5)
normal.normalize()
hit_point = factory.vector(3, 5, 6)
wo = factory.vector(-2, 1, 0)
wo.normalize()
hp = renmas2.shapes.HitPoint(1.5, hit_point, normal, 0)
hp.wo = wo
hp.fliped = False
ren.macro_call.set_runtimes([runtime])
sampling.next_direction_asm([runtime], ren.structures, ren.assembler)
mc = ren.assembler.assemble(self.asm_code1(ren))
ds = runtime.load("test", mc)
ds["next_dir_ptr"] = runtime.address_module(sampling.nd_asm_name)
ds["hp.normal"] = (normal.x, normal.y, normal.z, 0.0)
ds["hp.t"] = 1.5
ds["hp.hit"] = (hit_point.x, hit_point.y, hit_point.z, 0.0)
ds["hp.wo"] = (wo.x, wo.y, wo.z, 0.0)
ds["hp.fliped"] = 0
runtime.run("test")
sampling.next_direction(hp)
print ("Python")
print (hp.wi)
print (hp.ndotwi)
print ("ASM")
print (ds["hp.wi"])
print (ds["hp.ndotwi"])
示例8: test_perfect_sampling
# 需要导入模块: from tdasm import Runtime [as 别名]
# 或者: from tdasm.Runtime import address_module [as 别名]
def test_perfect_sampling(self):
factory = renmas2.Factory()
ren = renmas2.Renderer()
runtime = Runtime()
mat = renmas2.core.material.Material(ren.converter.zero_spectrum())
sam = renmas2.materials.PerfectSpecularSampling()
mat.add(sam)
normal = factory.vector(2, 4.5, 5)
normal.normalize()
hit_point = factory.vector(3, 5, 6)
wo = factory.vector(-2, 1, 0)
wo.normalize()
hp = renmas2.shapes.HitPoint(1.5, hit_point, normal, 0)
hp.wo = wo
ren.macro_call.set_runtimes([runtime])
mat.next_direction_asm([runtime], ren.structures, ren.assembler)
mc = ren.assembler.assemble(self.asm_code1(ren))
ds = runtime.load("test", mc)
ds["next_dir_ptr"] = runtime.address_module(mat.nd_asm_name)
ds["hp.normal"] = (normal.x, normal.y, normal.z, 0.0)
ds["hp.t"] = 1.5
ds["hp.hit"] = (hit_point.x, hit_point.y, hit_point.z, 0.0)
ds["hp.wo"] = (wo.x, wo.y, wo.z, 0.0)
runtime.run("test")
print ("PDF =", hp.pdf)
print ("wi =", hp.wi)
print ("ndotwi =", hp.ndotwi)
mat.next_direction(hp)
print ("PDF =", hp.pdf, " ASM pdf = ", ds["hp.pdf"])
print ("wi =", hp.wi)
print ("asm wi", ds["hp.wi"])
print ("ndotwi =", hp.ndotwi, " asm ndtowi=", ds["hp.ndotwi"])
print ("normal=", hp.normal)
示例9: test_ward1
# 需要导入模块: from tdasm import Runtime [as 别名]
# 或者: from tdasm.Runtime import address_module [as 别名]
def test_ward1(self):
factory = renmas2.Factory()
ren = renmas2.Renderer()
runtime = Runtime()
mat = renmas2.core.material.Material(ren.converter.zero_spectrum())
spec = ren.converter.create_spectrum((0.2, 0.3, 0.1))
ren.macro_call.set_runtimes([runtime])
ward = factory.create_ward(spec, 0.1, 1.0)
mat.add(ward)
t = 2.3
hit_point = factory.vector(2.2, 3.1, 4.4)
normal = factory.vector(2.9, 1.2, 4.5)
normal.normalize()
hp = renmas2.shapes.HitPoint(t, hit_point, normal, 0)
wi = factory.vector(6,-8,3.8)
wi.normalize()
wo = factory.vector(2, 2, 4)
wo.normalize()
hp.wo = wo
hp.wi = wi
hp.ndotwi = normal.dot(wi)
mat.f_asm([runtime], ren.assembler, ren.structures)
mc = ren.assembler.assemble(self.asm_code1(ren))
ds = runtime.load("test", mc)
self.populate_ds(ds, hp)
ds["brdf_ptr"] = runtime.address_module(mat.f_asm_name)
runtime.run("test")
spectrum = mat.f(hp)
print("Python")
print(spectrum)
print("---------------------------------------")
print("Asm")
print(ds["hp.f_spectrum.values"])
示例10:
# 需要导入模块: from tdasm import Runtime [as 别名]
# 或者: from tdasm.Runtime import address_module [as 别名]
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]
#END
"""
)
mc = col_mgr.assembler.assemble(ASM)
# mc.print_machine_code()
ds = runtime.load("test", mc)
ds["ptr_brdf"] = runtime.address_module(mat.brdf_asm_name)
ds["sp1.normal"] = sp.normal.to_ds()
ds["sp1.wi"] = sp.wi.to_ds()
runtime.run("test")
print(ds["sp1.f_spectrum.values"])