当前位置: 首页>>代码示例>>Python>>正文


Python ColorWriteAttrib.make方法代码示例

本文整理汇总了Python中panda3d.core.ColorWriteAttrib.make方法的典型用法代码示例。如果您正苦于以下问题:Python ColorWriteAttrib.make方法的具体用法?Python ColorWriteAttrib.make怎么用?Python ColorWriteAttrib.make使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在panda3d.core.ColorWriteAttrib的用法示例。


在下文中一共展示了ColorWriteAttrib.make方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create

# 需要导入模块: from panda3d.core import ColorWriteAttrib [as 别名]
# 或者: from panda3d.core.ColorWriteAttrib import make [as 别名]
    def create(self):
        # Create the voxel grid used to store the voxels
        self._voxel_grid = Image.create_3d(
            "Voxels", self._voxel_res, self._voxel_res, self._voxel_res, Texture.T_float, Texture.F_r11_g11_b10
        )
        self._voxel_grid.set_clear_color(Vec4(0))

        # Create the camera for voxelization
        self._voxel_cam = Camera("VoxelizeCam")
        self._voxel_cam.set_camera_mask(self._pipeline.tag_mgr.get_voxelize_mask())
        self._voxel_cam_lens = OrthographicLens()
        self._voxel_cam_lens.set_film_size(-self._voxel_ws, self._voxel_ws)
        self._voxel_cam_lens.set_near_far(0.0, 2.0 * self._voxel_ws)
        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_voxelize_camera(self._voxel_cam)

        # Create the voxelization target
        self._voxel_target = self._create_target("VoxelizeScene")
        self._voxel_target.set_source(source_cam=self._voxel_cam_np, source_win=Globals.base.win)
        self._voxel_target.set_size(self._voxel_res, self._voxel_res)
        self._voxel_target.set_create_overlay_quad(False)
        self._voxel_target.prepare_scene_render()

        # Create the initial state used for rendering voxels
        initial_state = NodePath("VXInitialState")
        initial_state.set_attrib(CullFaceAttrib.make(CullFaceAttrib.M_cull_none), 100000)
        initial_state.set_attrib(DepthTestAttrib.make(DepthTestAttrib.M_none), 100000)
        initial_state.set_attrib(ColorWriteAttrib.make(ColorWriteAttrib.C_off), 100000)
        self._voxel_cam.set_initial_state(initial_state.get_state())

        Globals.base.render.set_shader_input("voxelGridPosition", self._pta_grid_pos)
        Globals.base.render.set_shader_input("voxelGridRes", self._pta_grid_res)
        Globals.base.render.set_shader_input("voxelGridSize", self._pta_grid_size)
        Globals.base.render.set_shader_input("VoxelGridDest", self._voxel_grid.texture)
开发者ID:MYheavyGo,项目名称:RenderPipeline,代码行数:37,代码来源:VoxelizationStage.py

示例2: register_camera

# 需要导入模块: from panda3d.core import ColorWriteAttrib [as 别名]
# 或者: from panda3d.core.ColorWriteAttrib import make [as 别名]
 def register_camera(self, container, source):
     source.set_tag_state_key(container.tag_name)
     source.set_camera_mask(container.mask)
     state = RenderState.make_empty()
     state = state.set_attrib(ColorWriteAttrib.make(ColorWriteAttrib.C_off), 10000)
     source.set_initial_state(state)
     container.cameras.append(source)
开发者ID:MYheavyGo,项目名称:RenderPipeline,代码行数:9,代码来源:TagStateManager.py

示例3: prepareOffscreenBuffer

# 需要导入模块: from panda3d.core import ColorWriteAttrib [as 别名]
# 或者: from panda3d.core.ColorWriteAttrib import make [as 别名]
    def prepareOffscreenBuffer(self):
        """ Creates an offscreen buffer for this target """

        self.debug("Preparing offscreen buffer")

        # Init buffer object
        self._createBuffer()

        # Prepare fullscreen quad
        self._quad = self._makeFullscreenQuad()

        # Prepare fullscreen camera
        bufferCam = self._makeFullscreenCam()
        initialState = NodePath("is")

        if not self._writeColor:
            initialState.setAttrib(ColorWriteAttrib.make(ColorWriteAttrib.COff), 1000)

        initialState.setAttrib(DepthWriteAttrib.make(DepthWriteAttrib.MNone), 1000)

        bufferCam.setInitialState(initialState.getState())

        bufferCamNode = self._quad.attachNewNode(bufferCam)

        bufferRegion = self._buffer.getInternalBuffer().getDisplayRegion(0)
        bufferRegion.setCamera(bufferCamNode)
        bufferRegion.setActive(1)

        self._setSizeShaderInput()
开发者ID:Happy-Ferret,项目名称:RenderPipeline,代码行数:31,代码来源:RenderTarget.py

示例4: registerTagState

# 需要导入模块: from panda3d.core import ColorWriteAttrib [as 别名]
# 或者: from panda3d.core.ColorWriteAttrib import make [as 别名]
    def registerTagState(self, name, state):
        """ Registers a new tag state """
        state.setAttrib(ColorWriteAttrib.make(ColorWriteAttrib.COff))
        initialState = state.getState()

        for camera in self.shadowCameras:
            camera.node().setTagState(name, initialState) 
开发者ID:cesarmarinhorj,项目名称:RenderPipeline,代码行数:9,代码来源:ShadowScenePass.py

示例5: setEffect

# 需要导入模块: from panda3d.core import ColorWriteAttrib [as 别名]
# 或者: from panda3d.core.ColorWriteAttrib import make [as 别名]
    def setEffect(self, obj, effect, properties = None, sort=0):
        """ Applies the effect to an object with the given properties """

        effect = self.effectLoader.loadEffect(effect, properties)

        if effect.getSetting("transparent"):
            pass

        if effect.getSetting("dynamic"):
            self.registerDynamicObject(obj)

        if not effect.getSetting("castShadows"):
            obj.hide(self.getShadowPassBitmask())

        if not effect.getSetting("castGI"):
            obj.hide(self.getVoxelizePassBitmask())

        obj.setShader(effect.getShader("Default"), sort)

        # Create shadow caster state
        if effect.getSetting("castShadows"):
            initialState = NodePath("EffectInitialState"+str(effect.getEffectID()))
            initialState.setShader(effect.getShader("Shadows"), sort + 20)
            initialState.setAttrib(ColorWriteAttrib.make(ColorWriteAttrib.COff))
            stateName = "NodeEffect" + str(effect.getEffectID())
            self.lightManager.shadowPass.registerTagState(stateName, initialState.getState())
            obj.setTag("ShadowPassShader", stateName)
开发者ID:derkreature,项目名称:RenderPipeline,代码行数:29,代码来源:RenderingPipeline.py

示例6: apply_state

# 需要导入模块: from panda3d.core import ColorWriteAttrib [as 别名]
# 或者: from panda3d.core.ColorWriteAttrib import make [as 别名]
    def apply_state(self, container, np, shader, name, sort):
        state = RenderState.make_empty()
        state = state.set_attrib(ColorWriteAttrib.make(ColorWriteAttrib.C_off), 10000)
        state = state.set_attrib(ShaderAttrib.make(shader, sort), sort)

        container.tag_states[name] = state
        np.set_tag(container.tag_name, name)

        for camera in container.cameras:
            camera.set_tag_state(name, state)
开发者ID:MYheavyGo,项目名称:RenderPipeline,代码行数:12,代码来源:TagStateManager.py

示例7: setShaders

# 需要导入模块: from panda3d.core import ColorWriteAttrib [as 别名]
# 或者: from panda3d.core.ColorWriteAttrib import make [as 别名]
    def setShaders(self):
        casterShader = Shader.load(Shader.SLGLSL,
            "Shader/DefaultShaders/ShadowCasting/vertex.glsl",
            "Shader/DefaultShaders/ShadowCasting/fragment.glsl")
        initialState = NodePath("ShadowCasterState")
        initialState.setShader(casterShader, 100)
        initialState.setAttrib(ColorWriteAttrib.make(ColorWriteAttrib.COff))
        for camera in self.shadowCameras:
            camera.node().setTagState("Default", initialState.getState())

        casterShaderTransparent = Shader.load(Shader.SLGLSL,
            "Shader/DefaultShaders/TransparentShadowCasting/vertex.glsl",
            "Shader/DefaultShaders/TransparentShadowCasting/fragment.glsl")
        initialState = NodePath("ShadowCasterStateTransparent")
        initialState.setShader(casterShaderTransparent, 100)
        initialState.setAttrib(ColorWriteAttrib.make(ColorWriteAttrib.COff))
        for camera in self.shadowCameras:
            camera.node().setTagState("Transparent", initialState.getState()) 

        return [casterShader, casterShaderTransparent]
开发者ID:croxis,项目名称:RenderPipeline,代码行数:22,代码来源:ShadowScenePass.py

示例8: _create_buffer

# 需要导入模块: from panda3d.core import ColorWriteAttrib [as 别名]
# 或者: from panda3d.core.ColorWriteAttrib import make [as 别名]
    def _create_buffer(self):
        """ Internal method to create the buffer object """
        self._compute_size_from_constraint()
        if not self._create():
            self.error("Failed to create buffer!")
            return False

        if self.create_default_region:
            self._source_region = PostProcessRegion.make(self._internal_buffer)

            if max(self._color_bits) == 0:
                self._source_region.set_attrib(ColorWriteAttrib.make(ColorWriteAttrib.M_none), 1000)
开发者ID:jakogut,项目名称:RenderPipeline,代码行数:14,代码来源:render_target.py

示例9: registerEarlyZTagState

# 需要导入模块: from panda3d.core import ColorWriteAttrib [as 别名]
# 或者: from panda3d.core.ColorWriteAttrib import make [as 别名]
    def registerEarlyZTagState(self, name, state):
        """ Registers a new tag state """
        if not self.prepassCam:
            return

        # state.setAttrib(CullFaceAttrib.make(CullFaceAttrib.MCullClockwise), 10000)
        state.setAttrib(ColorWriteAttrib.make(ColorWriteAttrib.COff), 10000)
        state.setAttrib(AlphaTestAttrib.make(AlphaTestAttrib.MNone, 1.0), 10000)
        state.setAttrib(DepthWriteAttrib.make(DepthWriteAttrib.MOn), 10000)
        state.setAttrib(DepthTestAttrib.make(DepthTestAttrib.MLess), 10000)
        state.setAttrib(TransparencyAttrib.make(TransparencyAttrib.MNone), 10000)

        self.prepassCam.setTagState(name, state.getState()) 
开发者ID:cesarmarinhorj,项目名称:RenderPipeline,代码行数:15,代码来源:DeferredScenePass.py

示例10: createWorld

# 需要导入模块: from panda3d.core import ColorWriteAttrib [as 别名]
# 或者: from panda3d.core.ColorWriteAttrib import make [as 别名]
    def createWorld(self, task=None):
        self.sky.clearAttrib(TransparencyAttrib)

        self.deskNP.reparentTo(self.base.render)
        self.deskNP.setScale(7.5)
        self.deskNP.setPos(0, -5, -6.5)

        # make a box that clips content under the desk (e.g. the paper)
        bb = self.deskNP.getTightBounds()
        sz = (bb[1]-bb[0]) * 0.8

        self.underDeskClip = self.base.loader.loadModel('box')
        self.underDeskClip.setScale(sz)
        self.underDeskClip.reparentTo(self.base.render)
        self.underDeskClip.setPos(-sz.x/2, -sz.y*1.1, -sz.z*0.73)

        if False:
            # --> nope, this actually hides everything the camera might see

            self.newBin = CullBinManager.getGlobalPtr().addBin('foo', CullBinManager.BT_state_sorted, -50)
            # make the box obscure geometry "inside" it
            self.underDeskClip.setAttrib(ColorWriteAttrib.make(False))
            self.underDeskClip.setDepthWrite(True)
            self.underDeskClip.setBin('foo', -50)

        else:
            bb = self.underDeskClip.getTightBounds()
            self.underDeskClip.removeNode()


        self.typewriterNP.reparentTo(self.base.render)

        self.typewriterNP.setHpr(0, 0, 0)
        self.typewriterNP.setScale(5)

        self.base.camera.setPos(0, -25, 5)
        self.cameraTarget = Point3(0, -9.5, 7.5)
        #self.cameraTarget = Point3(0, -25, 2.5)
        self.cameraHprTarget = Point3(0, -19.5, 0)
        self.typewriterTarget = Point3(0, -2.5, 2.666)
        self.typewriterStart = Point3(0, -5, 10)

        if not self.skipIntro:
            self.animateArrival()
        else:
            self.activateTypewriter()
开发者ID:eswartz,项目名称:panda3d-stuff,代码行数:48,代码来源:world.py

示例11: _create_buffer

# 需要导入模块: from panda3d.core import ColorWriteAttrib [as 别名]
# 或者: from panda3d.core.ColorWriteAttrib import make [as 别名]
    def _create_buffer(self):
        """ Internal method to create the buffer object """
        if self._source_window == Globals.base.win:
            w, h = Globals.resolution.x, Globals.resolution.y
        else:
            w, h = self._source_window.get_x_size(), self._source_window.get_y_size()

        if self._size.x < 0:
            self._size.x = (w - self._size.x - 1) // (-self._size.x)

        if self._size.y < 0:
            self._size.y = (h - self._size.y - 1) // (-self._size.y)

        if not self._create():
            self.error("Failed to create buffer!")
            return False

        if self.create_default_region:
            self._source_region = PostProcessRegion.make(self._internal_buffer)

            if max(self._color_bits) == 0:
                self._source_region.set_attrib(ColorWriteAttrib.make(ColorWriteAttrib.M_none), 1000)
开发者ID:aimoonchen,项目名称:RenderPipeline,代码行数:24,代码来源:render_target.py

示例12: prepare_render

# 需要导入模块: from panda3d.core import ColorWriteAttrib [as 别名]
# 或者: from panda3d.core.ColorWriteAttrib import make [as 别名]
    def prepare_render(self, camera_np):
        """ Prepares to render a scene """
        self.create_default_region = False
        self._create_buffer()
        self._source_region = self._internal_buffer.get_display_region(0)

        if camera_np:
            initial_state = NodePath("rtis")
            initial_state.set_state(camera_np.node().get_initial_state())

            if self._aux_count:
                initial_state.set_attrib(AuxBitplaneAttrib.make(self._aux_bits), 20)
            initial_state.set_attrib(TransparencyAttrib.make(TransparencyAttrib.M_none), 20)

            if max(self._color_bits) == 0:
                initial_state.set_attrib(ColorWriteAttrib.make(ColorWriteAttrib.C_off), 20)

            # Disable existing regions of the camera
            for region in camera_np.node().get_display_regions():
                region.set_active(False)

            # Remove the existing display region of the camera
            for region in self._source_window.get_display_regions():
                if region.get_camera() == camera_np:
                    self._source_window.remove_display_region(region)

            camera_np.node().set_initial_state(initial_state.get_state())
            self._source_region.set_camera(camera_np)

        self._internal_buffer.disable_clears()
        self._source_region.disable_clears()
        self._source_region.set_active(True)
        self._source_region.set_sort(20)

        # Reenable depth-clear, usually desireable
        self._source_region.set_clear_depth_active(True)
        self._source_region.set_clear_depth(1.0)
        self._active = True
开发者ID:jakogut,项目名称:RenderPipeline,代码行数:40,代码来源:render_target.py

示例13: setEffect

# 需要导入模块: from panda3d.core import ColorWriteAttrib [as 别名]
# 或者: from panda3d.core.ColorWriteAttrib import make [as 别名]
    def setEffect(self, obj, effect, properties = None, sort=0):
        """ Applies the effect to an object with the given properties """

        effect = self.effectLoader.loadEffect(effect, properties)

        if effect.getSetting("transparent"):
            if not self.settings.useTransparency:
                self.error("Cannot assign transparent material when transparency is disabled")
                return False

        if effect.getSetting("dynamic"):
            self.registerDynamicObject(obj)

        if not effect.getSetting("castShadows"):
            obj.hide(self.getShadowPassBitmask())

        if not effect.getSetting("castGI"):
            obj.hide(self.getVoxelizePassBitmask())

        if not effect.getSetting("mainPass"):
            obj.hide(self.getMainPassBitmask())

        effect.assignNode(obj, "Default", sort)

        # Create shadow caster state
        if effect.getSetting("castShadows"):
            initialState = NodePath("EffectInitialState"+str(effect.getEffectID()))
            initialState.setShader(effect.getShader("Shadows"), sort + 20)
            initialState.setAttrib(ColorWriteAttrib.make(ColorWriteAttrib.COff))

            # Fix for the shadowed terrain. Initial state doesn't seem to work with instancing
            # initialState.setInstanceCount(500)

            stateName = "NodeEffect" + str(effect.getEffectID())
            self.lightManager.shadowPass.registerTagState(stateName, initialState.getState())
            obj.setTag("ShadowPassShader", stateName)
开发者ID:rimij405,项目名称:RenderPipeline,代码行数:38,代码来源:RenderingPipeline.py

示例14: __init__

# 需要导入模块: from panda3d.core import ColorWriteAttrib [as 别名]
# 或者: from panda3d.core.ColorWriteAttrib import make [as 别名]
    def __init__(self, pipeline):
        """ Creates a new LightManager. It expects a RenderPipeline as parameter. """
        DebugObject.__init__(self, "LightManager")

        self._initArrays()

        self.pipeline = pipeline
        self.settings = pipeline.getSettings()

        # Create arrays to store lights & shadow sources
        self.lights = []
        self.shadowSources = []
        self.queuedShadowUpdates = []
        self.allLightsArray = ShaderStructArray(Light, self.maxTotalLights)

        self.cullBounds = None
        self.shadowScene = Globals.render

        # Create atlas
        self.shadowAtlas = ShadowAtlas()
        self.shadowAtlas.setSize(self.settings.shadowAtlasSize)
        self.shadowAtlas.create()

        self.maxShadowMaps = 24
        self.maxShadowUpdatesPerFrame = self.settings.maxShadowUpdatesPerFrame
        self.numShadowUpdatesPTA = PTAInt.emptyArray(1)

        self.updateShadowsArray = ShaderStructArray(
            ShadowSource, self.maxShadowUpdatesPerFrame)
        self.allShadowsArray = ShaderStructArray(
            ShadowSource, self.maxShadowMaps)

        # Create shadow compute buffer
        self._createShadowComputationBuffer()

        # Create the initial shadow state
        self.shadowComputeCamera.setTagStateKey("ShadowPassShader")
        self.shadowComputeCamera.setInitialState(RenderState.make(
            ColorWriteAttrib.make(ColorWriteAttrib.C_off),
            DepthWriteAttrib.make(DepthWriteAttrib.M_on),
            # CullFaceAttrib.make(CullFaceAttrib.MCullNone),
            100))

        self._createTagStates()

        self.shadowScene.setTag("ShadowPassShader", "Default")

        # Create debug overlay
        self._createDebugTexts()

        # Disable buffer on start
        self.shadowComputeTarget.setActive(False)

        # Bind arrays
        self.updateShadowsArray.bindTo(self.shadowScene, "updateSources")
        self.updateShadowsArray.bindTo(
            self.shadowComputeTarget, "updateSources")

        # Set initial inputs
        for target in [self.shadowComputeTarget, self.shadowScene]:
            target.setShaderInput("numUpdates", self.numShadowUpdatesPTA)

        self.lightingComputator = None
        self.lightCuller = None
开发者ID:Happy-Ferret,项目名称:RenderPipeline,代码行数:66,代码来源:LightManager.py

示例15: prepareSceneRender

# 需要导入模块: from panda3d.core import ColorWriteAttrib [as 别名]
# 或者: from panda3d.core.ColorWriteAttrib import make [as 别名]
    def prepareSceneRender(self):
        """ Renders the scene of the source camera to the buffer. See the
        documentation of this class for further information """

        self.debug("Preparing scene render")

        # Init buffer object
        self._createBuffer()

        # Prepare fullscreen quad
        self._quad = self._makeFullscreenQuad()

        # Prepare initial state
        cs = NodePath("InitialStateDummy")
        cs.setState(self._sourceCam.node().getInitialState())
        if self.hasTarget(RenderTargetType.Aux0):
            cs.setAttrib(AuxBitplaneAttrib.make(self._auxBits), 20)

        cs.setAttrib(StencilAttrib.makeOff(), 20)

        if not self._enableTransparency:
            cs.setAttrib(TransparencyAttrib.make(TransparencyAttrib.MNone), 100)

        if not self._writeColor:
            cs.setAttrib(ColorWriteAttrib.make(ColorWriteAttrib.COff), 100)
            
        self._sourceCam.node().setInitialState(cs.getState())

        # Set new camera
        bufferCam = self._makeFullscreenCam()
        bufferCamNode = self._quad.attachNewNode(bufferCam)
        self._region.setCamera(bufferCamNode)
        self._region.setSort(5)

        # Set clears
        bufferRegion = self._buffer.getInternalBuffer().getDisplayRegion(0)

        self._correctClears()

        bufferRegion.setClearStencilActive(False)
        # self._sourceWindow.setClearStencilActive(False)

        # Set aux clears
        targetCheck = [
            (RenderTargetType.Aux0, GraphicsOutput.RTPAuxRgba0),
            (RenderTargetType.Aux1, GraphicsOutput.RTPAuxRgba1),
            (RenderTargetType.Aux2, GraphicsOutput.RTPAuxRgba2),
            (RenderTargetType.Aux3, GraphicsOutput.RTPAuxRgba3),
        ]
        for target, targetBindPos in targetCheck:
            if self.hasTarget(target):
                bufferRegion.setClearActive(targetBindPos, 1)
                bufferRegion.setClearValue(
                    targetBindPos, Vec4(0.5, 0.5, 1.0, 0.0))

        self._region.disableClears()

        bufferRegion.setCamera(self._sourceCam)
        bufferRegion.setActive(1)
        # bufferRegion.setClearDepthActive(False)
        bufferRegion.setSort(20)

        self._setSizeShaderInput()
开发者ID:Happy-Ferret,项目名称:RenderPipeline,代码行数:65,代码来源:RenderTarget.py


注:本文中的panda3d.core.ColorWriteAttrib.make方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。