Example #1
0
def render(filename, output=None, integrator=None, tmo=True):
    ren = Renderer()
    if integrator is not None:
        ren.integrator.load(integrator, ren.sam_mgr, ren.spectral)
    print("Begin of loading %s" % filename)
    start = time.clock()
    ren.load(filename)
    elapsed = time.clock() - start
    print("Loading scene took %f seconds" % elapsed)

    print("Begin preparing scene for rendering")
    start = time.clock()
    ren.prepare()
    elapsed = time.clock() - start
    print("Preparation of scene took %f seconds" % elapsed)

    total_time = 0.0
    iteration = 0
    while True:
        start = time.clock()
        ret = ren.render()
        elapsed = time.clock() - start
        total_time += elapsed
        iteration += 1
        print("Rendering of iteration %i took %f seconds" % (iteration, elapsed))
        if ret:  # We finished rendering all samples 
            break;
    print("Total rendering time took %f seconds." % total_time)

    if output is None:
        output = os.path.join(os.path.dirname(filename), 'Unknown.jpeg')

    name, ext = os.path.splitext(output)

    hdr_output = os.path.join(os.path.dirname(filename), 'Unknown.exr')
    save_image(hdr_output, ren._hdr_buffer)

    if ext in ('.rgbe', '.exr'):
        save_image(output, ren._hdr_buffer)
    else:
        width, height = ren._hdr_buffer.size()
        new_img = ImageRGBA(width, height)
        if tmo:
            print("Tone mapping is in progress!")
            start = time.clock()
            ren.tmo()
            elapsed = time.clock() - start
            print("Tone mapping took %f seconds!" % elapsed)
            blt_prgba_to_rgba(ren._hdr_output, new_img)
        else:
            blt_prgba_to_rgba(ren._hdr_buffer, new_img)
        save_image(output, new_img)
Example #2
0
 def save_image(self, objects, args):
     fname, id_img = args.split(',')
     image = objects[id_img]
     if isinstance(image, ImagePRGBA):
         width, height = image.size()
         new_img = ImageRGBA(width, height)
         blt_prgba_to_rgba(image, new_img)
         save_image(fname, new_img)
     elif isinstance(image, ImageRGBA):
         save_image(fname, image)
     elif isinstance(image, ImageBGRA):
         new_img = image.to_rgba()
         save_image(fname, new_img)
     return ""
Example #3
0
 def save_image(self, objects, args):
     fname, id_img = args.split(',')
     image = objects[id_img]
     if isinstance(image, ImagePRGBA):
         width, height = image.size()
         new_img = ImageRGBA(width, height)
         blt_prgba_to_rgba(image, new_img)
         save_image(fname, new_img)
     elif isinstance(image, ImageRGBA):
         save_image(fname, image)
     elif isinstance(image, ImageBGRA):
         new_img = image.to_rgba()
         save_image(fname, new_img)
     return ""
Example #4
0
from sdl.blt_floatrgba import blt_prgba_to_rgba, ImageRGBA
from imldr import save_image
from renlgt import Renderer

ren = Renderer()
# ren.load('sphere1.txt')
ren.load("triangle1.txt")
ren.prepare()

ren.render()
ren.tmo()

width, height = ren._hdr_buffer.size()
new_img = ImageRGBA(width, height)
# blt_prgba_to_rgba(ren._hdr_buffer, new_img)
blt_prgba_to_rgba(ren._hdr_output, new_img)

save_image("render1.jpeg", new_img)
Example #5
0
import time
from sdl import ImagePRGBA, ImageRGBA
from sdl.blt_floatrgba import blt_prgba_to_rgba
from imldr import load_image, save_image
from hdr import Tmo
from win import show_image_in_window

tm = Tmo()
tm.load('exp')

in_img = load_image('E:/hdr_images/Desk_oBA2.hdr')
w, h = in_img.size()
out_img = ImagePRGBA(w, h)

start = time.clock()
tm.tmo(in_img, out_img)
end = time.clock()
print("Tone mapping took %f\n" % (end - start))

output = ImageRGBA(w, h)
blt_prgba_to_rgba(out_img, output)

show_image_in_window(output, fliped=True)
Example #6
0
from sdl.blt_floatrgba import blt_prgba_to_rgba, ImageRGBA
from imldr import save_image
from renlgt import Renderer

ren = Renderer()
#ren.load('sphere1.txt')
ren.load('triangle1.txt')
ren.prepare()

ren.render()
ren.tmo()

width, height = ren._hdr_buffer.size()
new_img = ImageRGBA(width, height)
#blt_prgba_to_rgba(ren._hdr_buffer, new_img)
blt_prgba_to_rgba(ren._hdr_output, new_img)

save_image("render1.jpeg", new_img)