Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    def on_pipeline_created(self):
        cloud_voxels = RPLoader.load_3d_texture(self.get_resource("slices/#.png"))
        cloud_voxels.set_wrap_w(SamplerState.WM_clamp)
        self.apply_stage.set_shader_input("CloudVoxels", cloud_voxels)

        noise_tex = RPLoader.load_texture(self.get_resource("noise.png"))
        noise_tex.set_minfilter(SamplerState.FT_linear_mipmap_linear)
        self.apply_stage.set_shader_input("NoiseTex", noise_tex)
    def __init__(self,
                 parent=None,
                 x=0,
                 y=0,
                 callback=None,
                 extra_args=None,
                 radio=False,
                 expand_width=100,
                 checked=False,
                 enabled=True):
        RPObject.__init__(self)

        prefix = "checkbox" if not radio else "radiobox"

        if enabled:
            checked_img = RPLoader.load_texture("/$$rp/data/gui/" + prefix +
                                                "_checked.png")
            unchecked_img = RPLoader.load_texture("/$$rp/data/gui/" + prefix +
                                                  "_default.png")
        else:
            checked_img = RPLoader.load_texture("/$$rp/data/gui/" + prefix +
                                                "_disabled.png")
            unchecked_img = checked_img

        # Set near filter, otherwise textures look like crap
        for tex in [checked_img, unchecked_img]:
            tex.set_minfilter(SamplerState.FT_linear)
            tex.set_magfilter(SamplerState.FT_linear)
            tex.set_wrap_u(SamplerState.WM_clamp)
            tex.set_wrap_v(SamplerState.WM_clamp)
            tex.set_anisotropic_degree(0)

        self._node = DirectCheckBox(parent=parent,
                                    pos=(x + 11, 1, -y - 8),
                                    scale=(10 / 2.0, 1, 10 / 2.0),
                                    checkedImage=checked_img,
                                    uncheckedImage=unchecked_img,
                                    image=unchecked_img,
                                    extraArgs=extra_args,
                                    state=DGG.NORMAL,
                                    relief=DGG.FLAT,
                                    command=self._update_status)

        self._node["frameColor"] = (0, 0, 0, 0)
        self._node["frameSize"] = (-2.6, 2 + expand_width / 7.5, -2.35, 2.5)
        self._node.set_transparency(TransparencyAttrib.M_alpha)

        self._callback = callback
        self._extra_args = extra_args
        self._collection = None

        if checked:
            self.set_checked(True, False)
Ejemplo n.º 4
0
    def _load_textures(self):
        """ Loads all required textures """
        search_tex = RPLoader.load_texture(self.get_resource("search_tex.png"))
        area_tex = RPLoader.load_texture(self.get_resource("area_tex.png"))

        for tex in [search_tex, area_tex]:
            tex.set_minfilter(SamplerState.FT_linear)
            tex.set_magfilter(SamplerState.FT_linear)
            tex.set_wrap_u(SamplerState.WM_clamp)
            tex.set_wrap_v(SamplerState.WM_clamp)

        self._smaa_stage.area_tex = area_tex
        self._smaa_stage.search_tex = search_tex
Ejemplo n.º 5
0
    def _load_textures(self):
        """ Loads all required textures """
        search_tex = RPLoader.load_texture(self.get_resource("search_tex.png"))
        area_tex = RPLoader.load_texture(self.get_resource("area_tex.png"))

        for tex in [search_tex, area_tex]:
            tex.set_minfilter(SamplerState.FT_linear)
            tex.set_magfilter(SamplerState.FT_linear)
            tex.set_wrap_u(SamplerState.WM_clamp)
            tex.set_wrap_v(SamplerState.WM_clamp)

        self._smaa_stage.area_tex = area_tex
        self._smaa_stage.search_tex = search_tex
Ejemplo n.º 6
0
 def _load_skydome(self):
     """ Loads the skydome """
     skydome = RPLoader.load_texture(
         "/$$rp/data/builtin_models/skybox/skybox.txo")
     skydome.set_wrap_u(SamplerState.WM_clamp)
     skydome.set_wrap_v(SamplerState.WM_clamp)
     self._pipeline.stage_mgr.inputs["DefaultSkydome"] = skydome
Ejemplo n.º 7
0
    def __init__(self,
                 font="/$$rp/rpcore/data/font/Roboto-Bold.ttf",
                 pixel_size=16,
                 align="left",
                 pos=Vec2(0),
                 color=Vec3(1),
                 parent=None):
        """ Constructs a new text node, forwaring the parameters to the internal
        panda3d implementation """
        RPObject.__init__(self)
        self._node = TextNodeImpl('FTN')
        self._node.set_text("")
        self._node.set_align(getattr(TextNodeImpl, "A_" + align))
        self._node.set_text_color(color.x, color.y, color.z, 1)

        if parent is None:
            parent = Globals.base.aspect2d

        self._nodepath = parent.attach_new_node(self._node)
        self._nodepath.set_pos(pos.x, 0, pos.y)

        font = RPLoader.load_font(font)
        # font.set_outline(Vec4(0, 0, 0, 0.78), 1.6, 0.37)
        font.set_outline(Vec4(0, 0, 0, 1), 1.6, 0.37)
        font.set_scale_factor(1.0)
        font.set_texture_margin(int(pixel_size / 4.0 * 2.0))
        font.set_bg(Vec4(0, 0, 0, 0))
        self._node.set_font(font)
        self.set_pixel_size(pixel_size)
Ejemplo n.º 8
0
 def _load_fonts(self):
     """ Loads the default font used for rendering and assigns it to
     Globals.font for further usage """
     Globals.font = RPLoader.load_font("/$$rp/data/font/roboto-medium.ttf")
     Globals.font.set_pixels_per_unit(35)
     Globals.font.set_poly_margin(0.0)
     Globals.font.set_texture_margin(1)
Ejemplo n.º 9
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
Ejemplo n.º 10
0
 def _load_grain(self):
     grain_tex = RPLoader.load_texture("/$$rp/data/film_grain/grain.txo")
     grain_tex.set_minfilter(SamplerState.FT_linear)
     grain_tex.set_magfilter(SamplerState.FT_linear)
     grain_tex.set_wrap_u(SamplerState.WM_repeat)
     grain_tex.set_wrap_v(SamplerState.WM_repeat)
     grain_tex.set_anisotropic_degree(0)
     self._stage.set_shader_input("PrecomputedGrain", grain_tex)
Ejemplo n.º 11
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
Ejemplo n.º 12
0
    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
Ejemplo n.º 13
0
    def __init__(self,
                 image=None,
                 parent=None,
                 x=0,
                 y=0,
                 w=None,
                 h=None,
                 transparent=True,
                 near_filter=True,
                 any_filter=True):
        """ Creates a new image, taking (x,y) as topleft coordinates.

        When near_filter is set to true, a near filter will be set to the
        texture passed. This provides sharper images.

        When any_filter is set to false, the passed image won't be modified at
        all. This enables you to display existing textures, otherwise the
        texture would get a near filter in the 3D View, too. """

        RPObject.__init__(self)

        if not isinstance(image, Texture):
            if not isinstance(image, str):
                self.warn("Invalid argument to image parameter:", image)
                return
            image = RPLoader.load_texture(image)

            if w is None or h is None:
                w, h = image.get_x_size(), image.get_y_size()
        else:
            if w is None or h is None:
                w = 10
                h = 10

        self._width, self._height = w, h
        self._initial_pos = self._translate_pos(x, y)

        self.node = OnscreenImage(image=image,
                                  parent=parent,
                                  pos=self._initial_pos,
                                  scale=(self._width / 2.0, 1,
                                         self._height / 2.0))

        if transparent:
            self.node.set_transparency(TransparencyAttrib.M_alpha)

        tex = self.node.get_texture()

        # Apply a near filter, but only if the parent has no scale, otherwise
        # it will look weird
        if near_filter and any_filter and parent.get_sx() == 1.0:
            tex.set_minfilter(SamplerState.FT_nearest)
            tex.set_magfilter(SamplerState.FT_nearest)

        if any_filter:
            tex.set_anisotropic_degree(8)
            tex.set_wrap_u(SamplerState.WM_clamp)
            tex.set_wrap_v(SamplerState.WM_clamp)
Ejemplo n.º 14
0
 def _load_grain(self):
     grain_tex = RPLoader.load_texture(
         "/$$rp/data/film_grain/grain.txo")
     grain_tex.set_minfilter(SamplerState.FT_linear)
     grain_tex.set_magfilter(SamplerState.FT_linear)
     grain_tex.set_wrap_u(SamplerState.WM_repeat)
     grain_tex.set_wrap_v(SamplerState.WM_repeat)
     grain_tex.set_anisotropic_degree(0)
     self._stage.set_shader_input("PrecomputedGrain", grain_tex)
Ejemplo n.º 15
0
 def _load_fonts(self):
     """ Loads the default font used for rendering and assigns it to
     Globals.font for further usage """
     Globals.font = RPLoader.load_font("/$$rp/data/font/roboto-medium.ttf")
     Globals.font.set_pixels_per_unit(35)
     Globals.font.set_poly_margin(0.0)
     Globals.font.set_texture_margin(1)
     Globals.font.set_bg(Vec4(1, 1, 1, 0))
     Globals.font.set_fg(Vec4(1, 1, 1, 1))
Ejemplo n.º 16
0
 def _load_fonts(self):
     """ Loads the default font used for rendering and assigns it to
     Globals.font for further usage """
     font = RPLoader.load_font("/$$rp/data/font/Roboto-Medium.ttf")
     font.set_pixels_per_unit(35)
     font.set_poly_margin(0.0)
     font.set_texture_margin(1)
     font.set_bg(Vec4(1, 1, 1, 0))
     font.set_fg(Vec4(1, 1, 1, 1))
     Globals.font = font
 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
Ejemplo n.º 18
0
 def load_grain(self):
     """ Loads the precomputed film grain """
     grain_tex = RPLoader.load_texture(
         "/$$rp/rpcore/data/film_grain/grain.txo.pz")
     grain_tex.set_minfilter(SamplerState.FT_linear)
     grain_tex.set_magfilter(SamplerState.FT_linear)
     grain_tex.set_wrap_u(SamplerState.WM_repeat)
     grain_tex.set_wrap_v(SamplerState.WM_repeat)
     grain_tex.set_anisotropic_degree(0)
     self.stage.set_shader_input("PrecomputedGrain", grain_tex)
Ejemplo n.º 19
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
Ejemplo n.º 20
0
 def load_lut(self):
     """ Loads the color correction lookup table (LUT) """
     lut_path = self.get_resource(self.get_setting("color_lut"))
     lut = RPLoader.load_sliced_3d_texture(lut_path, 64)
     lut.set_wrap_u(SamplerState.WM_clamp)
     lut.set_wrap_v(SamplerState.WM_clamp)
     lut.set_wrap_w(SamplerState.WM_clamp)
     lut.set_minfilter(SamplerState.FT_linear)
     lut.set_magfilter(SamplerState.FT_linear)
     lut.set_anisotropic_degree(0)
     self.tonemapping_stage.set_shader_input("ColorLUT", lut)
Ejemplo n.º 21
0
 def _load_lut(self):
     """ Loads the color correction lookup table (LUT) """
     lut_path = self.get_resource(self.get_setting("color_lut"))
     lut = RPLoader.load_sliced_3d_texture(lut_path, 64)
     lut.set_wrap_u(SamplerState.WM_clamp)
     lut.set_wrap_v(SamplerState.WM_clamp)
     lut.set_wrap_w(SamplerState.WM_clamp)
     lut.set_minfilter(SamplerState.FT_linear)
     lut.set_magfilter(SamplerState.FT_linear)
     lut.set_anisotropic_degree(0)
     self._tonemapping_stage.set_shader_input("ColorLUT", lut)
Ejemplo n.º 22
0
 def _load_environment_cubemap(self):
     """ Loads the default cubemap used for the environment, which is used
     when no other environment data is available """
     envmap = RPLoader.load_cube_map(
         "/$$rp/data/default_cubemap/cubemap.txo", read_mipmaps=True)
     envmap.set_minfilter(SamplerState.FT_linear_mipmap_linear)
     # envmap.set_format(Image.F_rgba16)
     envmap.set_magfilter(SamplerState.FT_linear)
     envmap.set_wrap_u(SamplerState.WM_repeat)
     envmap.set_wrap_v(SamplerState.WM_repeat)
     envmap.set_wrap_w(SamplerState.WM_repeat)
     self._pipeline.stage_mgr.inputs["DefaultEnvmap"] = envmap
 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
Ejemplo n.º 24
0
 def _load_environment_cubemap(self):
     """ Loads the default cubemap used for the environment, which is used
     when no other environment data is available """
     envmap = RPLoader.load_cube_map(
         "/$$rp/data/default_cubemap/cubemap.txo", read_mipmaps=True)
     envmap.set_minfilter(SamplerState.FT_linear_mipmap_linear)
     # envmap.set_format(Image.F_rgba16)
     envmap.set_magfilter(SamplerState.FT_linear)
     envmap.set_wrap_u(SamplerState.WM_repeat)
     envmap.set_wrap_v(SamplerState.WM_repeat)
     envmap.set_wrap_w(SamplerState.WM_repeat)
     self._pipeline.stage_mgr.inputs["DefaultEnvmap"] = envmap
Ejemplo n.º 25
0
    def __init__(self, parent=None, x=0, y=0, callback=None, extra_args=None,
                 radio=False, expand_width=100, checked=False, enabled=True):
        RPObject.__init__(self)

        prefix = "checkbox" if not radio else "radiobox"

        if enabled:
            checked_img = RPLoader.load_texture(
                "/$$rp/data/gui/" + prefix + "_checked.png")
            unchecked_img = RPLoader.load_texture(
                "/$$rp/data/gui/" + prefix + "_default.png")
        else:
            checked_img = RPLoader.load_texture(
                "/$$rp/data/gui/" + prefix + "_disabled.png")
            unchecked_img = checked_img

        # Set near filter, otherwise textures look like crap
        for tex in [checked_img, unchecked_img]:
            tex.set_minfilter(SamplerState.FT_linear)
            tex.set_magfilter(SamplerState.FT_linear)
            tex.set_wrap_u(SamplerState.WM_clamp)
            tex.set_wrap_v(SamplerState.WM_clamp)
            tex.set_anisotropic_degree(0)

        self._node = DirectCheckBox(
            parent=parent, pos=(x + 11, 1, -y - 8), scale=(10 / 2.0, 1, 10 / 2.0),
            checkedImage=checked_img, uncheckedImage=unchecked_img,
            image=unchecked_img, extraArgs=extra_args, state=DGG.NORMAL,
            relief=DGG.FLAT, command=self._update_status)

        self._node["frameColor"] = (0, 0, 0, 0)
        self._node["frameSize"] = (-2.6, 2 + expand_width / 7.5, -2.35, 2.5)
        self._node.set_transparency(TransparencyAttrib.M_alpha)

        self._callback = callback
        self._extra_args = extra_args
        self._collection = None

        if checked:
            self.set_checked(True, False)
Ejemplo n.º 26
0
    def on_pipeline_created(self):
        # High-res noise
        noise1 = RPLoader.load_texture(self.get_resource("noise1-data.txo"))
        noise1.set_wrap_u(SamplerState.WM_repeat)
        noise1.set_wrap_v(SamplerState.WM_repeat)
        noise1.set_wrap_w(SamplerState.WM_repeat)
        noise1.set_minfilter(SamplerState.FT_linear_mipmap_linear)
        self.apply_stage.set_shader_input("Noise1", noise1)

        # Low-res noise
        noise2 = RPLoader.load_texture(self.get_resource("noise2-data.txo"))
        noise2.set_wrap_u(SamplerState.WM_repeat)
        noise2.set_wrap_v(SamplerState.WM_repeat)
        noise2.set_wrap_w(SamplerState.WM_repeat)
        noise2.set_minfilter(SamplerState.FT_linear_mipmap_linear)
        self.apply_stage.set_shader_input("Noise2", noise2)

        # Weather tex
        weather = RPLoader.load_texture(self.get_resource("weather_tex.png"))
        weather.set_wrap_u(SamplerState.WM_repeat)
        weather.set_wrap_v(SamplerState.WM_repeat)
        self.apply_stage.set_shader_input("WeatherTex", weather)
Ejemplo n.º 27
0
    def on_pipeline_created(self):
        # High-res noise
        noise1 = RPLoader.load_texture(self.get_resource("noise1-data.txo.pz"))
        noise1.set_wrap_u(SamplerState.WM_repeat)
        noise1.set_wrap_v(SamplerState.WM_repeat)
        noise1.set_wrap_w(SamplerState.WM_repeat)
        noise1.set_minfilter(SamplerState.FT_linear_mipmap_linear)
        self.apply_stage.set_shader_input("Noise1", noise1)

        # Low-res noise
        noise2 = RPLoader.load_texture(self.get_resource("noise2-data.txo.pz"))
        noise2.set_wrap_u(SamplerState.WM_repeat)
        noise2.set_wrap_v(SamplerState.WM_repeat)
        noise2.set_wrap_w(SamplerState.WM_repeat)
        noise2.set_minfilter(SamplerState.FT_linear_mipmap_linear)
        self.apply_stage.set_shader_input("Noise2", noise2)

        # Weather tex
        weather = RPLoader.load_texture(self.get_resource("weather_tex.png"))
        weather.set_wrap_u(SamplerState.WM_repeat)
        weather.set_wrap_v(SamplerState.WM_repeat)
        self.apply_stage.set_shader_input("WeatherTex", weather)
Ejemplo n.º 28
0
    def __init__(self, image=None, parent=None, x=0, y=0, w=None, h=None,
                 transparent=True, near_filter=True, any_filter=True):
        """ Creates a new image, taking (x,y) as topleft coordinates.

        When near_filter is set to true, a near filter will be set to the
        texture passed. This provides sharper images.

        When any_filter is set to false, the passed image won't be modified at
        all. This enables you to display existing textures, otherwise the
        texture would get a near filter in the 3D View, too. """

        RPObject.__init__(self)

        if not isinstance(image, Texture):
            if not isinstance(image, str):
                self.warn("Invalid argument to image parameter:", image)
                return
            image = RPLoader.load_texture(image)

            if w is None or h is None:
                w, h = image.get_x_size(), image.get_y_size()
        else:
            if w is None or h is None:
                w = 10
                h = 10

        self._width, self._height = w, h
        self._initial_pos = self._translate_pos(x, y)

        self.node = OnscreenImage(
            image=image, parent=parent, pos=self._initial_pos,
            scale=(self._width / 2.0, 1, self._height / 2.0))

        if transparent:
            self.node.set_transparency(TransparencyAttrib.M_alpha)

        tex = self.node.get_texture()

        # Apply a near filter, but only if the parent has no scale, otherwise
        # it will look weird
        if near_filter and any_filter and parent.get_sx() == 1.0:
            tex.set_minfilter(SamplerState.FT_nearest)
            tex.set_magfilter(SamplerState.FT_nearest)

        if any_filter:
            tex.set_anisotropic_degree(8)
            tex.set_wrap_u(SamplerState.WM_clamp)
            tex.set_wrap_v(SamplerState.WM_clamp)
Ejemplo n.º 29
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
Ejemplo n.º 30
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
Ejemplo n.º 31
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
Ejemplo n.º 32
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
    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)
Ejemplo n.º 34
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)
Ejemplo n.º 35
0
    def load(self):
        """ Loads the scattering method """
        lut_src = self.handle.get_resource(
            "hosek_wilkie_scattering/scattering_lut.txo")

        if not isfile(lut_src):
            self.error("Could not find precompiled LUT for the Hosek Wilkie "
                       "Scattering! Make sure you compiled the algorithm code!")
            return

        lut_tex = RPLoader.load_sliced_3d_texture(lut_src, 512, 128, 100)
        lut_tex.set_wrap_u(SamplerState.WM_repeat)
        lut_tex.set_wrap_v(SamplerState.WM_clamp)
        lut_tex.set_wrap_w(SamplerState.WM_clamp)
        lut_tex.set_minfilter(SamplerState.FT_linear)
        lut_tex.set_magfilter(SamplerState.FT_linear)

        # Setting the format explicitely shouldn't be necessary
        # lut_tex.set_format(Image.F_rgb16)

        self.handle.display_stage.set_shader_input("ScatteringLUT", lut_tex)
        self.handle.envmap_stage.set_shader_input("ScatteringLUT", lut_tex)
Ejemplo n.º 36
0
    def load(self):
        """ Loads the scattering method """
        lut_src = self.handle.get_resource(
            "HosekWilkieScattering/scattering_luit.png")

        if not isfile(lut_src):
            self.error("Could not find precompiled LUT for the Hosek Wilkie "
                       "Scattering! Make sure you compiled the algorithm code!")
            return

        lut_tex = RPLoader.load_sliced_3d_texture(lut_src, 512, 128, 100)
        lut_tex.set_wrap_u(SamplerState.WM_repeat)
        lut_tex.set_wrap_v(SamplerState.WM_clamp)
        lut_tex.set_wrap_w(SamplerState.WM_clamp)
        lut_tex.set_minfilter(SamplerState.FT_linear)
        lut_tex.set_magfilter(SamplerState.FT_linear)

        # Setting the format explicitely shouldn't be necessary
        # lut_tex.set_format(Image.F_rgb16)

        self.handle.display_stage.set_shader_input("ScatteringLUT", lut_tex)
        self.handle.envmap_stage.set_shader_input("ScatteringLUT", lut_tex)
    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)
Ejemplo n.º 38
0
    def __init__(self, font="/$$rp/data/font/roboto-bold.ttf", pixel_size=16, align="left",
                 pos=Vec2(0), color=Vec3(1), parent=None):
        """ Constructs a new text node, forwaring the parameters to the internal
        panda3d implementation """
        RPObject.__init__(self)
        self._node = TextNodeImpl('FTN')
        self._node.set_text("")
        self._node.set_align(getattr(TextNodeImpl, "A_" + align))
        self._node.set_text_color(color.x, color.y, color.z, 1)

        if parent is None:
            parent = Globals.base.aspect2d

        self._nodepath = parent.attach_new_node(self._node)
        self._nodepath.set_pos(pos.x, 0, pos.y)

        font = RPLoader.load_font(font)
        font.set_outline(Vec4(0, 0, 0, 0.78), 1.6, 0.37)
        font.set_scale_factor(1.0)
        font.set_texture_margin(int(pixel_size / 4.0 * 2.0))
        font.set_bg(Vec4(0, 0, 0, 0))
        self._node.set_font(font)
        self.set_pixel_size(pixel_size)
Ejemplo n.º 39
0
 def on_pipeline_created(self):
     dirt_tex = RPLoader.load_texture(self.get_resource("lens_dirt.txo"))
     self._bloom_stage.set_shader_input("LensDirtTex", dirt_tex)
Ejemplo n.º 40
0
 def load_default_skybox(self):
     skybox = RPLoader.load_model("/$$rp/data/builtin_models/skybox/skybox.bam")
     return skybox
Ejemplo n.º 41
0
 def _load_skydome(self):
     """ Loads the skydome """
     skydome = RPLoader.load_texture("/$$rp/data/builtin_models/skybox/skybox.txo")
     skydome.set_wrap_u(SamplerState.WM_clamp)
     skydome.set_wrap_v(SamplerState.WM_clamp)
     self._pipeline.stage_mgr.inputs["DefaultSkydome"] = skydome
Ejemplo n.º 42
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
Ejemplo n.º 43
0
 def load_default_skybox(self):
     skybox = RPLoader.load_model(
         "/$$rp/data/builtin_models/skybox/skybox.bam")
     return skybox
Ejemplo n.º 44
0
 def on_pipeline_created(self):
     dirt_tex = RPLoader.load_texture(self.get_resource("lens_dirt.txo.pz"))
     self._bloom_stage.set_shader_input("LensDirtTex", dirt_tex)
Ejemplo n.º 45
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