How to use the panda3d.core.SamplerState function in Panda3D

To help you get started, we’ve selected a few Panda3D examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tobspr / RenderPipeline-Samples / 05-Quboid / src / Menu.py View on Github external
def __init__(self,main): 
        self.main=main

        wx = base.win.get_x_size()
        wy = base.win.get_y_size()
        kx = 1920
        ky = 1080
        self.myFrame = DirectFrame(frameColor=(1,1,1,1),
            frameSize=(0, kx,0, ky))

        menu_tex = loader.loadTexture("res/menu.png")
        menu_tex.set_minfilter(SamplerState.FT_nearest)
        menu_tex.set_magfilter(SamplerState.FT_linear)
        self.myFrame["frameTexture"] = menu_tex
        self.myFrame.reparentTo(base.pixel2d)
        self.myFrame.set_pos( (wx-kx) / 2, 0, -(wy+ky) / 2)
        self.myFrame.set_transparency(True)

        self.startButton = DirectButton(
                    text = "",  
                    text_scale=1.0,
                    text_fg=(0.2,0.2,0.2,1),
                    frameTexture="res/start_game.png",
                    frameColor=(1,1,1,1),
                    frameSize=(-64, 64, -20, 20),
                    command=self.main.startGame,
                    relief=DGG.FLAT,
                    rolloverSound=None,
github tobspr / RenderPipeline / Plugins / ColorCorrection / Plugin.py View on Github external
def _load_lut(self):
        lut_path = self.get_resource("DefaultLUT.png")
        lut = SliceLoader.load_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._stage.set_shader_input("ColorLUT", lut)
github tobspr / RenderPipeline / rpplugins / color_correction / plugin.py View on Github external
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)
github tobspr / RenderPipeline / Plugins / Clouds / Plugin.py View on Github external
def setup_inputs(self):
        sprite_tex = Globals.loader.loadTexture(self.get_resource("CloudSprites.png"))
        noise_tex = Globals.loader.loadTexture(self.get_resource("Noise.png"))

        for tex in [sprite_tex, noise_tex]:
            tex.set_wrap_u(SamplerState.WM_repeat)
            tex.set_wrap_v(SamplerState.WM_repeat)
            tex.set_anisotropic_degree(16)
            tex.set_minfilter(SamplerState.FT_linear)
            tex.set_magfilter(SamplerState.FT_linear)

        self._stage.set_shader_input("SpriteTex",  sprite_tex)
        self._stage.set_shader_input("NoiseTex", noise_tex)
github tobspr / RenderPipeline / rpcore / common_resources.py View on Github external
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
github tobspr / RenderPipeline / Code / RenderPasses / PCSSPreFilterPass.py View on Github external
def create(self):
        # Not much to be done here, most is done in the shader
        self.target = RenderTarget("PCSSPreFilter")
        # self.target.setHalfResolution()
        self.target.addColorTexture()
        self.target.prepareOffscreenBuffer()

        # self.blurTarget = RenderTarget("PCSSBlur")
        # self.blurTarget.addColorTexture()
        # self.blurTarget.prepareOffscreenBuffer()

        for target in [self.target]:
            target.getColorTexture().setMinfilter(SamplerState.FTNearest)
            target.getColorTexture().setMagfilter(SamplerState.FTNearest)
github tobspr / RenderPipeline / Plugins / ColorCorrection / ColorCorrectionStage.py View on Github external
# Create the sharpen target
        if self._use_sharpen:

            # When using a sharpen filter, the main target needs a color texture
            self._target.add_color_texture(bits=8)
            self._target.prepare_offscreen_buffer()

            self._target_sharpen = self.make_target("ColorCorrection:Sharpen")
            # We don't have a color attachment, but still want to write color
            self._target_sharpen.color_write = True
            self._target_sharpen.prepare_offscreen_buffer()
            self._target_sharpen.make_main_target()

            # Use a linear filter for the color texture, this is required for the sharpen
            # filter to work properly.
            self._target["color"].set_minfilter(SamplerState.FT_linear)
            self._target["color"].set_magfilter(SamplerState.FT_linear)

            self._target_sharpen.set_shader_input("SourceTex", self._target["color"])

        else:
            # Make the main target the only target
            self._target.color_write = True
            self._target.prepare_offscreen_buffer()
            self._target.make_main_target()
github tobspr / RenderPipeline / rpplugins / vxgi / voxelization_stage.py View on Github external
def create(self):
        # Create the voxel grid used to generate the voxels
        self.voxel_temp_grid = Image.create_3d(
            "VoxelsTemp", self.voxel_resolution, self.voxel_resolution,
            self.voxel_resolution, "RGBA8")
        self.voxel_temp_grid.set_clear_color(Vec4(0))
        self.voxel_temp_nrm_grid = Image.create_3d(
            "VoxelsTemp", self.voxel_resolution, self.voxel_resolution,
            self.voxel_resolution, "R11G11B10")
        self.voxel_temp_nrm_grid.set_clear_color(Vec4(0))

        # Create the voxel grid which is a copy of the temporary grid, but stable
        self.voxel_grid = Image.create_3d(
            "Voxels", self.voxel_resolution, self.voxel_resolution, self.voxel_resolution, "RGBA8")
        self.voxel_grid.set_clear_color(Vec4(0))
        self.voxel_grid.set_minfilter(SamplerState.FT_linear_mipmap_linear)

        # Create the camera for voxelization
        self.voxel_cam = Camera("VoxelizeCam")
        self.voxel_cam.set_camera_mask(self._pipeline.tag_mgr.get_mask("voxelize"))
        self.voxel_cam_lens = OrthographicLens()
        self.voxel_cam_lens.set_film_size(
            -2.0 * self.voxel_world_size, 2.0 * self.voxel_world_size)
        self.voxel_cam_lens.set_near_far(0.0, 2.0 * self.voxel_world_size)
        self.voxel_cam.set_lens(self.voxel_cam_lens)
        self.voxel_cam_np = Globals.base.render.attach_new_node(self.voxel_cam)
        self._pipeline.tag_mgr.register_camera("voxelize", self.voxel_cam)

        # Create the voxelization target
        self.voxel_target = self.create_target("VoxelizeScene")
        self.voxel_target.size = self.voxel_resolution
        self.voxel_target.prepare_render(self.voxel_cam_np)
github tobspr / RenderPipeline / rpplugins / pssm / pssm_shadow_stage.py View on Github external
def make_pcf_state(self):
        state = SamplerState()
        state.set_minfilter(SamplerState.FT_shadow)
        state.set_magfilter(SamplerState.FT_shadow)
        return state
github tobspr / RenderPipeline / rpplugins / pssm / pssm_shadow_stage.py View on Github external
def make_pcf_state(self):
        state = SamplerState()
        state.set_minfilter(SamplerState.FT_shadow)
        state.set_magfilter(SamplerState.FT_shadow)
        return state