Ejemplo n.º 1
0
    def test_cameras(self):
        eye = Vector3(0.0, 10.0, 5.0)
        lookat = Vector3(0.0, 0.0, 0.0)
        distance = 100.0

        cam = Camera(eye, lookat, distance)
        cam.load('pinhole')
        cam.compile()
        runtimes = [Runtime()]
        cam.prepare(runtimes)

        code = """
ray = Ray()
sample = Sample()
sample.x = 2.2
sample.y = 2.5
generate_ray(ray, sample)
origin = ray.origin
direction = ray.direction
        """
        origin = Vec3Arg('origin', Vector3(0.0, 0.0, 0.0))
        direction = Vec3Arg('direction', Vector3(0.0, 0.0, 0.0))
        args = [origin, direction]
        shader = Shader(code=code, args=args)
        shader.compile([cam.shader])
        shader.prepare(runtimes)
        shader.execute()

        ray = Ray(Vector3(0.0, 0.0, 0.0), Vector3(0.0, 0.0, 0.0))
        sample = Sample(2.2, 2.5, 2, 2, 1.0)
        cam.execute_py(ray, sample)

        v = shader.get_value('origin')
        o = ray.origin
        self.assertAlmostEqual(v.x, o.x)
        self.assertAlmostEqual(v.y, o.y)
        self.assertAlmostEqual(v.z, o.z)

        v = shader.get_value('direction')
        d = ray.direction
        self.assertAlmostEqual(v.x, d.x)
        self.assertAlmostEqual(v.y, d.y)
        self.assertAlmostEqual(v.z, d.z)
Ejemplo n.º 2
0
from renlight.renderer.shp_mgr import ShapeManager
from renlight.image import ImagePRGBA, ImageRGBA
from renlight.renderer.blt_floatrgba import blt_prgba_to_rgba
from renlight.win import show_image_in_window

if __name__ == "__main__":

    runtimes = [Runtime()]
    sampler = Sampler()
    sampler.set_resolution(1024, 768)
    sampler.load('regular')

    eye = Vector3(0.0, 10.0, 5.0)
    lookat = Vector3(0.0, 0.0, 0.0)
    distance = 100.0
    camera = Camera(eye, lookat, distance)
    camera.load('pinhole')

    #intersection
    mgr = ShapeManager()
    sphere = Sphere(Vector3(0.0, 0.0, 0.0), 2.0, 0)
    mgr.add('sph1', sphere)

    isector = LinearIsect(mgr)
    isector.compile()
    isector.prepare(runtimes)

    ###################

    integrator = Integrator()
    integrator.load('isect_shader')