コード例 #1
0
    def prepareSceneRender(self):

        self.debug("Preparing scene render for", self._name)

        # 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), 20)
        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()
コード例 #2
0
    def prepareSceneRender(self, earlyZ=False, earlyZCam=None):
        """ 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 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())

        if earlyZ:
            self._earlyZRegion = self._internalBuffer.makeDisplayRegion()
            self._earlyZRegion.setSort(-10)
            self._earlyZRegion.setCamera(earlyZCam)

        self._node = NodePath("RTRoot")

        # Prepare fullscreen quad
        if self._createOverlayQuad:

            self._quad = self._makeFullscreenQuad()
            self._quad.reparentTo(self._node)

            bufferCam = self._makeFullscreenCam()
            self._camera = self._node.attachNewNode(bufferCam)
            self._region.setCamera(self._camera)
            self._region.setSort(5)

        # Set clears
        bufferRegion = self._internalBuffer.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)

        if earlyZ:
            self._earlyZRegion.disableClears()
            self._earlyZRegion.setClearDepthActive(True)
            self._earlyZRegion.setActive(1)

        self._setSizeShaderInput()

        self._active = True
        self._registerBuffer()
コード例 #3
0
    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()