Exemplo n.º 1
0
def raycast(tile):
    sampler = ren.get_sampler()
    camera = ren.get_camera()
    film = ren.get_film()

    shapes = ren.isect_shapes()
    isect = renmas.shapes.isect #intersection rutine
    shade = renmas.core.shade

    background = renmas.core.Spectrum(0.00, 0.00, 0.00) 
    hp2 = renmas.shapes.HitPoint()
    hp2.spectrum = background

    sample = renmas.samplers.Sample()
    x, y, width, height = tile
    sampler.tile(x, y, width, height)

    while True:
        sam = sampler.get_sample(sample)
        if sam is None: break 
        ray = camera.ray(sample)
        hp = isect(ray, shapes)

        if hp is None:
            film.add_sample(sample, hp2) #background
        else:
            hp.wo = ray.dir * -1.0
            shade(hp)
            film.add_sample(sample, hp) #background
Exemplo n.º 2
0
def get_hp(sample):
    sam = sampler.get_sample(sample)
    if sam is None: return False
    ray = camera.ray(sample)
    hp = isect(ray, shapes, 999999.0)
    if hp is not None:
        hp.wo = ray.dir * -1.0
    return hp
Exemplo n.º 3
0
def get_hp(sample):
    sam = sampler.get_sample(sample)
    if sam is None: return False 
    ray = camera.ray(sample)
    hp = isect(ray, shapes, 999999.0)
    if hp is not None:
        hp.wo = ray.dir * -1.0
    return hp 
Exemplo n.º 4
0
def raycast():
    sampler = ren.get_sampler()
    camera = ren.get_camera()
    film = ren.get_film()
    lst_lights = ren.lst_lights()
    shapes = ren.lst_shapes()
    #isect = renmas.shapes.isect #intersection rutine
    isect = grid.isect
    shade = renmas.core.shade

    background = renmas.core.Spectrum(0.00, 0.00, 0.00)
    hp2 = renmas.shapes.HitPoint()
    hp2.spectrum = background

    tile = next_tile()
    if tile is None:
        global image_saved
        if not image_saved:
            save_image(film, "Image5.png")
            print("Slika je spremljena")
            image_saved = True
        return None
    sample = renmas.samplers.Sample()
    x, y, width, height = tile
    sampler.tile(x, y, width, height)
    start = time.clock()

    while True:
        sam = sampler.get_sample(sample)
        if sam is None: break
        ray = camera.ray(sample)
        #hp = isect(ray, shapes, 999999.0)
        hp = isect(ray)

        if hp is None:
            film.add_sample(sample, hp2)  #background
        else:
            hp.wo = ray.dir * -1.0
            shade(hp)
            film.add_sample(sample, hp)  #background

    blt_float_img_to_window(0, 0, film.image, win)
    end = time.clock()
    global duration
    duration = duration + (end - start)
    print("Renderiranje jednog tile je trajalo", end - start, duration)
    return True
Exemplo n.º 5
0
def raycast():
    sampler = ren.get_sampler()
    camera = ren.get_camera()
    film = ren.get_film()
    lst_lights = ren.lst_lights()
    shapes = ren.lst_shapes()
    #isect = renmas.shapes.isect #intersection rutine
    isect = grid.isect
    shade = renmas.core.shade

    background = renmas.core.Spectrum(0.00, 0.00, 0.00) 
    hp2 = renmas.shapes.HitPoint()
    hp2.spectrum = background

    tile = next_tile()
    if tile is None: 
        global image_saved
        if not image_saved:
            save_image(film, "Image5.png")
            print("Slika je spremljena")
            image_saved = True
        return None
    sample = renmas.samplers.Sample()
    x, y, width, height = tile
    sampler.tile(x, y, width, height)
    start = time.clock()
    
    while True:
        sam = sampler.get_sample(sample)
        if sam is None: break 
        ray = camera.ray(sample)
        #hp = isect(ray, shapes, 999999.0)
        hp = isect(ray)

        if hp is None:
            film.add_sample(sample, hp2) #background
        else:
            hp.wo = ray.dir * -1.0
            shade(hp)
            film.add_sample(sample, hp) #background

    blt_float_img_to_window(0, 0, film.image, win)
    end = time.clock()
    global duration
    duration = duration + (end - start)
    print("Renderiranje jednog tile je trajalo", end - start, duration)
    return True
Exemplo n.º 6
0
def raycast():
    tile = next_tile()
    if tile is None:
        save_image(film)
        return None
    x, y, width, height = tile
    sampler.tile(x, y, width, height)

    while True:
        sam = sampler.get_sample(sample)
        if sam is None: break
        ray = camera.ray(sample)
        hp = isect(ray, shapes, 999999.0)
        if hp is None:
            film.add_sample(sample, hp2)  #background
        else:
            hp.wo = ray.dir * -1.0
            shade(sample, hp)

    blt_float_img_to_window(0, 0, blitter, film.image, win)
    return True
Exemplo n.º 7
0
def raycast():
    tile = next_tile()
    if tile is None: 
        save_image(film)
        return None
    x, y, width, height = tile
    sampler.tile(x, y, width, height)

    while True:
        sam = sampler.get_sample(sample)
        if sam is None: break
        ray = camera.ray(sample)
        hp = isect(ray, shapes, 999999.0)
        if hp is None:
            film.add_sample(sample, hp2) #background
        else:
            hp.wo = ray.dir * -1.0
            shade(sample, hp)

    blt_float_img_to_window(0, 0, blitter, film.image, win)
    return True
Exemplo n.º 8
0
def path_tracer(tile):
    sampler = ren.get_sampler()
    camera = ren.get_camera()
    film = ren.get_film()

    shapes = ren.isect_shapes()
    isect = renmas.shapes.isect  #intersection rutine
    shade = renmas.core.shade

    background = renmas.core.Spectrum(0.00, 0.00, 0.00)
    hp2 = renmas.shapes.HitPoint()
    hp3 = renmas.shapes.HitPoint()
    hp2.spectrum = background

    sample = renmas.samplers.Sample()
    x, y, width, height = tile
    sampler.tile(x, y, width, height)

    Lr = []  #reflection coefficient
    Ld = []  #direct light
    transmitance = 1.0
    cur_depth = 0
    max_depth = 4

    #current implementation stop tracing path when we hit emitter
    while True:
        sam = sampler.get_sample(sample)
        if sam is None: break
        ray = camera.ray(sample)
        hp = isect(ray, shapes)

        if hp is None:
            film.add_sample(sample, hp2)  #background
            continue

        hp.wo = ray.dir * -1.0
        shade(hp)
        kr = hp.brdf * (1.0 / hp.pdf) * hp.ndotwi
        transmitance *= kr.r  #FIXME take component that has maximum value
        Lr.append(kr)
        Ld.append(hp.spectrum)

        cur_depth = 1
        ray.dir = hp.wi  #in wi is next direction
        ray.origin = hp.hit_point
        if hp.le.r > 0.01:  #primiray ray hit emitter - stop path
            hp.spectrum = hp.le
            film.add_sample(sample, hp)
            Lr = []
            Ld = []
            transmitance = 1.0
            cur_depth = 0
            continue

        Le = renmas.core.Spectrum(0.00, 0.00, 0.00)

        while True:
            if cur_depth == max_depth: break
            if transmitance < 0.0001: break
            hp = isect(ray, shapes)
            if hp is None: break
            hp.wo = ray.dir * -1.0
            shade(hp)
            if hp.le.r > 0.0001:
                #Le = hp.le
                break  #we hit emiter FIXME - we dont't have to stop think for better implementation !!!!
            kr = hp.brdf * (1.0 / hp.pdf) * hp.ndotwi
            Lr.append(kr)
            Ld.append(hp.spectrum)
            ray.dir = hp.wi  #in wi is next direction
            ray.origin = hp.hit_point
            transmitance *= kr.r  #FIXME take component that has maximum value
            cur_depth += 1

        tmp_spec = Le
        for i in range(cur_depth):

            brdf = Lr.pop()
            ld = Ld.pop()
            tmp_spec = tmp_spec.mix_spectrum(brdf) + ld

        hp3.spectrum = tmp_spec
        film.add_sample(sample, hp3)

        Lr = []
        Ld = []
        transmitance = 1.0
        cur_depth = 0
Exemplo n.º 9
0
def raycast():
    sampler = ren.get_sampler()
    camera = ren.get_camera()
    film = ren.get_film()
    lst_lights = ren.lst_lights()

    shapes = ren.isect_shapes()
    isect = renmas.shapes.isect  #intersection rutine
    shade = renmas.core.shade
    recursion_depth = 3

    background = renmas.core.Spectrum(0.00, 0.00, 0.00)
    hp2 = renmas.shapes.HitPoint()
    hp2.spectrum = background

    tile = next_tile()
    if tile is None:
        global image_saved
        if not image_saved:
            save_image(film, "Image5.png")
            print("Slika je spremljena")
            image_saved = True
        return None
    sample = renmas.samplers.Sample()
    x, y, width, height = tile
    sampler.tile(x, y, width, height)
    start = time.clock()

    while True:
        sam = sampler.get_sample(sample)
        if sam is None: break
        ray = camera.ray(sample)
        hp = isect(ray, shapes, 999999.0)

        if hp is None:
            hp2.spectrum = background
            film.add_sample(sample, hp2)  #background
            continue

        Ld1, Brdf1 = calc_brdf(hp, ray)
        hp = isect(ray, shapes, 999999.0)
        if hp is None:
            hp2.spectrum = Ld1
            film.add_sample(sample, hp2)
            continue

        Ld2, Brdf2 = calc_brdf(hp, ray)
        hp = isect(ray, shapes, 999999.0)
        if hp is None:
            hp2.spectrum = Ld1 + Ld2.mix_spectrum(Brdf1)
            film.add_sample(sample, hp2)
            continue

        Ld3, Brdf3 = calc_brdf(hp, ray)
        spectrum = Ld3.mix_spectrum(Brdf2) + Ld2
        spectrum = spectrum.mix_spectrum(Brdf1) + Ld1
        hp.spectrum = spectrum
        film.add_sample(sample, hp)

    blt_float_img_to_window(0, 0, film.image, win)
    end = time.clock()
    global duration
    duration = duration + (end - start)
    print("Renderiranje jednog tile je trajalo", end - start, duration)
    return True
Exemplo n.º 10
0
def path_tracer(tile):
    sampler = ren.get_sampler()
    camera = ren.get_camera()
    film = ren.get_film()

    shapes = ren.isect_shapes()
    isect = renmas.shapes.isect #intersection rutine
    shade = renmas.core.shade

    background = renmas.core.Spectrum(0.00, 0.00, 0.00) 
    hp2 = renmas.shapes.HitPoint()
    hp3 = renmas.shapes.HitPoint()
    hp2.spectrum = background

    sample = renmas.samplers.Sample()
    x, y, width, height = tile
    sampler.tile(x, y, width, height)

    Lr = [] #reflection coefficient
    Ld = [] #direct light
    transmitance = 1.0
    cur_depth = 0
    max_depth = 4

    #current implementation stop tracing path when we hit emitter
    while True:
        sam = sampler.get_sample(sample)
        if sam is None: break 
        ray = camera.ray(sample)
        hp = isect(ray, shapes)

        if hp is None:
            film.add_sample(sample, hp2) #background
            continue 

        hp.wo = ray.dir * -1.0
        shade(hp)
        kr = hp.brdf * (1.0 / hp.pdf) * hp.ndotwi
        transmitance *= kr.r #FIXME take component that has maximum value
        Lr.append(kr)
        Ld.append(hp.spectrum)

        cur_depth = 1
        ray.dir = hp.wi #in wi is next direction
        ray.origin = hp.hit_point
        if hp.le.r > 0.01: #primiray ray hit emitter - stop path 
            hp.spectrum = hp.le
            film.add_sample(sample, hp) 
            Lr = [] 
            Ld = []
            transmitance = 1.0
            cur_depth = 0
            continue

        Le = renmas.core.Spectrum(0.00, 0.00, 0.00) 

        while True:
            if cur_depth == max_depth: break
            if transmitance < 0.0001: break
            hp = isect(ray, shapes)
            if hp is None: break
            hp.wo = ray.dir * -1.0
            shade(hp)
            if hp.le.r > 0.0001: 
                #Le = hp.le
                break #we hit emiter FIXME - we dont't have to stop think for better implementation !!!!
            kr = hp.brdf * (1.0 / hp.pdf) * hp.ndotwi
            Lr.append(kr)
            Ld.append(hp.spectrum)
            ray.dir = hp.wi #in wi is next direction
            ray.origin = hp.hit_point
            transmitance *= kr.r #FIXME take component that has maximum value 
            cur_depth += 1

        tmp_spec = Le
        for i in range(cur_depth):

            brdf = Lr.pop()
            ld = Ld.pop()
            tmp_spec = tmp_spec.mix_spectrum(brdf) + ld

        hp3.spectrum = tmp_spec 
        film.add_sample(sample, hp3) 
            
        Lr = [] 
        Ld = []
        transmitance = 1.0
        cur_depth = 0
Exemplo n.º 11
0
def raycast():
    sampler = ren.get_sampler()
    camera = ren.get_camera()
    film = ren.get_film()
    lst_lights = ren.lst_lights()

    shapes = ren.isect_shapes()
    isect = renmas.shapes.isect #intersection rutine
    shade = renmas.core.shade
    recursion_depth = 3

    background = renmas.core.Spectrum(0.00, 0.00, 0.00) 
    hp2 = renmas.shapes.HitPoint()
    hp2.spectrum = background

    tile = next_tile()
    if tile is None: 
        global image_saved
        if not image_saved:
            save_image(film, "Image5.png")
            print("Slika je spremljena")
            image_saved = True
        return None
    sample = renmas.samplers.Sample()
    x, y, width, height = tile
    sampler.tile(x, y, width, height)
    start = time.clock()
    
    while True:
        sam = sampler.get_sample(sample)
        if sam is None: break 
        ray = camera.ray(sample)
        hp = isect(ray, shapes, 999999.0)

        if hp is None:
            hp2.spectrum = background
            film.add_sample(sample, hp2) #background
            continue

        Ld1, Brdf1 = calc_brdf(hp, ray)
        hp = isect(ray, shapes, 999999.0)
        if hp is None:
            hp2.spectrum = Ld1 
            film.add_sample(sample, hp2) 
            continue

        Ld2, Brdf2 = calc_brdf(hp, ray)
        hp = isect(ray, shapes, 999999.0)
        if hp is None:
            hp2.spectrum = Ld1 + Ld2.mix_spectrum(Brdf1)
            film.add_sample(sample, hp2) 
            continue

        Ld3, Brdf3 = calc_brdf(hp, ray)
        spectrum = Ld3.mix_spectrum(Brdf2) + Ld2
        spectrum = spectrum.mix_spectrum(Brdf1) + Ld1
        hp.spectrum = spectrum 
        film.add_sample(sample, hp) 


    blt_float_img_to_window(0, 0, film.image, win)
    end = time.clock()
    global duration
    duration = duration + (end - start)
    print("Renderiranje jednog tile je trajalo", end - start, duration)
    return True