Esempio n. 1
0
    def test_sampler(self):
        sam = Sampler()
        sam.set_resolution(2, 2)
        sam.load('regular')
        sam.compile()
        runtimes = [Runtime()]
        sam.prepare(runtimes)

        code = """
sample = Sample()
r1 = generate_sample(sample)
p1 = sample.x
p2 = sample.y
p3 = sample.ix
p4 = sample.iy
        """

        p1 = FloatArg('p1', 566.6)
        p2 = FloatArg('p2', 566.6)

        p3 = IntArg('p3', 5655)
        p4 = IntArg('p4', 5655)
        r1 = IntArg('r1', 5655)
        args = [p1, p2, p3, p4, r1]
        shader = Shader(code=code, args=args)
        shader.compile([sam.shader])
        shader.prepare(runtimes)

        shader.execute()
        self._check_result(shader, -0.5, -0.5, 0, 0, 1)
        shader.execute()
        self._check_result(shader, 0.5, -0.5, 1, 0, 1)
        shader.execute()
        self._check_result(shader, -0.5, 0.5, 0, 1, 1)
        shader.execute()
        self._check_result(shader, 0.5, 0.5, 1, 1, 1)
        shader.execute()
        ret = shader.get_value('r1')
        self.assertEqual(ret, 0)
Esempio n. 2
0
from renlight.vector import Vector3
from renlight.renderer.sampler import Sampler
from renlight.renderer.camera import Camera
from renlight.renderer.integrator import Integrator
from renlight.renderer.sphere import Sphere
from renlight.renderer.linear import LinearIsect
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)