コード例 #1
0
ファイル: fps_chart.py プロジェクト: croxis/SpaceDrive
    def _late_init(self, task):
        """ Gets called after the pipeline was initialized """
        self._display_txt = Text(
            text="40 ms", parent=self._node, x=20, y=25,
            size=13, color=Vec3(1), may_change=True)
        self._display_txt_bottom = Text(
            text="0 ms", parent=self._node, x=20, y=120,
            size=13, color=Vec3(1), may_change=True)


        # Create the shader which generates the visualization texture
        self._cshader_node = ComputeNode("FPSChartUpdateChart")
        self._cshader_node.add_dispatch(250 // 10, 120 // 4, 1)
        self._cshader_np = self._node.attach_new_node(self._cshader_node)

        self._cshader = RPLoader.load_shader("/$$rp/shader/fps_chart.compute.glsl")
        self._cshader_np.set_shader(self._cshader)
        self._cshader_np.set_shader_input("DestTex", self._display_tex)
        self._cshader_np.set_shader_input("FPSValues", self._storage_buffer)
        self._cshader_np.set_shader_input("index", self._store_index)
        self._cshader_np.set_shader_input("maxMs", self._chart_ms_max)

        self._update_shader_node = ComputeNode("FPSChartUpdateValues")
        self._update_shader_node.add_dispatch(1, 1, 1)
        self._update_shader_np = self._node.attach_new_node(self._update_shader_node)
        self._ushader = RPLoader.load_shader("/$$rp/shader/fps_chart_update.compute.glsl")
        self._update_shader_np.set_shader(self._ushader)
        self._update_shader_np.set_shader_input("DestTex", self._storage_buffer)
        self._update_shader_np.set_shader_input("index", self._store_index)
        self._update_shader_np.set_shader_input("currentData", self._current_ftime)

        Globals.base.addTask(self._update, "UpdateFPSChart", sort=-50)

        return task.done
コード例 #2
0
 def _late_init(self, task):
     """ Gets called after the pipeline got initialized """
     scene_tex = self._pipeline.stage_mgr.pipes["ShadedScene"]
     self._zoomer.set_shader(RPLoader.load_shader(
         "/$$rp/shader/default_gui_shader.vert.glsl",
         "/$$rp/shader/pixel_inspector.frag.glsl"))
     self._zoomer.set_shader_input("SceneTex", scene_tex)
     return task.done
コード例 #3
0
 def _late_init(self, task):
     """ Gets called after the pipeline got initialized """
     scene_tex = self._pipeline.stage_mgr.pipes["ShadedScene"]
     self._zoomer.set_shader(
         RPLoader.load_shader("/$$rp/shader/default_gui_shader.vert.glsl",
                              "/$$rp/shader/pixel_inspector.frag.glsl"))
     self._zoomer.set_shader_input("SceneTex", scene_tex)
     return task.done
コード例 #4
0
ファイル: fps_chart.py プロジェクト: mayudong/RenderPipeline
    def _late_init(self, task):
        """ Gets called after the pipeline was initialized """
        self._display_txt = Text(text="40 ms",
                                 parent=self._node,
                                 x=20,
                                 y=25,
                                 size=13,
                                 color=Vec3(1),
                                 may_change=True)
        self._display_txt_bottom = Text(text="0 ms",
                                        parent=self._node,
                                        x=20,
                                        y=120,
                                        size=13,
                                        color=Vec3(1),
                                        may_change=True)

        # Create the shader which generates the visualization texture
        self._cshader_node = ComputeNode("FPSChartUpdateChart")
        self._cshader_node.add_dispatch(250 // 10, 120 // 4, 1)
        self._cshader_np = self._node.attach_new_node(self._cshader_node)

        self._cshader = RPLoader.load_shader(
            "/$$rp/shader/fps_chart.compute.glsl")
        self._cshader_np.set_shader(self._cshader)
        self._cshader_np.set_shader_input("DestTex", self._display_tex)
        self._cshader_np.set_shader_input("FPSValues", self._storage_buffer)
        self._cshader_np.set_shader_input("index", self._store_index)
        self._cshader_np.set_shader_input("maxMs", self._chart_ms_max)

        self._update_shader_node = ComputeNode("FPSChartUpdateValues")
        self._update_shader_node.add_dispatch(1, 1, 1)
        self._update_shader_np = self._node.attach_new_node(
            self._update_shader_node)
        self._ushader = RPLoader.load_shader(
            "/$$rp/shader/fps_chart_update.compute.glsl")
        self._update_shader_np.set_shader(self._ushader)
        self._update_shader_np.set_shader_input("DestTex",
                                                self._storage_buffer)
        self._update_shader_np.set_shader_input("index", self._store_index)
        self._update_shader_np.set_shader_input("currentData",
                                                self._current_ftime)

        Globals.base.addTask(self._update, "UpdateFPSChart", sort=-50)

        return task.done
コード例 #5
0
 def create_shaders(self):
     """ Creates all the shaders used for precomputing """
     self.shaders = {}
     resource_path = self.handle.get_shader_resource("eric_bruneton")
     for fname in listdir(resource_path):
         fpath = join(resource_path, fname)
         if isfile(fpath) and fname.endswith(".compute.glsl"):
             shader_name = fname.split(".")[0]
             shader_obj = RPLoader.load_shader(fpath)
             self.shaders[shader_name] = shader_obj
コード例 #6
0
 def create_shaders(self):
     """ Creates all the shaders used for precomputing """
     self.shaders = {}
     resource_path = self.handle.get_shader_resource("eric_bruneton")
     for fname in listdir(resource_path):
         fpath = join(resource_path, fname)
         if isfile(fpath) and fname.endswith(".compute.glsl"):
             shader_name = fname.split(".")[0]
             shader_obj = RPLoader.load_shader(fpath)
             self.shaders[shader_name] = shader_obj
コード例 #7
0
 def create_shaders(self):
     """ Creates all the shaders used for precomputing """
     self.shaders = {}
     for i in files('render-pipeline'):
         if len(i.parts) == 5 and '/'.join(
                 i.parts[:4]
         ) == 'rpplugins/scattering/shader/eric_bruneton':
             fname = i.parts[4]
             if fname.endswith('.compute.glsl'):
                 shader_name = fname.split(".")[0]
                 shader_obj = RPLoader.load_shader('/'.join(i.parts))
                 self.shaders[shader_name] = shader_obj
コード例 #8
0
ファイル: effect.py プロジェクト: jakogut/RenderPipeline
    def do_load(self, filename):
        """ Internal method to load the effect from the given filename, do
        not use this directly, instead use load(). """
        self.filename = filename
        self.effect_name = self._convert_filename_to_name(filename)
        self.effect_hash = self._generate_hash(filename, self._options)

        # Load the YAML file
        parsed_yaml = load_yaml_file(filename) or {}
        self._parse_content(parsed_yaml)

        # Construct a shader object for each pass
        for pass_id in self._PASSES:
            vertex_src = self._generated_shader_paths["vertex-" + pass_id]
            fragment_src = self._generated_shader_paths["fragment-" + pass_id]
            self._shader_objs[pass_id] = RPLoader.load_shader(vertex_src, fragment_src)
        return True
コード例 #9
0
    def do_load(self, filename):
        """ Internal method to load the effect from the given filename, do
        not use this directly, instead use load(). """
        self.filename = filename
        self.effect_name = self._convert_filename_to_name(filename)
        self.effect_hash = self._generate_hash(filename, self._options)

        # Load the YAML file
        parsed_yaml = load_yaml_file(filename) or {}
        self._parse_content(parsed_yaml)

        # Construct a shader object for each pass
        for pass_id in self._PASSES:
            vertex_src = self._generated_shader_paths["vertex-" + pass_id]
            fragment_src = self._generated_shader_paths["fragment-" + pass_id]
            self._shader_objs[pass_id] = RPLoader.load_shader(
                vertex_src, fragment_src)
        return True
コード例 #10
0
ファイル: exposure_widget.py プロジェクト: croxis/SpaceDrive
    def _late_init(self, task):
        """ Gets called after the pipeline initialized, this extracts the
        exposure texture from the stage manager """
        stage_mgr = self._pipeline.stage_mgr

        if "Exposure" not in stage_mgr.pipes:
            self.debug("Disabling exposure widget, could not find the exposure data.")
            self._node.remove_node()
            return

        self._node.show()

        exposure_tex = stage_mgr.pipes["Exposure"]
        self._cshader = RPLoader.load_shader("/$$rp/shader/visualize_exposure.compute.glsl")
        self._cshader_np.set_shader(self._cshader)
        self._cshader_np.set_shader_input("DestTex", self._storage_tex)
        self._cshader_np.set_shader_input("ExposureTex", exposure_tex)

        return task.done
コード例 #11
0
    def _late_init(self, task):
        """ Gets called after the pipeline initialized, this extracts the
        exposure texture from the stage manager """
        stage_mgr = self._pipeline.stage_mgr

        if "Exposure" not in stage_mgr.pipes:
            self.debug("Disabling exposure widget, could not find the exposure data.")
            self._node.remove_node()
            return

        self._node.show()

        exposure_tex = stage_mgr.pipes["Exposure"]
        self._cshader = RPLoader.load_shader("/$$rp/shader/visualize_exposure.compute.glsl")
        self._cshader_np.set_shader(self._cshader)
        self._cshader_np.set_shader_input("DestTex", self._storage_tex)
        self._cshader_np.set_shader_input("ExposureTex", exposure_tex)

        return task.done
コード例 #12
0
    def build(cls, texture, view_width, view_height):
        """ Builds a shader to display <texture> in a view port with the size
        <view_width> * <view_height> """
        view_width, view_height = int(view_width), int(view_height)

        cache_key = "/$$rptemp/$$TEXDISPLAY-X{}-Y{}-Z{}-TT{}-CT{}-VW{}-VH{}.frag.glsl".format(
            texture.get_x_size(), texture.get_y_size(), texture.get_z_size(),
            texture.get_texture_type(), texture.get_component_type(),
            view_width, view_height)

        # Only regenerate the file when there is no cache entry for it
        if not isfile(cache_key) or True:
            fragment_shader = cls._build_fragment_shader(
                texture, view_width, view_height)

            with open(cache_key, "w") as handle:
                handle.write(fragment_shader)

        return RPLoader.load_shader(
            "/$$rp/shader/default_gui_shader.vert.glsl", cache_key)
コード例 #13
0
    def _get_shader_handle(self, path, *args):
        """ Returns a handle to a Shader object, containing all sources passed
        as arguments. The path argument will be used to locate shaders if no
        absolute path is given. This is the internal method used in load_shader
        and load_plugin_shader. """
        assert len(args) > 0 and len(args) <= 3
        path_args = []

        for source in args:
            for prefix in ("/$$rpconfig", "/$$rp/shader", "/$$rptemp"):
                if prefix in source:
                    path_args.append(source)
                    break
            else:
                path_args.append(path.format(source))

        # If only one shader is specified, assume its a postprocess fragment shader,
        # and use the default vertex shader
        if len(args) == 1:
            path_args = ["/$$rp/shader/default_post_process.vert.glsl"] + path_args
        return RPLoader.load_shader(*path_args)
コード例 #14
0
    def build(cls, texture, view_width, view_height):
        """ Builds a shader to display <texture> in a view port with the size
        <view_width> * <view_height> """
        view_width, view_height = int(view_width), int(view_height)

        cache_key = "/$$rptemp/$$TEXDISPLAY-X{}-Y{}-Z{}-TT{}-CT{}-VW{}-VH{}.frag.glsl".format(
            texture.get_x_size(),
            texture.get_y_size(),
            texture.get_z_size(),
            texture.get_texture_type(),
            texture.get_component_type(),
            view_width,
            view_height)

        # Only regenerate the file when there is no cache entry for it
        if not isfile(cache_key) or True:
            fragment_shader = cls._build_fragment_shader(texture, view_width, view_height)

            with open(cache_key, "w") as handle:
                handle.write(fragment_shader)

        return RPLoader.load_shader("/$$rp/shader/default_gui_shader.vert.glsl", cache_key)
コード例 #15
0
 def reload_shaders(self):
     """ Reloads the command shader """
     shader = RPLoader.load_shader(
         "/$$rp/shader/default_post_process.vert.glsl",
         "/$$rp/shader/process_command_queue.frag.glsl")
     self._command_target.shader = shader
コード例 #16
0
 def reload_shaders(self):
     """ Reloads the command shader """
     shader = RPLoader.load_shader(
         "/$$rp/shader/default_post_process.vert.glsl",
         "/$$rp/shader/process_command_queue.frag.glsl")
     self._command_target.shader = shader