本文整理汇总了C++中ogre::GpuProgramParametersSharedPtr::setNamedAutoConstant方法的典型用法代码示例。如果您正苦于以下问题:C++ GpuProgramParametersSharedPtr::setNamedAutoConstant方法的具体用法?C++ GpuProgramParametersSharedPtr::setNamedAutoConstant怎么用?C++ GpuProgramParametersSharedPtr::setNamedAutoConstant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::GpuProgramParametersSharedPtr
的用法示例。
在下文中一共展示了GpuProgramParametersSharedPtr::setNamedAutoConstant方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setUpBaseParameters
void setUpBaseParameters(const Ogre::GpuProgramParametersSharedPtr& params)
{
assert(params.isNull()==false);
struct AutoParamPair { Ogre::String name; Ogre::GpuProgramParameters::AutoConstantType type; };
//A list of auto params that might be present in the shaders generated
static const AutoParamPair AUTO_PARAMS[] = {
{ "vpWidth", Ogre::GpuProgramParameters::ACT_VIEWPORT_WIDTH },
{ "vpHeight", Ogre::GpuProgramParameters::ACT_VIEWPORT_HEIGHT },
{ "worldView", Ogre::GpuProgramParameters::ACT_WORLDVIEW_MATRIX },
{ "invProj", Ogre::GpuProgramParameters::ACT_INVERSE_PROJECTION_MATRIX },
{ "invView", Ogre::GpuProgramParameters::ACT_INVERSE_VIEW_MATRIX },
{ "flip", Ogre::GpuProgramParameters::ACT_RENDER_TARGET_FLIPPING },
{ "lightDiffuseColor", Ogre::GpuProgramParameters::ACT_LIGHT_DIFFUSE_COLOUR },
{ "lightSpecularColor", Ogre::GpuProgramParameters::ACT_LIGHT_SPECULAR_COLOUR },
{ "lightFalloff", Ogre::GpuProgramParameters::ACT_LIGHT_ATTENUATION },
{ "lightPos", Ogre::GpuProgramParameters::ACT_LIGHT_POSITION_VIEW_SPACE },
{ "lightDir", Ogre::GpuProgramParameters::ACT_LIGHT_DIRECTION_VIEW_SPACE },
{ "spotParams", Ogre::GpuProgramParameters::ACT_SPOTLIGHT_PARAMS },
{ "farClipDistance", Ogre::GpuProgramParameters::ACT_FAR_CLIP_DISTANCE },
{ "shadowViewProjMat", Ogre::GpuProgramParameters::ACT_TEXTURE_VIEWPROJ_MATRIX }
};
int numParams = sizeof(AUTO_PARAMS) / sizeof(AutoParamPair);
for (int i=0; i<numParams; i++)
{
if (params->_findNamedConstantDefinition(AUTO_PARAMS[i].name))
{
params->setNamedAutoConstant(AUTO_PARAMS[i].name, AUTO_PARAMS[i].type);
}
}
}
示例2: _createSoftMaterial
//-----------------------------------------------------------------------
void ParticleRenderer::_createSoftMaterial(void)
{
Ogre::String newMaterialName = SOFT_PREFIX + mParentTechnique->getMaterialName();
if (!Ogre::MaterialManager::getSingletonPtr()->getByName(newMaterialName).isNull())
{
mParentTechnique->setMaterialName(newMaterialName);
return;
}
// Create a new material for soft particles
if (mUseSoftParticles && mNotifiedDepthMap)
{
// Create Vertex program
Ogre::String softVertexName = "ParticleUniverse_SoftVP"; // Use ParticleUniverse_ to avoid name conflicts.
Ogre::HighLevelGpuProgramPtr vertexProgram = Ogre::HighLevelGpuProgramManager::getSingleton().createProgram(
softVertexName,
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
"hlsl",
Ogre::GPT_VERTEX_PROGRAM);
vertexProgram->setSourceFile("pu_soft_sm20.hlsl");
vertexProgram->setParameter("target", "vs_2_0");
vertexProgram->setParameter("entry_point", "mainVP"); // Must be same name as in pu_soft_sm20.hlsl
vertexProgram->load();
Ogre::String softFragmentName = "ParticleUniverse_SoftFP"; // Use ParticleUniverse_ to avoid name conflicts.
Ogre::HighLevelGpuProgramPtr fragmentProgram = Ogre::HighLevelGpuProgramManager::getSingleton().createProgram(
softFragmentName,
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
"hlsl",
Ogre::GPT_FRAGMENT_PROGRAM);
fragmentProgram->setSourceFile("pu_soft_sm20.hlsl");
fragmentProgram->setParameter("target", "ps_2_0");
fragmentProgram->setParameter("entry_point", "mainFP"); // Must be same name as in pu_soft_sm20.hlsl
fragmentProgram->load();
Ogre::String resourceGroupName = mParentTechnique->getParentSystem() ?
mParentTechnique->getParentSystem()->getResourceGroupName() :
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME;
// Create material with depth texture
Ogre::MaterialPtr newMaterial = Ogre::MaterialManager::getSingleton().getByName(newMaterialName);
if (!newMaterial.getPointer())
{
newMaterial = Ogre::MaterialManager::getSingleton().create(newMaterialName, resourceGroupName);
Ogre::Pass* newPass = newMaterial->getTechnique(0)->getPass(0);
newPass->setDepthCheckEnabled(true);
newPass->setDepthWriteEnabled(false);
newPass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
newPass->createTextureUnitState(ParticleSystemManager::getSingleton().getDepthTextureName());
// Get the first texture from the old material (assume it has at least 1 technique and one pass)
Ogre::Pass* oldPass = mParentTechnique->getMaterial()->getBestTechnique()->getPass(0);
newPass->setLightingEnabled(oldPass->getLightingEnabled());
if (oldPass->getNumTextureUnitStates() > 0)
{
Ogre::TextureUnitState* oldTextureUnitState = oldPass->getTextureUnitState(0);
newPass->createTextureUnitState(oldTextureUnitState->getTextureName());
}
// Set the vertex and fragment parameters
newPass->setVertexProgram(softVertexName);
newPass->setFragmentProgram(softFragmentName);
Ogre::GpuProgramParametersSharedPtr vertexParams = newPass->getVertexProgramParameters();
vertexParams->setNamedAutoConstant("worldViewProj", Ogre::GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);
vertexParams->setNamedAutoConstant("depthRange", Ogre::GpuProgramParameters::ACT_SCENE_DEPTH_RANGE);
// Depth scale must be the same as used in creation of the depth map
vertexParams->setNamedConstant("depthScale", ParticleSystemManager::getSingleton().getDepthScale());
Ogre::GpuProgramParametersSharedPtr fragmentParams = newPass->getFragmentProgramParameters();
fragmentParams->setNamedConstant("contrastPower", mSoftParticlesContrastPower);
fragmentParams->setNamedConstant("scale", mSoftParticlesScale);
fragmentParams->setNamedConstant("delta", mSoftParticlesDelta);
}
// Set the new material
mParentTechnique->setMaterialName(newMaterialName);
}
}