예제 #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
파일: regular.py 프로젝트: mario007/renmas
    def test1(self):
        mgr = ColorManager()

        sampler = RegularSampler(2, 2, pixel=1.0)
        tile = Tile(5, 5, 20, 20)
        tile.split(1)
        runtime = Runtime()

        sampler.get_sample_asm([runtime], "get_sample", mgr.assembler)
        mc = mgr.assembler.assemble(self.asm_code())
        ds = runtime.load('test', mc)

        sampler.set_tile(tile)

        while True:
            sample = sampler.get_sample()
            if sample is None:
                break

            runtime.run('test')
            self.sample_test(sample, ds)

        runtime.run('test')
        ret = ds['kraj']
        self.assertFalse(ret)
예제 #3
0
    def test1(self):
        mgr = ColorManager()

        sampler = RandomSampler(2, 2, pixel=1.0)
        tile = Tile(0, 0, 3, 3)
        tile.split(1)
        runtime = Runtime()
        mgr.macro_call.set_runtimes([runtime])

        sampler.get_sample_asm([runtime], "get_sample", mgr.assembler)
        mc = mgr.assembler.assemble(self.asm_code())
        ds = runtime.load('test', mc)

        sampler.set_tile(tile)

        while True:
            sample = sampler.get_sample()
            if sample is None:
                break

            runtime.run('test')
            self.show_samples(sample, ds)

        runtime.run('test')
        ret = ds['kraj']
        self.assertFalse(ret)
예제 #4
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))
예제 #5
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)
예제 #6
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
예제 #7
0
파일: lamb.py 프로젝트: mario007/renmas
import platform
from tdasm import Runtime
from renmas3.core import ColorManager, ShadePoint, Material, Factory
from renmas3.materials import Lambertian

col_mgr = ColorManager(False)

mat = Material(col_mgr.zero_spectrum())

lamb = Lambertian(col_mgr.create_spectrum((0.3, 0.4, 0.6)))

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
예제 #8
0
파일: lamb.py 프로젝트: mario007/renmas
import platform
from tdasm import Runtime
from renmas3.core import ColorManager, ShadePoint, Material, Factory
from renmas3.materials import Lambertian

col_mgr = ColorManager(False)

mat = Material(col_mgr.zero_spectrum())

lamb = Lambertian(col_mgr.create_spectrum((0.3, 0.4, 0.6)))

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
예제 #9
0
ASM_CODE += Sample.struct() + Ray.struct() + """
    sample sample1
    ray ray1
    uint32 kraj 
    #CODE
    macro mov eax, sample1
    call get_sample
    mov dword [kraj], eax
    macro mov eax, sample1
    macro mov ebx, ray1
    call get_ray
    #END
"""

cam = Pinhole((2,3,4), (5,9,1))
mgr = ColorManager()

width = 2
height = 2
sampler = RegularSampler(width, height)

runtime = Runtime()
sampler.get_sample_asm([runtime], "get_sample", mgr.assembler)
cam.ray_asm([runtime], 'get_ray', mgr.assembler)
mc = mgr.assembler.assemble(ASM_CODE)
ds = runtime.load('test', mc)

tile = Tile(0,0, width, height)
tile.split(1)
sampler.set_tile(tile)
예제 #10
0
파일: point.py 프로젝트: mario007/renmas
from tdasm import Runtime
from renmas3.core import Factory, ColorManager, ShadePoint
from renmas3.loaders import load_spd

mgr = ColorManager(False)
factory = Factory()

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
"""