Example #1
0
    def __init__(self, grid_processor: GridProcessor):
        Renderer.__init__(self)
        self.grid_processor: GridProcessor = grid_processor

        shader_settings: List[ShaderSetting] = []
        shader_settings.extend([ShaderSetting("grid_point", ["grid/grid.vert", "basic/discard_screen_color.frag"],
                                              ["screen_width", "screen_height"]),
                                ShaderSetting("grid_cube", ["grid/grid_impostor.vert", "basic/screen_color.frag",
                                                            "grid/point_to_cube_impostor.geom"],
                                              ["screen_width", "screen_height"])
                                ])
        self.set_shader(shader_settings)

        self.data_handler: OverflowingVertexDataHandler = OverflowingVertexDataHandler(
            [], [(self.grid_processor.grid_position_buffer, 0), (self.grid_processor.grid_density_buffer, 1)])

        def generate_element_count_func(gp: GridProcessor) -> Callable:
            buffered_gp: GridProcessor = gp

            def element_count_func(buffer: int):
                return buffered_gp.grid_density_buffer.get_objects() - buffered_gp.grid_slice_size

            return element_count_func

        self.render_funcs["grid_point"] = generate_render_function(OGLRenderFunction.ARRAYS, GL_POINTS, 10.0,
                                                                   depth_test=True)
        self.render_funcs["grid_cube"] = generate_render_function(OGLRenderFunction.ARRAYS, GL_POINTS,
                                                                  depth_test=True)
        self.element_count_funcs["grid_point"] = generate_element_count_func(grid_processor)
        self.element_count_funcs["grid_cube"] = generate_element_count_func(grid_processor)

        self.create_sets(self.data_handler)
Example #2
0
    def __init__(self, node_processor: NodeProcessor, grid: Grid):
        Renderer.__init__(self)
        self.node_processor = node_processor
        self.grid = grid

        shader_settings: List[ShaderSetting] = []
        shader_settings.extend([ShaderSetting("node_point", ["node/sample.vert", "basic/discard_screen_color.frag"],
                                              ["screen_width", "screen_height"]),
                                ShaderSetting("node_sphere",
                                              ["node/sample_impostor.vert", "node/point_to_sphere_impostor_phong.frag",
                                               "node/point_to_sphere_impostor.geom"],
                                              ["node_object_radius", "node_importance_threshold"]),
                                ShaderSetting("node_transparent_sphere", ["node/sample_impostor.vert",
                                                                          "node/point_to_sphere_impostor_transparent.frag",
                                                                          "node/point_to_sphere_impostor.geom"],
                                              ["node_object_radius", "node_base_opacity", "node_importance_opacity",
                                               "node_depth_opacity",
                                               "node_opacity_exponent", "node_importance_threshold"])
                                ])
        self.set_shader(shader_settings)

        self.data_handler: VertexDataHandler = VertexDataHandler([(self.node_processor.node_buffer, 0)])

        def generate_element_count_func(np: NodeProcessor) -> Callable:
            buffered_np: NodeProcessor = np

            def element_count_func():
                return buffered_np.get_buffer_points()

            return element_count_func

        self.render_funcs["node_point"] = generate_render_function(OGLRenderFunction.ARRAYS, GL_POINTS, 10.0,
                                                                   depth_test=True)
        self.render_funcs["node_sphere"] = generate_render_function(OGLRenderFunction.ARRAYS, GL_POINTS,
                                                                    depth_test=True)
        self.render_funcs["node_transparent_sphere"] = generate_render_function(OGLRenderFunction.ARRAYS, GL_POINTS,
                                                                                add_blending=True)
        self.element_count_funcs["node_point"] = generate_element_count_func(node_processor)
        self.element_count_funcs["node_sphere"] = generate_element_count_func(node_processor)
        self.element_count_funcs["node_transparent_sphere"] = generate_element_count_func(node_processor)

        self.create_sets(self.data_handler)
Example #3
0
    def __init__(self, edge_processor: EdgeProcessor, grid: Grid):
        Renderer.__init__(self)
        self.edge_processor = edge_processor
        self.grid = grid

        shader_settings: List[ShaderSetting] = []
        shader_settings.extend(
            [ShaderSetting("sample_point", ["sample/sample.vert", "basic/discard_screen_color.frag"],
                           ["edge_importance_threshold", "screen_width", "screen_height"]),
             ShaderSetting("sample_line",
                           ["sample/sample_impostor.vert", "basic/color.frag",
                            "sample/points_to_line.geom"],
                           ["edge_importance_threshold"]),
             ShaderSetting("sample_sphere", ["sample/sample_impostor.vert",
                                             "sample/point_to_sphere_impostor_phong.frag",
                                             "sample/point_to_sphere_impostor.geom"],
                           ["edge_object_radius", "edge_importance_threshold"]),
             ShaderSetting("sample_transparent_sphere", ["sample/sample_impostor.vert",
                                                         "sample/point_to_sphere_impostor_transparent.frag",
                                                         "sample/point_to_sphere_impostor.geom"],
                           ["edge_object_radius", "edge_base_opacity", "edge_importance_opacity", "edge_depth_opacity",
                            "edge_opacity_exponent", "edge_importance_threshold"]),
             ShaderSetting("sample_ellipsoid_transparent", ["sample/sample_impostor.vert",
                                                            "sample/points_to_ellipsoid_impostor_transparent.frag",
                                                            "sample/points_to_ellipsoid_impostor.geom"],
                           ["edge_object_radius", "edge_base_opacity", "edge_importance_opacity", "edge_depth_opacity",
                            "edge_opacity_exponent", "edge_importance_threshold"])
             ])
        self.set_shader(shader_settings)

        self.data_handler: LayeredVertexDataHandler = LayeredVertexDataHandler([[VertexDataHandler(
            [(self.edge_processor.sample_buffer[i][j], 0), (self.edge_processor.edge_buffer[i][j], 2)], []) for j in
            range(len(self.edge_processor.sample_buffer[i]))] for i in range(len(self.edge_processor.sample_buffer))])

        def generate_element_count_func(ep: EdgeProcessor) -> Callable:
            buffered_ep: EdgeProcessor = ep

            def element_count_func(layer: int, buffer: int):
                return buffered_ep.get_buffer_points(layer, buffer)

            return element_count_func

        self.render_funcs["sample_point"] = generate_render_function(OGLRenderFunction.ARRAYS_INSTANCED, GL_POINTS,
                                                                     10.0, depth_test=True)
        self.render_funcs["sample_line"] = generate_render_function(OGLRenderFunction.ARRAYS_INSTANCED, GL_POINTS,
                                                                    line_width=2.0, depth_test=True)
        self.render_funcs["sample_sphere"] = generate_render_function(OGLRenderFunction.ARRAYS_INSTANCED, GL_POINTS,
                                                                      depth_test=True)
        self.render_funcs["sample_transparent_sphere"] = generate_render_function(OGLRenderFunction.ARRAYS_INSTANCED,
                                                                                  GL_POINTS, add_blending=True)
        self.render_funcs["sample_ellipsoid_transparent"] = generate_render_function(OGLRenderFunction.ARRAYS_INSTANCED,
                                                                                     GL_POINTS, add_blending=True)
        self.element_count_funcs["sample_point"] = generate_element_count_func(edge_processor)
        self.element_count_funcs["sample_line"] = generate_element_count_func(edge_processor)
        self.element_count_funcs["sample_sphere"] = generate_element_count_func(edge_processor)
        self.element_count_funcs["sample_transparent_sphere"] = generate_element_count_func(edge_processor)
        self.element_count_funcs["sample_ellipsoid_transparent"] = generate_element_count_func(edge_processor)

        self.create_sets(self.data_handler)

        self.importance_threshold: float = 0.0