本文整理汇总了C++中GFXStateBlockDesc::addDesc方法的典型用法代码示例。如果您正苦于以下问题:C++ GFXStateBlockDesc::addDesc方法的具体用法?C++ GFXStateBlockDesc::addDesc怎么用?C++ GFXStateBlockDesc::addDesc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GFXStateBlockDesc
的用法示例。
在下文中一共展示了GFXStateBlockDesc::addDesc方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _initRenderStateStateBlocks
/// Creates the default state blocks for a list of render states
void ProcessedMaterial::_initRenderStateStateBlocks( RenderPassData *rpd )
{
GFXStateBlockDesc stateTranslucent;
GFXStateBlockDesc stateGlow;
GFXStateBlockDesc stateReflect;
GFXStateBlockDesc statePass;
_initStateBlockTemplates( stateTranslucent, stateGlow, stateReflect );
_initPassStateBlock( rpd, statePass );
// Ok, we've got our templates set up, let's combine them together based on state and
// create our state blocks.
for (U32 i = 0; i < RenderPassData::STATE_MAX; i++)
{
GFXStateBlockDesc stateFinal;
if (i & RenderPassData::STATE_REFLECT)
stateFinal.addDesc(stateReflect);
if (i & RenderPassData::STATE_TRANSLUCENT)
stateFinal.addDesc(stateTranslucent);
if (i & RenderPassData::STATE_GLOW)
stateFinal.addDesc(stateGlow);
stateFinal.addDesc(statePass);
if (i & RenderPassData::STATE_WIREFRAME)
stateFinal.fillMode = GFXFillWireframe;
GFXStateBlockRef sb = GFX->createStateBlock(stateFinal);
rpd->mRenderStates[i] = sb;
}
}
示例2: _initPassStateBlock
void ProcessedCustomMaterial::_initPassStateBlock( RenderPassData *rpd, GFXStateBlockDesc &result )
{
Parent::_initPassStateBlock( rpd, result );
if (mCustomMaterial->getStateBlockData())
result.addDesc(mCustomMaterial->getStateBlockData()->getState());
}
示例3: _initPassStateBlock
void ProcessedFFMaterial::_initPassStateBlock( RenderPassData *rpd, GFXStateBlockDesc &result )
{
Parent::_initPassStateBlock( rpd, result );
if ( mIsLightingMaterial )
{
result.ffLighting = true;
result.blendDefined = true;
result.blendEnable = true;
result.blendSrc = GFXBlendOne;
result.blendSrc = GFXBlendOne;
}
// This is here for generic FF shader fallbacks.
CustomMaterial* custmat = dynamic_cast<CustomMaterial*>(mMaterial);
if (custmat && custmat->getStateBlockData() )
result.addDesc(custmat->getStateBlockData()->getState());
}
示例4: _initPassStateBlock
/// Does the base render state block setting, normally per pass
void ProcessedFFMaterial::_initPassStateBlock(const Material::BlendOp blendOp, U32 numTex, const U32 texFlags[Material::MAX_TEX_PER_PASS], GFXStateBlockDesc& result)
{
Parent::_initPassStateBlock(blendOp, numTex, texFlags, result);
if (mIsLightingMaterial)
{
result.ffLighting = true;
result.blendDefined = true;
result.blendEnable = true;
result.blendSrc = GFXBlendOne;
result.blendSrc = GFXBlendOne;
}
// This is here for generic FF shader fallbacks.
CustomMaterial* custmat = dynamic_cast<CustomMaterial*>(mMaterial);
if (custmat)
{
if (custmat->getStateBlockData())
{
result.addDesc(custmat->getStateBlockData()->getState());
}
}
}
示例5: _initPassStateBlock
void ProcessedMaterial::_initPassStateBlock( RenderPassData *rpd, GFXStateBlockDesc &result )
{
if ( rpd->mBlendOp != Material::None )
{
result.blendDefined = true;
result.blendEnable = true;
_setBlendState( rpd->mBlendOp, result );
}
if (mMaterial && mMaterial->isDoubleSided())
{
result.cullDefined = true;
result.cullMode = GFXCullNone;
}
if(mMaterial && mMaterial->mAlphaTest)
{
result.alphaDefined = true;
result.alphaTestEnable = mMaterial->mAlphaTest;
result.alphaTestRef = mMaterial->mAlphaRef;
result.alphaTestFunc = GFXCmpGreaterEqual;
}
result.samplersDefined = true;
NamedTexTarget *texTarget;
U32 maxAnisotropy = 1;
if (mMaterial && mMaterial->mUseAnisotropic[ rpd->mStageNum ] )
maxAnisotropy = MATMGR->getDefaultAnisotropy();
for( U32 i=0; i < rpd->mNumTex; i++ )
{
U32 currTexFlag = rpd->mTexType[i];
switch( currTexFlag )
{
default:
{
result.samplers[i].textureColorOp = GFXTOPModulate;
result.samplers[i].addressModeU = GFXAddressWrap;
result.samplers[i].addressModeV = GFXAddressWrap;
if ( maxAnisotropy > 1 )
{
result.samplers[i].minFilter = GFXTextureFilterAnisotropic;
result.samplers[i].magFilter = GFXTextureFilterAnisotropic;
result.samplers[i].maxAnisotropy = maxAnisotropy;
}
else
{
result.samplers[i].minFilter = GFXTextureFilterLinear;
result.samplers[i].magFilter = GFXTextureFilterLinear;
}
break;
}
case Material::Cube:
case Material::SGCube:
case Material::NormalizeCube:
{
result.samplers[i].addressModeU = GFXAddressClamp;
result.samplers[i].addressModeV = GFXAddressClamp;
result.samplers[i].addressModeW = GFXAddressClamp;
break;
}
case Material::TexTarget:
{
texTarget = mPasses[0]->mTexSlot[i].texTarget;
if ( texTarget )
texTarget->setupSamplerState( &result.samplers[i] );
break;
}
}
}
// The prepass will take care of writing to the
// zbuffer, so we don't have to by default.
// The prepass can't write to the backbuffer's zbuffer in OpenGL.
if ( MATMGR->getPrePassEnabled() &&
!GFX->getAdapterType() == OpenGL &&
!mFeatures.hasFeature(MFT_ForwardShading))
result.setZReadWrite( result.zEnable, false );
result.addDesc(mUserDefined);
}
示例6: _createPass
//.........这里部分代码省略.........
matInfo->detailInfoVConst = pass->shader->getShaderConstHandle( avar( "$detailScaleAndFade%d", i ) );
matInfo->detailInfoPConst = pass->shader->getShaderConstHandle( avar( "$detailIdStrengthParallax%d", i ) );
matInfo->detailTexConst = pass->shader->getShaderConstHandle( avar( "$detailMap%d", i ) );
if ( matInfo->detailTexConst->isValid() )
{
const S32 sampler = matInfo->detailTexConst->getSamplerRegister();
desc.samplers[sampler] = GFXSamplerStateDesc::getWrapLinear();
desc.samplers[sampler].magFilter = GFXTextureFilterLinear;
desc.samplers[sampler].mipFilter = GFXTextureFilterLinear;
if ( maxAnisotropy > 1 )
{
desc.samplers[sampler].minFilter = GFXTextureFilterAnisotropic;
desc.samplers[sampler].maxAnisotropy = maxAnisotropy;
}
else
desc.samplers[sampler].minFilter = GFXTextureFilterLinear;
matInfo->detailTex.set( matInfo->mat->getDetailMap(),
&GFXDefaultStaticDiffuseProfile, "TerrainCellMaterial::_createPass() - DetailMap" );
}
matInfo->macroInfoVConst = pass->shader->getShaderConstHandle( avar( "$macroScaleAndFade%d", i ) );
matInfo->macroInfoPConst = pass->shader->getShaderConstHandle( avar( "$macroIdStrengthParallax%d", i ) );
matInfo->macroTexConst = pass->shader->getShaderConstHandle( avar( "$macroMap%d", i ) );
if ( matInfo->macroTexConst->isValid() )
{
const S32 sampler = matInfo->macroTexConst->getSamplerRegister();
desc.samplers[sampler] = GFXSamplerStateDesc::getWrapLinear();
desc.samplers[sampler].magFilter = GFXTextureFilterLinear;
desc.samplers[sampler].mipFilter = GFXTextureFilterLinear;
if ( maxAnisotropy > 1 )
{
desc.samplers[sampler].minFilter = GFXTextureFilterAnisotropic;
desc.samplers[sampler].maxAnisotropy = maxAnisotropy;
}
else
desc.samplers[sampler].minFilter = GFXTextureFilterLinear;
matInfo->macroTex.set( matInfo->mat->getMacroMap(),
&GFXDefaultStaticDiffuseProfile, "TerrainCellMaterial::_createPass() - MacroMap" );
}
//end macro texture
matInfo->normalTexConst = pass->shader->getShaderConstHandle( avar( "$normalMap%d", i ) );
if ( matInfo->normalTexConst->isValid() )
{
const S32 sampler = matInfo->normalTexConst->getSamplerRegister();
desc.samplers[sampler] = GFXSamplerStateDesc::getWrapLinear();
desc.samplers[sampler].magFilter = GFXTextureFilterLinear;
desc.samplers[sampler].mipFilter = GFXTextureFilterLinear;
if ( maxAnisotropy > 1 )
{
desc.samplers[sampler].minFilter = GFXTextureFilterAnisotropic;
desc.samplers[sampler].maxAnisotropy = maxAnisotropy;
}
else
desc.samplers[sampler].minFilter = GFXTextureFilterLinear;
matInfo->normalTex = normalMaps[i];
}
}
// Remove the materials we processed and leave the
// ones that remain for the next pass.
for ( U32 i=0; i < matCount; i++ )
{
MaterialInfo *matInfo = materials->first();
if ( baseOnly || pass->materials.find_next( matInfo ) == -1 )
delete matInfo;
materials->pop_front();
}
// If we're doing prepass it requires some
// special stencil settings for it to work.
if ( prePassMat )
desc.addDesc( RenderPrePassMgr::getOpaqueStenciWriteDesc( false ) );
desc.setCullMode( GFXCullCCW );
pass->stateBlock = GFX->createStateBlock(desc);
//reflection stateblock
desc.setCullMode( GFXCullCW );
pass->reflectionStateBlock = GFX->createStateBlock(desc);
// Create the wireframe state blocks.
GFXStateBlockDesc wireframe( desc );
wireframe.fillMode = GFXFillWireframe;
wireframe.setCullMode( GFXCullCCW );
pass->wireframeStateBlock = GFX->createStateBlock( wireframe );
return true;
}
示例7:
bool RenderImposterMgr::ShaderState::init( const String &shaderName,
const GFXStateBlockDesc *desc )
{
ShaderData *shaderData;
if ( !Sim::findObject( shaderName, shaderData ) )
{
Con::warnf( "TSImposterRenderMgr - failed to locate shader '%s'!", shaderName.c_str() );
return false;
}
// We're adding both the lightinfo uncondition and the
// prepass conditioner to the shader... we usually only
// use one of them, but the extra macros doesn't hurt.
Vector<GFXShaderMacro> macros;
mLightTarget = MatTextureTarget::findTargetByName( "lightinfo" );
if ( mLightTarget )
mLightTarget->getTargetShaderMacros( ¯os );
MatTextureTargetRef prepassTarget = MatTextureTarget::findTargetByName( "prepass" );
if ( prepassTarget )
prepassTarget->getTargetShaderMacros( ¯os );
// Get the shader.
mShader = shaderData->getShader( macros );
if ( !mShader )
return false;
mConsts = mShader->allocConstBuffer();
mWorldViewProjectSC = mShader->getShaderConstHandle( "$modelViewProj" );
mCamPosSC = mShader->getShaderConstHandle( "$camPos" );
mCamRightSC = mShader->getShaderConstHandle( "$camRight" );
mCamUpSC = mShader->getShaderConstHandle( "$camUp" );
mSunDirSC = mShader->getShaderConstHandle( "$sunDir" );
mFogDataSC = mShader->getShaderConstHandle( "$fogData" );
mParamsSC = mShader->getShaderConstHandle( "$params" );
mUVsSC = mShader->getShaderConstHandle( "$uvs" );
mLightColorSC = mShader->getShaderConstHandle( "$lightColor" );
mAmbientSC = mShader->getShaderConstHandle( "$ambient" );
mLightTexRT = mShader->getShaderConstHandle( "$lightTexRT" );
GFXStateBlockDesc d;
d.cullDefined = true;
d.cullMode = GFXCullNone;
d.samplersDefined = true;
d.samplers[0] = GFXSamplerStateDesc::getClampLinear();
d.samplers[1] = GFXSamplerStateDesc::getClampLinear();
d.samplers[2] = GFXSamplerStateDesc::getClampLinear();
// We clip in the shader!
//d.alphaDefined = true;
//d.alphaTestEnable = true;
//d.alphaTestRef = 84;
//d.alphaTestFunc = GFXCmpGreater;
d.zDefined = true;
d.zEnable = true;
d.zWriteEnable = true;
if ( desc )
d.addDesc( *desc );
mSB = GFX->createStateBlock(d);
return true;
}