Esempio n. 1
0
void Camera::renderTexture(engine::ITexture* texture)
{
    Texture* t = dynamic_cast<Texture*>( texture ); assert( t );

    t->apply( 0 );
    dxSetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
    dxSetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
    dxSetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
    dxSetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
    dxSetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );

    dxRenderRect( 0, 0, _viewPort.Width, _viewPort.Height, white  );
}
Esempio n. 2
0
void Camera::renderTextureAdditive(engine::ITexture* texture)
{
	Texture* t = dynamic_cast<Texture*>( texture ); assert( t );

    t->apply( 0 );
    dxSetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
    dxSetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
    dxSetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
    dxSetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
    dxSetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );

	_dxCR( dxSetRenderState( D3DRS_ALPHABLENDENABLE, TRUE ) );
	_dxCR( dxSetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE ) );
    _dxCR( dxSetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ) );
    _dxCR( dxSetRenderState( D3DRS_BLENDOP, D3DBLENDOP_ADD ) );

    dxRenderRect( 0, 0, _viewPort.Width, _viewPort.Height, white  );

	_dxCR( dxSetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ) );
    _dxCR( dxSetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ) );
}
Esempio n. 3
0
static void setWireRenderStates(const Color* color)
{
    _dxCR( dxSetRenderState( D3DRS_COLORVERTEX, FALSE ) );
    _dxCR( dxSetRenderState( D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL ) );
    _dxCR( dxSetRenderState( D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL ) );
    _dxCR( dxSetRenderState( D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL ) );
    _dxCR( dxSetRenderState( D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL ) );
    D3DMATERIAL9 material;
    material.Diffuse  = _wrap( wrap( *color ) );
    material.Ambient  = material.Diffuse;
    material.Specular = material.Diffuse;
    material.Emissive = material.Diffuse;
    _dxCR( dxSetMaterial( &material ) ); 
    _dxCR( dxSetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG2 ) );
    _dxCR( dxSetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ) );
    _dxCR( dxSetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG2 ) );
    _dxCR( dxSetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ) );
    _dxCR( dxSetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ) );
    _dxCR( dxSetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ) );
}
void Geometry::renderDepthMap(void)
{
    // for each triangle - the fill rule is simple opaque black-colored painting    
    _dxCR( dxSetRenderState( D3DRS_TEXTUREFACTOR, depthColor ) );
    _dxCR( dxSetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ) );
    _dxCR( dxSetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TFACTOR ) );
    _dxCR( dxSetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ) );
    _dxCR( dxSetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR ) );
    _dxCR( dxSetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ) );
    _dxCR( dxSetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ) );    

    int shaderId;
    int numAttributes = _mesh->NumAttributeGroups;

    for( int i=0; i<numAttributes; i++ )
    {
        shaderId = _mesh->getAttributeId( i );

        if( !shader( shaderId )->isInvisible() )
        {            
            _mesh->renderSubset( i, shader( shaderId ) );
        }
    }
}
Esempio n. 5
0
void CameraEffect::applyMotionBlur(void)
{
    if( _prevIsEmpty || _weight == 0.0f )
    {
        _prevIsEmpty = false;
        
        // setup new image for texture rendering
        _newImage->apply( 0 );
        dxSetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
        dxSetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
        dxSetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
        dxSetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
        dxSetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
        dxSetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
        dxSetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );

        // render new image in to the previous image        
        IDirect3DSurface9* iDirect3DSurface;
        _dxCR( _prevImage->iDirect3DTexture()->GetSurfaceLevel( 0, &iDirect3DSurface ) );
        _dxCR( _rts->BeginScene( iDirect3DSurface, &_viewPort ) );
        iDirect3DSurface->Release();        
        _dxCR( iDirect3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, black, 1.0f, 0L ) );
        dxRenderRect( 
            0, 0, 
            Engine::instance->screenWidth-1, Engine::instance->screenHeight-1, 
            white 
        );
        _dxCR( _rts->EndScene( D3DX_FILTER_LINEAR ) );

        // render new image in to the render target
        _dxCR( _renderTarget->iDirect3DTexture()->GetSurfaceLevel( 0, &iDirect3DSurface ) );
        _dxCR( _rts->BeginScene( iDirect3DSurface, &_viewPort ) );
        iDirect3DSurface->Release();
        _dxCR( iDirect3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, black, 1.0f, 0L ) );
        dxRenderRect( 
            0, 0, 
            Engine::instance->screenWidth-1, Engine::instance->screenHeight-1, 
            white 
        );
        _dxCR( _rts->EndScene( D3DX_FILTER_LINEAR ) );
    }
    else
    {
        // setup blending of new image & previous image
        _prevImage->apply( 0 );
        _newImage->apply( 1 );

        Color w = D3DCOLOR_RGBA( int(255 * _weight), int(255 * _weight), int(255 * _weight), 255 );

        dxSetRenderState( D3DRS_TEXTUREFACTOR, w );

        dxSetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
        dxSetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
        dxSetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
        dxSetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
        dxSetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );

        dxSetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 0 );
        dxSetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_LERP );
        dxSetTextureStageState( 1, D3DTSS_COLORARG0, D3DTA_TFACTOR );
        dxSetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_CURRENT );
        dxSetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_TEXTURE );
        dxSetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
        dxSetTextureStageState( 1, D3DTSS_ALPHAARG1, D3DTA_CURRENT );

        dxSetTextureStageState( 2, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
        dxSetTextureStageState( 2, D3DTSS_COLOROP, D3DTOP_DISABLE );

        // blend new image & prev image into the render target
        IDirect3DSurface9* iDirect3DSurface;
        _dxCR( _renderTarget->iDirect3DTexture()->GetSurfaceLevel( 0, &iDirect3DSurface ) );
        _dxCR( _rts->BeginScene( iDirect3DSurface, &_viewPort ) );
        iDirect3DSurface->Release();
        _dxCR( iDirect3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, black, 1.0f, 0L ) );
        dxRenderRect( 
            0, 0, 
            Engine::instance->screenWidth-1, Engine::instance->screenHeight-1, 
            white
        );
        _rts->EndScene( D3DX_FILTER_LINEAR );

        // setup rendering of render target
        _renderTarget->apply( 0 );
        dxSetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0 );
        dxSetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
        dxSetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
        dxSetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
        dxSetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
        dxSetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
        dxSetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );

        // copy target image into the previous image       
        _dxCR( _prevImage->iDirect3DTexture()->GetSurfaceLevel( 0, &iDirect3DSurface ) );
        _dxCR( _rts->BeginScene( iDirect3DSurface, &_viewPort ) );
        iDirect3DSurface->Release();
        _dxCR( iDirect3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, black, 1.0f, 0L ) );
        dxRenderRect( 
            0, 0, 
            Engine::instance->screenWidth-1, Engine::instance->screenHeight-1, 
            white 
        );        
        _dxCR( _rts->EndScene( D3DX_FILTER_LINEAR ) );
    }
}
Esempio n. 6
0
void Shader::apply(void)
{
    // simple caching
    if( ( _lightset == 0 ) && ( _flags & engine::sfCaching ) && ( _lastShader == this ) ) 
    {
        Engine::instance->statistics.shaderCacheHits++;
        return;
    }
    _lastShader = this;

    // setup lighting
    if( _lightset == 0 )
    {
        _materialColor.Emissive = _globalAmbient;    
        dxModulateColorValue( &_materialColor.Emissive, &_materialColor.Diffuse );
        _dxCR( dxSetMaterial( &_materialColor ) );
    }
    else
    {
        BSP::currentBSP->calculateGlobalAmbient( _lightset );
        BSPSector::currentSector->illuminate( _lightset );
        _materialColor.Emissive = _globalAmbient;    
        dxModulateColorValue( &_materialColor.Emissive, &_materialColor.Diffuse );
        _dxCR( dxSetMaterial( &_materialColor ) );
    }

    // current lightmap (if exists)
    Texture* lightmap = NULL;
    if( BSPSector::currentSector )
    {
        if( BSPSector::currentSector->lightmap() )
        {
            lightmap = BSPSector::currentSector->lightmap();
        }
        if( Atomic::currentAtomic && Atomic::currentAtomic->lightmap() )
        {
            lightmap = Atomic::currentAtomic->lightmap();
        }
    }

    // cannot cache shaders with lightmaps
    if( lightmap ) _lastShader = NULL;

    // setup culling    
    if( _flags & engine::sfCulling )
    {
        _dxCR( dxSetRenderState( D3DRS_CULLMODE, D3DCULL_CW ) );
    }
    else
    {
        _dxCR( dxSetRenderState( D3DRS_CULLMODE, D3DCULL_NONE ) );
    }

    // setup alpha-blending
    if( _flags & engine::sfAlphaBlending )
    {
        _dxCR( dxSetRenderState( D3DRS_ALPHABLENDENABLE, TRUE ) );
        _dxCR( dxSetRenderState( D3DRS_SRCBLEND, _srcBlend ) );
        _dxCR( dxSetRenderState( D3DRS_DESTBLEND, _dstBlend ) );
        _dxCR( dxSetRenderState( D3DRS_BLENDOP, _blendOp ) );
    }
    else
    {
        _dxCR( dxSetRenderState( D3DRS_ALPHABLENDENABLE, FALSE ) );
    }

    // setup alpha-testing
    if( _flags & engine::sfAlphaTesting )
    {               
        _dxCR( dxSetRenderState( D3DRS_ALPHATESTENABLE, TRUE ) );
        _dxCR( dxSetRenderState( D3DRS_ALPHAFUNC, _alphaTestFunction ) );
        _dxCR( dxSetRenderState( D3DRS_ALPHAREF, _alphaTestRef ) );
    }
    else
    {
        _dxCR( dxSetRenderState( D3DRS_ALPHATESTENABLE, FALSE ) );
    }

    // fixed function pipeline : first texture
    if( _numLayers )
    {
        assert( _layerTexture[0] );
        _layerTexture[0]->apply( 0 );
        _dxCR( dxSetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, _layerUV[0] ) );
        _dxCR( dxSetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ) );
        _dxCR( dxSetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ) );
        _dxCR( dxSetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ) );
        _dxCR( dxSetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ) );
    }

    // fixed function pipeline : multitextures
	int stageId;
    for( stageId=1; stageId<_numLayers; stageId++ )
    {
        assert( _layerTexture[stageId] );
        _layerTexture[stageId]->apply( stageId );
        _dxCR( dxSetTextureStageState( stageId, D3DTSS_TEXCOORDINDEX, _layerUV[stageId] ) );
        switch( _layerBlending[stageId] )
        {
        case engine::btOver:
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLOROP, D3DTOP_SELECTARG2 ) );
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG2, D3DTA_TEXTURE ) );
        case engine::btAdd:
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLOROP, D3DTOP_ADD ) );
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG1, D3DTA_CURRENT ) );
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG2, D3DTA_TEXTURE ) );
            break;
        case engine::btSub:
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLOROP, D3DTOP_SUBTRACT ) );
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG1, D3DTA_CURRENT ) );
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG2, D3DTA_TEXTURE ) );
            break;
        case engine::btAddSigned:
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLOROP, D3DTOP_ADDSIGNED ) );
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG1, D3DTA_CURRENT ) );
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG2, D3DTA_TEXTURE ) );
            break;
        case engine::btAddSmooth:
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLOROP, D3DTOP_ADDSMOOTH ) );
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG1, D3DTA_CURRENT ) );
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG2, D3DTA_TEXTURE ) );
            break;
        case engine::btModulate:
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLOROP, D3DTOP_MODULATE ) );
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG1, D3DTA_CURRENT ) );
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG2, D3DTA_TEXTURE ) );
            break;
        case engine::btModulate2x:
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLOROP, D3DTOP_MODULATE2X ) );
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG1, D3DTA_CURRENT ) );
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG2, D3DTA_TEXTURE ) );
            break;
        case engine::btModulate4x:
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLOROP, D3DTOP_MODULATE4X ) );
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG1, D3DTA_CURRENT ) );
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG2, D3DTA_TEXTURE ) );
            break;
        case engine::btBlendTextureAlpha:
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLOROP, D3DTOP_BLENDTEXTUREALPHA ) );
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG1, D3DTA_TEXTURE ) );
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG2, D3DTA_CURRENT ) );
            break;
        case engine::btLerp:
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLOROP, D3DTOP_LERP ) );
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG1, D3DTA_CURRENT ) );
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG2, D3DTA_TEXTURE ) );
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG0, D3DTA_CONSTANT ) );
            _dxCR( dxSetTextureStageState( stageId, D3DTSS_CONSTANT, _layerConstant[stageId] ) );
            break;
        default:
            assert( !"Shouldn't be here!" );
        }

        _dxCR( dxSetTextureStageState( stageId, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ) );
        _dxCR( dxSetTextureStageState( stageId, D3DTSS_ALPHAARG1, D3DTA_CURRENT ) );
    }

    // lighting
    if( _flags & engine::sfLighting ) 
    {
        if( lightmap )
        {
            if( _numLayers )
            {
                lightmap->apply( stageId );
                _dxCR( dxSetTextureStageState( stageId, D3DTSS_TEXCOORDINDEX, 1 ) );
                _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLOROP, D3DTOP_MODULATE ) );
                _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG1, D3DTA_CURRENT ) );
                _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG2, D3DTA_TEXTURE ) );
                _dxCR( dxSetTextureStageState( stageId, D3DTSS_ALPHAOP, D3DTOP_MODULATE ) );
                _dxCR( dxSetTextureStageState( stageId, D3DTSS_ALPHAARG1, D3DTA_CURRENT ) );
                _dxCR( dxSetTextureStageState( stageId, D3DTSS_ALPHAARG2, D3DTA_TEXTURE ) );
                stageId++;
            }
            else
            {
                lightmap->apply( 0 );
                _dxCR( dxSetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 1 ) );
                _dxCR( dxSetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ) );
                _dxCR( dxSetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ) );
                _dxCR( dxSetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ) );
                _dxCR( dxSetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ) );
                stageId++;
            }
        }
        else
        {
            if( _numLayers )
            {
                _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLOROP, D3DTOP_MODULATE ) );
                _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG1, D3DTA_CURRENT ) );
                _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG2, D3DTA_DIFFUSE ) );
                _dxCR( dxSetTextureStageState( stageId, D3DTSS_ALPHAOP, D3DTOP_MODULATE ) );
                _dxCR( dxSetTextureStageState( stageId, D3DTSS_ALPHAARG1, D3DTA_CURRENT ) );
                _dxCR( dxSetTextureStageState( stageId, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ) );
                stageId++;
            }
            else
            {
                _dxCR( dxSetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG2 ) );
                _dxCR( dxSetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ) );
                _dxCR( dxSetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG2 ) );
                _dxCR( dxSetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ) );
            }
        }
    }

    // normal map ( for programmable pipeline only )
    /*if( _normalMap )
    {
        _normalMap->apply( stageId );
        _dxCR( dxSetTextureStageState( stageId, D3DTSS_TEXCOORDINDEX, 0 ) );
        _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ) );
        _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG1, D3DTA_CURRENT ) );
        _dxCR( dxSetTextureStageState( stageId, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ) );
        _dxCR( dxSetTextureStageState( stageId, D3DTSS_ALPHAARG1, D3DTA_CURRENT ) );
        stageId++;
    }*/

    // environment map ( for programmable pipeline only )
    /*if( _environmentMap )
    {
        _environmentMap->apply( stageId );
        _dxCR( dxSetTextureStageState( stageId, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR | 1 ) ); 
        _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLOROP, D3DTOP_ADD ) );
        _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG1, D3DTA_CURRENT ) );
        _dxCR( dxSetTextureStageState( stageId, D3DTSS_COLORARG2, D3DTA_TEXTURE ) );
        _dxCR( dxSetTextureStageState( stageId, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ) );
        _dxCR( dxSetTextureStageState( stageId, D3DTSS_ALPHAARG1, D3DTA_CURRENT ) );
        stageId++;
    }*/

    _dxCR( dxSetTextureStageState( stageId, D3DTSS_ALPHAOP, D3DTOP_DISABLE ) );
    //_dxCR( dxSetTextureStageState( stageId, D3DTSS_COLOROP, D3DTOP_DISABLE ) ); // ms2010error
}