本文整理汇总了C++中ogre::GpuProgramParametersSharedPtr::setNamedConstant方法的典型用法代码示例。如果您正苦于以下问题:C++ GpuProgramParametersSharedPtr::setNamedConstant方法的具体用法?C++ GpuProgramParametersSharedPtr::setNamedConstant怎么用?C++ GpuProgramParametersSharedPtr::setNamedConstant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::GpuProgramParametersSharedPtr
的用法示例。
在下文中一共展示了GpuProgramParametersSharedPtr::setNamedConstant方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fade
void fade(Ogre::Real tpf) {
if (m_eFadeOperation != FADE_NONE && m_pTextUnitState) {
m_pTextUnitState->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_TEXTURE, m_fAlpha);
if (m_eFadeOperation == FADE_IN) {
m_fCurrentDuration -= tpf;
m_fAlpha = m_fCurrentDuration / m_fTotalDuration;
if (m_fAlpha < 0.0) {
m_pOverlay->hide();
m_eFadeOperation = FADE_NONE;
if (m_pFaderCallback) {
m_pFaderCallback->fadeInCallback();
}
}
}
else if (m_eFadeOperation == FADE_OUT) {
m_fCurrentDuration += tpf;
m_fAlpha = m_fCurrentDuration / m_fTotalDuration;
if (m_fAlpha > 1.0) {
m_eFadeOperation = FADE_NONE;
if (m_pFaderCallback) {
m_pFaderCallback->fadeOutCallback();
}
}
}
}
#ifdef USE_SPRITE_SHADER
m_SpritePixelShaderParameters->setNamedConstant("colour", Ogre::ColourValue(1, 1, 1, m_fAlpha));
#endif
}
示例2: UpdMiniTer
// HUD utils
//---------------------------------------------------------------------------------------------------------------
void CHud::UpdMiniTer()
{
MaterialPtr mm = MaterialManager::getSingleton().getByName("circle_minimap");
Pass* pass = mm->getTechnique(0)->getPass(0);
if (!pass) return;
try
{ Ogre::GpuProgramParametersSharedPtr par = pass->getFragmentProgramParameters();
if (par->_findNamedConstantDefinition("showTerrain",false))
par->setNamedConstant("showTerrain", pSet->mini_terrain && app->sc->ter ? 1.f : 0.f);
if (par->_findNamedConstantDefinition("showBorder",false))
par->setNamedConstant("showBorder", pSet->mini_border && app->sc->ter ? 1.f : 0.f);
if (par->_findNamedConstantDefinition("square",false))
par->setNamedConstant("square", pSet->mini_zoomed && app->sc->ter ? 0.f : 1.f);
}
catch(...){ }
}
示例3: setChangeWorldFactor
void RenderComponentBillboardSet::setChangeWorldFactor(double factor)
{
Ogre::Technique * technique;
Ogre::GpuProgramParametersSharedPtr params;
Ogre::Pass * pass;
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName(mChangeWorldMaterial);
if(material.get())
{
technique= material->getTechnique(0);
if(technique)
{
if(technique->getNumPasses()>0)
{
pass=technique->getPass(0);
if(pass->hasFragmentProgram())
{
params=pass->getFragmentProgramParameters();
if(params.get())
{
params->setNamedConstant("mix_factor",Ogre::Real(factor));
}
}
}
}
}
}
示例4: setColour
void GroundFog::setColour (const Ogre::ColourValue &colour) {
for (PassSet::iterator it = mPasses.begin(); it != mPasses.end(); ++it) {
Ogre::GpuProgramParametersSharedPtr params = (*it)->getFragmentProgramParameters();
params->setNamedConstant("fogColour", colour);
}
mFogColour = colour;
updateSkyFogging();
}
示例5: notifyCameraChanged
void GroundFog::notifyCameraChanged (Ogre::Camera *cam)
{
CameraBoundElement::notifyCameraChanged (cam);
// Send camera height to shader.
Ogre::GpuProgramParametersSharedPtr params =
mDomeMaterial->getBestTechnique()->getPass(0)->getFragmentProgramParameters();
params->setNamedConstant("cameraHeight", cam->getDerivedPosition().dotProduct(mDomeNode->_getDerivedOrientation() * Ogre::Vector3::UNIT_Y));
}
示例6: notifyMaterialSetup
void DepthOfFieldListener::notifyMaterialSetup(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
{
if(pass_id == 1)
{
float blurScale =.5f;
Ogre::Vector4 pixelSize(1.0f / (mViewportWidth * blurScale), 1.0f / (mViewportHeight * blurScale), 0.0f, 0.0f);
mat->load();
Ogre::Pass *pass = mat->getBestTechnique()->getPass(0);
Ogre::GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
if (params->_findNamedConstantDefinition("pixelSize"))
params->setNamedConstant("pixelSize", pixelSize);
}
else if(pass_id == 2)
{
float blurScale =.5f;
Ogre::Vector4 pixelSize(1.0f / mViewportWidth, 1.0f / mViewportHeight,1.0f / (mViewportWidth * blurScale), 1.0f / (mViewportHeight * blurScale) );
Ogre::Pass *pass = mat->getBestTechnique()->getPass(0);
Ogre::GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
if (params->_findNamedConstantDefinition("pixelSize"))
params->setNamedConstant("pixelSize", pixelSize);
// this is the camera you're using
#ifndef ROAD_EDITOR
Ogre::Camera *cam = mApp->mSplitMgr->mCameras.front();
#else
Ogre::Camera *cam = mApp->mCamera;
#endif
if (params->_findNamedConstantDefinition("far"))
params->setNamedConstant("far", cam->getFarClipDistance());
if (params->_findNamedConstantDefinition("dofparams"))
{
Ogre::Vector4 dofParams(0.0f,mApp->pSet->depthOfFieldFocus,mApp->pSet->depthOfFieldFar,1.0);
params->setNamedConstant("dofparams", dofParams);
}
}
}
示例7: setDensity
void GroundFog::setDensity (Ogre::Real density) {
if (Ogre::Math::Abs(mDensity - density) > 0.000001) {
for (PassSet::iterator it = mPasses.begin(); it != mPasses.end(); ++it) {
Ogre::GpuProgramParametersSharedPtr params = (*it)->getFragmentProgramParameters();
params->setNamedConstant("fogDensity", density);
}
mDensity = density;
}
updateSkyFogging();
}
示例8: setVerticalDecay
void GroundFog::setVerticalDecay (Ogre::Real verticalDecay) {
if (Ogre::Math::Abs(mVerticalDecay - verticalDecay) > 0.000001) {
for (PassSet::iterator it = mPasses.begin(); it != mPasses.end(); ++it) {
Ogre::GpuProgramParametersSharedPtr params = (*it)->getFragmentProgramParameters();
params->setNamedConstant("fogVerticalDecay", verticalDecay);
}
mVerticalDecay = verticalDecay;
}
updateSkyFogging();
}
示例9: setGroundLevel
void GroundFog::setGroundLevel (Ogre::Real groundLevel) {
if (Ogre::Math::Abs(mGroundLevel - groundLevel) > 0.000001) {
for (PassSet::iterator it = mPasses.begin(); it != mPasses.end(); ++it) {
Ogre::GpuProgramParametersSharedPtr params = (*it)->getFragmentProgramParameters();
params->setNamedConstant("fogGroundLevel", groundLevel);
}
mGroundLevel = groundLevel;
}
updateSkyFogging();
}
示例10: updateFromCamera
void AmbientLight::updateFromCamera(Ogre::Camera* camera)
{
Ogre::Technique* tech = getMaterial()->getBestTechnique();
Ogre::Vector3 farCorner = camera->getViewMatrix(true) * camera->getWorldSpaceCorners()[4];
for (unsigned short i=0; i<tech->getNumPasses(); i++)
{
Ogre::Pass* pass = tech->getPass(i);
// get the vertex shader parameters
Ogre::GpuProgramParametersSharedPtr params = pass->getVertexProgramParameters();
// set the camera's far-top-right corner
if (params->_findNamedConstantDefinition("farCorner"))
params->setNamedConstant("farCorner", farCorner);
params = pass->getFragmentProgramParameters();
if (params->_findNamedConstantDefinition("farCorner"))
params->setNamedConstant("farCorner", farCorner);
}
}
示例11: setTextureUnitIndex
void OgrePass::setTextureUnitIndex (int programType, const std::string& name, int index)
{
Ogre::GpuProgramParametersSharedPtr params;
if (programType == GPT_Vertex)
params = mPass->getVertexProgramParameters();
else if (programType == GPT_Fragment)
params = mPass->getFragmentProgramParameters();
params->setNamedConstant(name, index);
}
示例12:
void
GraphicsController::_setSHParameterMultipleMaterials(int paramIdx,
const Ogre::String &namer, const Ogre::String &nameg, const Ogre::String &nameb,
const std::vector<Ogre::String> &materialNames)
{
//for(auto iter = materialNames.cbegin(); iter != materialNames.cend(); ++iter)
for(const Ogre::String &materialName : materialNames)
{
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName(materialName);
//No checking
Ogre::Pass* pass = mat->getTechnique(0)->getPass(0);
Ogre::GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
if(params->_findNamedConstantDefinition(namer))
params->setNamedConstant(namer,_SHC_R[paramIdx]);
if(params->_findNamedConstantDefinition(nameg))
params->setNamedConstant(nameg,_SHC_G[paramIdx]);
if(params->_findNamedConstantDefinition(nameb))
params->setNamedConstant(nameb,_SHC_B[paramIdx]);
}
}
示例13: notifyMaterialRender
//---------------------------------------------------------------------------
void HeatVisionListener::notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
{
if(pass_id == 0xDEADBABE)
{
// "random_fractions" parameter
fpParams->setNamedConstant("random_fractions", Ogre::Vector4(Ogre::Math::RangeRandom(0.0, 1.0), Ogre::Math::RangeRandom(0, 1.0), 0, 0));
// "depth_modulator" parameter
float inc = ((float)timer->getMilliseconds())/1000.0f;
if ( (fabs(curr-end) <= 0.001) ) {
// take a new value to reach
end = Ogre::Math::RangeRandom(0.95, 1.0);
start = curr;
} else {
if (curr > end) curr -= inc;
else curr += inc;
}
timer->reset();
fpParams->setNamedConstant("depth_modulator", Ogre::Vector4(curr, 0, 0, 0));
}
}
示例14: UpdMiniTer
void App::UpdMiniTer()
{
MaterialPtr mm = MaterialManager::getSingleton().getByName("circle_minimap");
Pass* pass = mm->getTechnique(0)->getPass(0);
if (!pass) return;
try
{ Ogre::GpuProgramParametersSharedPtr fparams = pass->getFragmentProgramParameters();
if(fparams->_findNamedConstantDefinition("showTerrain",false))
{
fparams->setNamedConstant("showTerrain", pSet->mini_terrain ? 1.f : 0.f);
}
}catch(...){ }
}
示例15: SetMaterialParameters
void CompositionHandler::SetMaterialParameters(const Ogre::MaterialPtr &material, const QList< std::pair<std::string, Ogre::Vector4> > &source) const
{
assert (material.get());
material->load();
for(ushort t=0 ; t<material->getNumTechniques() ; ++t)
{
Ogre::Technique *technique = material->getTechnique(t);
if (technique)
{
for(ushort p=0 ; p<technique->getNumPasses() ; ++p)
{
Ogre::Pass *pass = technique->getPass(p);
if (pass)
{
if (pass->hasVertexProgram())
{
Ogre::GpuProgramParametersSharedPtr destination = pass->getVertexProgramParameters();
for(int i=0 ; i<source.size() ; ++i)
{
if (destination->_findNamedConstantDefinition(source[i].first, false))
destination->setNamedConstant(source[i].first, source[i].second);
}
}
if (pass->hasFragmentProgram())
{
Ogre::GpuProgramParametersSharedPtr destination = pass->getFragmentProgramParameters();
for(int i=0 ; i<source.size() ; ++i)
{
if (destination->_findNamedConstantDefinition(source[i].first, false))
destination->setNamedConstant(source[i].first, source[i].second);
}
}
}
}
}
}
}