示例#1
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
示例#2
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
示例#3
0
import renmas3.core
from renmas3.core import DirectLighting, Factory, ShadePoint
from renmas3.win32 import show_image_in_window

start = time.clock()
ren = renmas3.core.Renderer()
irender = renmas3.core.IRender(ren)
end = time.clock()
print(end-start)

filename = 'I:\\GitRENMAS\\tests3\\renderer\\sphere1.py'
filename = 'E:\\GitRENMAS\\renmas\\tests3\\renderer\\sphere1.py'

exec(compile(open(filename).read(), filename, 'exec'), dict(locals()), dict(globals()))

factory = Factory()
light = factory.create_light(mgr=ren.color_mgr, typ='point', source='A',\
        position=(9,10,9), direction=(2,2,2))

ren.add('point_light1', light)
ren.prepare()

direct_lighting = DirectLighting(ren)
sp = factory.shade_point(hit=(5,5,5))
sp.material = 0

ret = direct_lighting.estimate_direct(sp)
runtime = Runtime()
direct_lighting.estimate_direct_asm([runtime], 'estimate_dir')
print(ret)
示例#4
0
from random import random

from tdasm import Runtime
from renmas3.core import Renderer, ShapeManager, Factory, Ray, ShadePoint

factory = Factory()


def random_sphere():
    origin = (random(), random(), random())
    return factory.sphere(origin, random())


def random_ray():
    origin = (random(), random(), random())
    direction = (random(), random(), random())
    return factory.ray(origin, direction)


def ray_ds(ds, ray, name):
    ds[name + ".origin"] = ray.origin.to_ds()
    ds[name + ".dir"] = ray.dir.to_ds()


ren = Renderer()
mgr = ShapeManager(ren)
mgr.add('sphere1', random_sphere())
mgr.add('sphere2', random_sphere())
mgr.add('sphere3', random_sphere())
mgr.prepare()
示例#5
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
"""