コード例 #1
0
def test_clamp():
    mgr = ColorManager()
    ASM = "\n #DATA \n " + mgr.spectrum_struct() + """
    spectrum sp1
    float low =0.25
    float high = 0.35

    #CODE
    macro mov ebx, sp1
    macro eq32 xmm0 = low
    macro eq32 xmm1 = high
    macro spectrum clamp ebx
    #END
    """
    mc = mgr.assembler.assemble(ASM) 
    #mc.print_machine_code()
    runtime = Runtime()
    ds = runtime.load("test", mc)
    col = mgr.create_spectrum((0.3, 0.2, 0.4))
    ds['sp1.values'] = col.to_ds() 
    runtime.run('test')
    print(ds['sp1.values'])
    col.clamp(low=0.25, high=0.35)
    if col.sampled:
        print(col)
    else:
        print(col.r, col.g, col.b)
    pass
コード例 #2
0
def test_set():
    mgr = ColorManager()
    ASM = "\n #DATA \n " + mgr.spectrum_struct() + """
    spectrum sp1
    float value = 0.3

    #CODE
    macro mov ebx, sp1
    macro eq32 xmm0 = value 
    macro spectrum ebx = xmm0
    #END
    """
    mc = mgr.assembler.assemble(ASM) 
    #mc.print_machine_code()
    runtime = Runtime()
    ds = runtime.load("test", mc)
    col = mgr.create_spectrum((0.3, 0.2, 0.4))
    ds['sp1.values'] = col.to_ds() 
    runtime.run('test')
    print(ds['sp1.values'])
    print(col.set(0.3))
コード例 #3
0
def test_sum():
    mgr = ColorManager()
    ASM = "\n #DATA \n " + mgr.spectrum_struct() + """
    spectrum sp1
    float sum
    #CODE
    macro mov ebx, sp1
    macro spectrum sum ebx
    macro eq32 sum = xmm0 {xmm7}
    #END
    """
    mc = mgr.assembler.assemble(ASM) 
    #mc.print_machine_code()
    runtime = Runtime()
    ds = runtime.load("test", mc)
    col = mgr.create_spectrum((0.3, 0.2, 0.4))
    ds['sp1.values'] = col.to_ds() 
    runtime.run('test')
    print(ds['sum'])
    if col.sampled:
        print(sum(col.samples))
    else:
        print(col.r + col.g + col.b)
コード例 #4
0
def test_arithmetic():
    mgr = ColorManager()
    ASM = "\n #DATA \n " + mgr.spectrum_struct() + """
    spectrum sp1, sp2, sp3

    #CODE
    macro mov ebx, sp1
    macro mov eax, sp2
    macro mov ecx, sp3
    macro spectrum ecx = eax + ebx
    #END
    """
    mc = mgr.assembler.assemble(ASM) 
    #mc.print_machine_code()
    runtime = Runtime()
    ds = runtime.load("test", mc)
    col1 = mgr.create_spectrum((0.3, 0.2, 0.4))
    col2 = mgr.create_spectrum((0.1, 0.5, 0.1))
    ds['sp1.values'] = col1.to_ds() 
    ds['sp2.values'] = col2.to_ds() 
    runtime.run('test')
    print(ds['sp3.values'])
    print(col1+col2)
    pass
コード例 #5
0
ファイル: point.py プロジェクト: mario007/renmas
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('--------------------------')