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


C++ PixelShader::ProcessPixel方法代码示例

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


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

示例1: _ScanTriangleLine

Void Raster::_ScanTriangleLine()
{
    // Top-left filling-convention, left part
	Int startX = MathFn->Ceil( m_ScanLine.fX[0] );
	Int endX = MathFn->Ceil( m_ScanLine.fX[1] ) - 1;
	if (endX < startX)
		return;

    // Offset & InvDelta along X
	Scalar fOfsX = ( (Scalar)startX - m_ScanLine.fX[0] );
	Scalar fInvDeltaX = ( m_ScanLine.fX[1] - m_ScanLine.fX[0] );
	if (fInvDeltaX < SCALAR_ERROR)
		fInvDeltaX = 1.0f;
	else
		fInvDeltaX = MathFn->Invert(fInvDeltaX);

    // Slopes & Offsets
    UInt j;
    for(j = 0; j < m_pCFL->GetTotalSize(); ++j) {
        m_ScanLine.pSlope[j] = ( m_ScanLine.pPixels[1][j] - m_ScanLine.pPixels[0][j] ) * fInvDeltaX;
        m_ScanLine.pCurrent[j] = m_ScanLine.pPixels[0][j] + m_ScanLine.pSlope[j] * fOfsX;
    }

	// Rasterize
    PixelShader * pPS = m_pRenderer->m_pPixelShader;
    pPS->ProcessPixel( startX, m_ScanLine.iY, m_ScanLine.pCurrent );
    for(j = 0; j < m_pCFL->GetTotalSize(); ++j)
        m_ScanLine.pCurrent[j] += m_ScanLine.pSlope[j];
    if ( !( m_pRenderer->_GetStateTransform()->UseWireframe() ) ) {
        for(Int iX = startX + 1; iX < endX; ++iX) {
            pPS->ProcessPixel( iX, m_ScanLine.iY, m_ScanLine.pCurrent );
            for(j = 0; j < m_pCFL->GetTotalSize(); ++j)
                m_ScanLine.pCurrent[j] += m_ScanLine.pSlope[j];
        }
    }
    pPS->ProcessPixel( endX, m_ScanLine.iY, m_ScanLine.pCurrent );
}
开发者ID:Shikifuyin,项目名称:Scarab-Engine,代码行数:37,代码来源:_Raster.cpp

示例2: ScanSegment

Void Raster::ScanSegment( CCFLPtr pPixelA, CCFLPtr pPixelB )
{
    // IMPORTANT : Fields of pixels A B and C are already scaled by InvW !
    // See _VertexToPixel() in the Renderer class ...

    const Scalar *pP0, *pP1;
    const Vertex2 * pSwapPos;
    const Vertex2 * pPos0 = (const Vertex2 *)( m_pCFL->GetField( pPixelA, CFLSEMANTIC_RASTERPOS, 0 ) );
    const Vertex2 * pPos1 = (const Vertex2 *)( m_pCFL->GetField( pPixelB, CFLSEMANTIC_RASTERPOS, 0 ) );

    // Sort pointers by crescent Y
    Scalar fDY = (pPos1->Y - pPos0->Y);
    if (fDY < 0.0f) {
        fDY = -fDY;
        pP0 = pPixelB;
        pP1 = pPixelA;
        pSwapPos = pPos0;
        pPos0 = pPos1;
        pPos1 = pSwapPos;
    } else {
        pP0 = pPixelA;
        pP1 = pPixelB;
    }
    Scalar fDX = (pPos1->X - pPos0->X);
    if (fDY >= fDX) {
        if ( fDY < SCALAR_ERROR )
            return; // degenerate segment
        Scalar fInvDY = MathFn->Invert(fDY);

        // Top-left filling-convention, top part
		Int startY = MathFn->Ceil( pPos0->Y );
		Int endY = MathFn->Ceil( pPos1->Y ) - 1;
        if ( endY < startY )
            return; // degenerate segment
        Scalar fOfsY = ( (Scalar)startY - pPos0->Y );

        // Slopes
        Scalar fSlopeX = fDX * fInvDY;
        Scalar fCurX = pPos0->X + fSlopeX * fOfsY;
        UInt j;
        for(j = 0; j < m_pCFL->GetTotalSize(); ++j) {
            m_ScanLine.pSlope[j] = ( pP1[j] - pP0[j] ) * fInvDY;
            m_ScanLine.pCurrent[j] = pP0[j] + m_ScanLine.pSlope[j] * fOfsY;
        }

        // Rasterize
        PixelShader * pPS = m_pRenderer->m_pPixelShader;
        for(Int iY = startY; iY <= endY; ++iY) {
            // Top-left filling-convention, left part
            UInt iX = (fSlopeX < 0.0f) ? MathFn->Ceil(fCurX) : MathFn->Floor(fCurX);
            pPS->ProcessPixel( iX, iY, m_ScanLine.pCurrent );
            fCurX += fSlopeX;
            for(j = 0; j < m_pCFL->GetTotalSize(); ++j)
                m_ScanLine.pCurrent[j] += m_ScanLine.pSlope[j];
        }
    } else {
        if ( fDX < SCALAR_ERROR )
            return; // degenerate segment
        Scalar fInvDX = MathFn->Invert(fDX);

        // Top-left filling-convention, left part
		Int startX = MathFn->Ceil( pPos0->X );
		Int endX = MathFn->Ceil( pPos1->X ) - 1;
        if ( endX < startX )
            return; // degenerate segment
        Scalar fOfsX = ( (Scalar)startX - pPos0->X );

        // Slopes
        Scalar fSlopeY = fDY * fInvDX;
        Scalar fCurY = pPos0->Y + fSlopeY * fOfsX;
        UInt j;
        for(j = 0; j < m_pCFL->GetTotalSize(); ++j) {
            m_ScanLine.pSlope[j] = ( pP1[j] - pP0[j] ) * fInvDX;
            m_ScanLine.pCurrent[j] = pP0[j] + m_ScanLine.pSlope[j] * fOfsX;
        }

        // Rasterize
        PixelShader * pPS = m_pRenderer->m_pPixelShader;
        for(Int iX = startX; iX <= endX; ++iX) {
            // Top-left filling-convention, top part
            UInt iY = (fSlopeY < 0.0f) ? MathFn->Ceil(fCurY) : MathFn->Floor(fCurY);
            pPS->ProcessPixel( iX, iY, m_ScanLine.pCurrent );
            fCurY += fSlopeY;
            for(j = 0; j < m_pCFL->GetTotalSize(); ++j)
                m_ScanLine.pCurrent[j] += m_ScanLine.pSlope[j];
        }
    }
}
开发者ID:Shikifuyin,项目名称:Scarab-Engine,代码行数:88,代码来源:_Raster.cpp


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