def test_importor_sample(self):
        scene = example.cornell_box

        render = ims.importer_sample(ctx.Context())
        input_xy, output_color = render.drive_raycasting(scene)

        writer = sw.NormalizedWriter(ctx.Context())
        writer.write(input_xy, output_color, 'output_test1.jpg')
    def test_simple_render(self):
        
        scene = example.cornell_box

        render = raycasting.SimpleReverseRayCasting(ctx.Context())
        input_xy, output_color = render.drive_raycasting(scene)
        
        writer = sw.NormalizedWriter(ctx.Context())
        writer.write(input_xy, output_color, 'output_test.jpg')
Exemple #3
0
    def test_ctx(self):
        c = ctx.Context()
        c.color_mode = 'unknown_mode'
        with self.assertRaises(ValueError):
            c.integration_test()

        c = ctx.Context()
        c.writer_output_device = 'unknown_device_type'
        with self.assertRaises(ValueError):
            c.integration_test()

        c = ctx.Context()
        c.writer_color_mode = 'unknown_mode'
        with self.assertRaises(ValueError):
            c.integration_test()
Exemple #4
0
    def test_normalizedwriter(self):
        sample_size = 100
        input_xy = np.random.random((int(sample_size), 2)) * 2 - 1
        output_color = np.random.random((int(sample_size), 3))
        output_color[input_xy[:, 0] > input_xy[:, 1], :] = 0

        writer = sw.NormalizedWriter(ctx.Context())
        writer.write(input_xy, output_color, 'output_points.jpg')
Exemple #5
0
    def test_triangle(self):
        tctx = ctx.Context()
        if tctx.triangle_right_hand_norm:
            p1 = rp.Point3D(0, 0, 0)
            p2 = rp.Point3D(1, 0, 0)
            p3 = rp.Point3D(0, 1, 0)
        else:
            p1 = rp.Point3D(0, 0, 0)
            p2 = rp.Point3D(0, 1, 0)
            p3 = rp.Point3D(1, 0, 0)

        ttri = tri.Triangle(p1, p2, p3)

        self.assertTrue(ttri.verify())
Exemple #6
0
    def render(self):

        scene = make_shadow_cornell_box()

        myContext = ctx.Context()
        # myContext.raycasting_iteration = int(1e6)
        render = raycasting.SimpleReverseRayCasting(myContext)
        input_xy, output_color = render.drive_raycasting(scene)

        writer = sw.NormalizedWriter(myContext)
        writer.write(input_xy, output_color, 'output_test.jpg')


# if __name__ == "__main__":
#     test = STRRelaxRender()
#     test.render()
    def test_rasterize(self):
        p1 = rp.Point(0.5, 0.5, 0.5, None, color.Color.place_holder(),
                      rp.Vector.place_holder())

        p2 = rp.Point(0.0, 0.0, 0.0, None, color.Color.place_holder(),
                      rp.Vector.place_holder())

        p3 = rp.Point(0.5, 0.0, 0.5, None, color.Color.place_holder(),
                      rp.Vector.place_holder())

        tr1 = tri.Triangles()
        tr1.add_triangle(tri.Triangle(p1, p2, p3))

        ctx = context.Context()
        render = raster.SimpleRaster(ctx)
        render.rasterize(tr1)