Example #1
0
    mov eax, r1
    mov ebx, sp1
    call generate_ray
    movaps oword [_xmm], xmm4

"""

if __name__ == "__main__":

    runtime = Runtime()

    asm = util.get_asm()
    mc = asm.assemble(ASM)
    sample = renmas.samplers.Sample()

    camera = ren.pinhole_camera((14, 5.0, 0), (0, 5.0, 0), 250)
    camera.ray_asm(runtime, "generate_ray")

    sample.x = 3.4
    sample.y = 4.5
    ray = camera.ray(sample)
    print(ray)

    ds = runtime.load("test", mc)

    ds["sp1.xyxy"] = (3.4, 4.5, 6.6, 7.7)

    runtime.run("test")
    print(ds["r1.dir"])
    print(ds["r1.origin"])
Example #2
0
def build_scene():
    s =ren.create_random_sampler(WIDTH, HEIGHT, NSAMPLES)

    ren.pinhole_camera((0.278, 0.275, -0.789), (0,0,1), 280)
    ren.create_film(WIDTH, HEIGHT, NSAMPLES)

    #create lights
    ren.create_point_light("p1", (0.3, 0.5, 0.3), (1.0, 1.0, 1.0))
    #create materials
    ren.create_lambertian("m1", 0.99, 0.0, 0.0)
    ren.create_lambertian("m2", 0.7, 0.7, 0.7)
    ren.create_lambertian("m3", 0.0, 0.99, 0.0)
    ren.create_lambertian("m4", 0.0, 0.0, 0.99)
    ren.create_lambertian("m5", 0.99, 0.0, 0.99)
    ren.create_lambertian("m6", 0.0, 0.77, 0.0)
    #create shapes

    #create triangles for cornell
    ## FLOOR
    idx = ren.get_mat_idx("m2")
    ren.create_triangle((0.556, 0.0, 0.0), (0.006, 0.0, 0.559), (0.556, 0.0, 0.559), idx)
    ren.create_triangle((0.006, 0.0, 0.559), (0.556, 0.0, 0.0), (0.003, 0.0, 0.0), idx)
    ## BACK WALL
    idx = ren.get_mat_idx("m1")
    ren.create_triangle((0.556, 0.0, 0.559), (0.000, 0.549, 0.559), (0.556, 0.549, 0.559), idx)
    ren.create_triangle((0.000, 0.549, 0.559), (0.556, 0.0, 0.559), (0.006, 0.0, 0.559), idx)

    ## RIGHT WALL
    idx = ren.get_mat_idx("m3")
    ren.create_triangle((0.006, 0.0, 0.559), (0.00, 0.549, 0.00), (0.0, 0.549, 0.559), idx)
    ren.create_triangle((0.000, 0.549, 0.0), (0.006, 0.0, 0.559), (0.003, 0.0, 0.0), idx)

    ## LEFT WALL
    idx = ren.get_mat_idx("m4")
    ren.create_triangle((0.556, 0.0, 0.0), (0.556, 0.549, 0.559), (0.556, 0.549, 0.0), idx)
    ren.create_triangle((0.556, 0.549, 0.559), (0.556, 0.0, 0.0), (0.556, 0.0, 0.559), idx)

    ## TOP
    idx = ren.get_mat_idx("m5")
    ren.create_triangle((0.556, 0.549, 0.559), (0.0, 0.549, 0.0), (0.556, 0.549, 0.0), idx)
    ren.create_triangle((0.0, 0.549, 0.0), (0.556, 0.549, 0.559), (0.0, 0.549, 0.559), idx)

    ## gornji dio manje kocke
    idx = ren.get_mat_idx("m5")
    ren.create_triangle((0.474, 0.165, 0.225), (0.426, 0.165, 0.065), (0.316, 0.165, 0.272), idx)
    ren.create_triangle((0.266, 0.165, 0.114), (0.316, 0.165, 0.272), (0.426, 0.165, 0.065), idx)

    idx = ren.get_mat_idx("m5")
    ren.create_triangle((0.266, 0.0, 0.114), (0.266, 0.165, 0.114), (0.316, 0.165, 0.272), idx)
    ren.create_triangle((0.316, 0.0, 0.272), (0.266, 0.0, 0.114), (0.316, 0.165, 0.272), idx)

    idx = ren.get_mat_idx("m5")
    ren.create_triangle((0.316, 0.0, 0.272), (0.316, 0.165, 0.272), (0.474, 0.165, 0.225), idx)
    ren.create_triangle((0.474, 0.165, 0.225), (0.316, 0.0, 0.272), (0.474, 0.0, 0.225), idx)

    idx = ren.get_mat_idx("m5")
    ren.create_triangle((0.474, 0.0, 0.225), (0.474, 0.165, 0.225), (0.426, 0.165, 0.065), idx)
    ren.create_triangle((0.426, 0.165, 0.065), (0.426, 0.0, 0.065), (0.474, 0.0, 0.225), idx)

    idx = ren.get_mat_idx("m5")
    ren.create_triangle((0.426, 0.0, 0.065), (0.426, 0.165, 0.065), (0.266, 0.165, 0.114), idx)
    ren.create_triangle((0.266, 0.165, 0.114), (0.266, 0.0, 0.114), (0.426, 0.0, 0.065), idx)

    #veca kocka - gornji dio
    idx = ren.get_mat_idx("m6")
    ren.create_triangle((0.133, 0.330, 0.247), (0.291, 0.330, 0.296), (0.242, 0.330, 0.456), idx)
    ren.create_triangle((0.242, 0.330, 0.456), (0.084, 0.330, 0.406), (0.133, 0.330, 0.247), idx)

    idx = ren.get_mat_idx("m6")
    ren.create_triangle((0.133, 0.0, 0.247), (0.133, 0.330, 0.247), (0.084, 0.330, 0.406), idx)
    ren.create_triangle((0.084, 0.330, 0.406), (0.084, 0.0, 0.406), (0.133, 0.0, 0.247), idx)

    idx = ren.get_mat_idx("m6")
    ren.create_triangle((0.084, 0.000, 0.406), (0.084, 0.330, 0.406), (0.242, 0.330, 0.456), idx)
    ren.create_triangle((0.242, 0.330, 0.456), (0.242, 0.000, 0.456), (0.084, 0.000, 0.406), idx)

    idx = ren.get_mat_idx("m6")
    ren.create_triangle((0.242, 0.000, 0.456), (0.242, 0.330, 0.456), (0.291, 0.330, 0.296), idx)
    ren.create_triangle((0.291, 0.330, 0.296), (0.291, 0.000, 0.296), (0.242, 0.000, 0.456), idx)

    idx = ren.get_mat_idx("m6")
    ren.create_triangle((0.291, 0.000, 0.296), (0.291, 0.330, 0.296), (0.133, 0.330, 0.247), idx)
    ren.create_triangle((0.133, 0.330, 0.247), (0.133, 0.000, 0.247), (0.291, 0.000, 0.296), idx)
Example #3
0
    mov eax, r1
    mov ebx, sp1
    call generate_ray
    movaps oword [_xmm], xmm4

"""

if __name__ == "__main__":

    runtime = Runtime()

    asm = util.get_asm()
    mc = asm.assemble(ASM)
    sample = renmas.samplers.Sample()

    camera = ren.pinhole_camera((14,5.0,0), (0,5.0,0), 250)
    camera.ray_asm(runtime, "generate_ray")

    sample.x = 3.4
    sample.y = 4.5
    ray = camera.ray(sample)
    print(ray)

    ds = runtime.load("test", mc)

    ds["sp1.xyxy"] = (3.4, 4.5, 6.6, 7.7)
   
    runtime.run("test")
    print(ds["r1.dir"])
    print(ds["r1.origin"])
Example #4
0
def build_scene():
    s = ren.create_random_sampler(WIDTH, HEIGHT, NSAMPLES)

    ren.pinhole_camera((0.278, 0.275, -0.789), (0, 0, 1), 280)
    ren.create_film(WIDTH, HEIGHT, NSAMPLES)

    #create lights
    ren.create_point_light("p1", (0.3, 0.5, 0.3), (1.0, 1.0, 1.0))
    #create materials
    ren.create_lambertian("m1", 0.99, 0.0, 0.0)
    ren.create_lambertian("m2", 0.7, 0.7, 0.7)
    ren.create_lambertian("m3", 0.0, 0.99, 0.0)
    ren.create_lambertian("m4", 0.0, 0.0, 0.99)
    ren.create_lambertian("m5", 0.99, 0.0, 0.99)
    ren.create_lambertian("m6", 0.0, 0.77, 0.0)
    #create shapes

    #create triangles for cornell
    ## FLOOR
    idx = ren.get_mat_idx("m2")
    ren.create_triangle((0.556, 0.0, 0.0), (0.006, 0.0, 0.559),
                        (0.556, 0.0, 0.559), idx)
    ren.create_triangle((0.006, 0.0, 0.559), (0.556, 0.0, 0.0),
                        (0.003, 0.0, 0.0), idx)
    ## BACK WALL
    idx = ren.get_mat_idx("m1")
    ren.create_triangle((0.556, 0.0, 0.559), (0.000, 0.549, 0.559),
                        (0.556, 0.549, 0.559), idx)
    ren.create_triangle((0.000, 0.549, 0.559), (0.556, 0.0, 0.559),
                        (0.006, 0.0, 0.559), idx)

    # RIGHT WALL
    idx = ren.get_mat_idx("m3")
    ren.create_triangle((0.006, 0.0, 0.559), (0.00, 0.549, 0.00),
                        (0.0, 0.549, 0.559), idx)
    ren.create_triangle((0.000, 0.549, 0.0), (0.006, 0.0, 0.559),
                        (0.003, 0.0, 0.0), idx)

    ## LEFT WALL
    idx = ren.get_mat_idx("m4")
    ren.create_triangle((0.556, 0.0, 0.0), (0.556, 0.549, 0.559),
                        (0.556, 0.549, 0.0), idx)
    ren.create_triangle((0.556, 0.549, 0.559), (0.556, 0.0, 0.0),
                        (0.556, 0.0, 0.559), idx)

    ## TOP
    idx = ren.get_mat_idx("m5")
    ren.create_triangle((0.556, 0.549, 0.559), (0.0, 0.549, 0.0),
                        (0.556, 0.549, 0.0), idx)
    ren.create_triangle((0.0, 0.549, 0.0), (0.556, 0.549, 0.559),
                        (0.0, 0.549, 0.559), idx)

    ## gornji dio manje kocke
    idx = ren.get_mat_idx("m5")
    ren.create_triangle((0.474, 0.165, 0.225), (0.426, 0.165, 0.065),
                        (0.316, 0.165, 0.272), idx)
    ren.create_triangle((0.266, 0.165, 0.114), (0.316, 0.165, 0.272),
                        (0.426, 0.165, 0.065), idx)

    idx = ren.get_mat_idx("m5")
    ren.create_triangle((0.266, 0.0, 0.114), (0.266, 0.165, 0.114),
                        (0.316, 0.165, 0.272), idx)
    ren.create_triangle((0.316, 0.0, 0.272), (0.266, 0.0, 0.114),
                        (0.316, 0.165, 0.272), idx)

    idx = ren.get_mat_idx("m5")
    ren.create_triangle((0.316, 0.0, 0.272), (0.316, 0.165, 0.272),
                        (0.474, 0.165, 0.225), idx)
    ren.create_triangle((0.474, 0.165, 0.225), (0.316, 0.0, 0.272),
                        (0.474, 0.0, 0.225), idx)

    idx = ren.get_mat_idx("m5")
    ren.create_triangle((0.474, 0.0, 0.225), (0.474, 0.165, 0.225),
                        (0.426, 0.165, 0.065), idx)
    ren.create_triangle((0.426, 0.165, 0.065), (0.426, 0.0, 0.065),
                        (0.474, 0.0, 0.225), idx)

    idx = ren.get_mat_idx("m5")
    ren.create_triangle((0.426, 0.0, 0.065), (0.426, 0.165, 0.065),
                        (0.266, 0.165, 0.114), idx)
    ren.create_triangle((0.266, 0.165, 0.114), (0.266, 0.0, 0.114),
                        (0.426, 0.0, 0.065), idx)

    #veca kocka - gornji dio
    idx = ren.get_mat_idx("m6")
    ren.create_triangle((0.133, 0.330, 0.247), (0.291, 0.330, 0.296),
                        (0.242, 0.330, 0.456), idx)
    ren.create_triangle((0.242, 0.330, 0.456), (0.084, 0.330, 0.406),
                        (0.133, 0.330, 0.247), idx)

    idx = ren.get_mat_idx("m6")
    ren.create_triangle((0.133, 0.0, 0.247), (0.133, 0.330, 0.247),
                        (0.084, 0.330, 0.406), idx)
    ren.create_triangle((0.084, 0.330, 0.406), (0.084, 0.0, 0.406),
                        (0.133, 0.0, 0.247), idx)

    idx = ren.get_mat_idx("m6")
    ren.create_triangle((0.084, 0.000, 0.406), (0.084, 0.330, 0.406),
                        (0.242, 0.330, 0.456), idx)
    ren.create_triangle((0.242, 0.330, 0.456), (0.242, 0.000, 0.456),
                        (0.084, 0.000, 0.406), idx)

    idx = ren.get_mat_idx("m6")
    ren.create_triangle((0.242, 0.000, 0.456), (0.242, 0.330, 0.456),
                        (0.291, 0.330, 0.296), idx)
    ren.create_triangle((0.291, 0.330, 0.296), (0.291, 0.000, 0.296),
                        (0.242, 0.000, 0.456), idx)

    idx = ren.get_mat_idx("m6")
    ren.create_triangle((0.291, 0.000, 0.296), (0.291, 0.330, 0.296),
                        (0.133, 0.330, 0.247), idx)
    ren.create_triangle((0.133, 0.330, 0.247), (0.133, 0.000, 0.247),
                        (0.291, 0.000, 0.296), idx)