本文整理汇总了C++中GpuProgramParametersSharedPtr类的典型用法代码示例。如果您正苦于以下问题:C++ GpuProgramParametersSharedPtr类的具体用法?C++ GpuProgramParametersSharedPtr怎么用?C++ GpuProgramParametersSharedPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GpuProgramParametersSharedPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createTexturUnits
//-----------------------------------------------------------------------------------
void PbsMaterial::createTexturUnits(Pass* pass)
{
GpuProgramParametersSharedPtr fragmentParams = pass->getFragmentProgramParameters();
fragmentParams->setIgnoreMissingParams(true);
// Create the texture unit states
for (int i = 0; i < ST_COUNT; i++)
{
SamplerContainer& s = _samplers[i];
if (s.status == SS_ACTIVE || s.status == SS_ADDED || s.status == SS_UPDATED)
{
s.textureUnitState = pass->createTextureUnitState();
s.textureUnitState->setName("in_map_" + s.name);
s.status = SS_UPDATED;
}
else
{
s.status = SS_NOT_ACTIVE;
}
}
// set the sampler name for the texture unit state
int size = pass->getNumTextureUnitStates();
for (int i = 0; i < size; i++)
{
TextureUnitState* tus = pass->getTextureUnitState(i);
fragmentParams->setNamedConstant(tus->getName(), i);
}
_hasSamplerChanged = true;
}
示例2: uvMul
//---------------------------------------------------------------------
void TerrainMaterialGeneratorC::SM2Profile::ShaderHelper::updateVpParams(
const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, const GpuProgramParametersSharedPtr& params)
{
params->setIgnoreMissingParams(true);
uint maxLayers = prof->getMaxLayers(terrain);
uint numLayers = std::min(maxLayers, static_cast<uint>(terrain->getLayerCount()));
uint numUVMul = numLayers / 4;
if (numLayers % 4)
++numUVMul;
for (uint i = 0; i < numUVMul; ++i)
{
Vector4 uvMul(
terrain->getLayerUVMultiplier(i * 4),
terrain->getLayerUVMultiplier(i * 4 + 1),
terrain->getLayerUVMultiplier(i * 4 + 2),
terrain->getLayerUVMultiplier(i * 4 + 3)
);
params->setNamedConstant("uvMul_" + StringConverter::toString(i), uvMul);
}
if (terrain->_getUseVertexCompression() && tt != RENDER_COMPOSITE_MAP)
{
Real baseUVScale = 1.0f / (terrain->getSize() - 1);
params->setNamedConstant("baseUVScale", baseUVScale);
}
}
示例3: while
void CarModel::ChangeClr()
{
int i = iColor;
float c_h = pSet->gui.car_hue[i], c_s = pSet->gui.car_sat[i],
c_v = pSet->gui.car_val[i], gloss = pSet->gui.car_gloss[i], refl = pSet->gui.car_refl[i];
color.setHSB(1-c_h, c_s, c_v); //set, mini pos clr
MaterialPtr mtr = MaterialManager::getSingleton().getByName(sMtr[Mtr_CarBody]);
if (!mtr.isNull())
{ Material::TechniqueIterator techIt = mtr->getTechniqueIterator();
while (techIt.hasMoreElements())
{ Technique* tech = techIt.getNext();
Technique::PassIterator passIt = tech->getPassIterator();
while (passIt.hasMoreElements())
{ Pass* pass = passIt.getNext();
if (pass->hasFragmentProgram())
{
GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
params->setNamedConstant("carColour", color);
params->setNamedConstant("glossiness", 1 - gloss);
params->setNamedConstant("reflectiveness", refl);
} } } }
if (pNickTxt)
pNickTxt->setTextColour(MyGUI::Colour(color.r,color.g,color.b));
// opp list text and mini pos colors - auto in hud update
}
示例4: pixelSize
void DepthOfFieldListener::notifyMaterialRender(uint32 pass_id, MaterialPtr &mat)
{
if(pass_id == 2)
{
float blurScale =.5f;
Vector4 pixelSize(1.0f / mViewportWidth, 1.0f / mViewportHeight,1.0f / (mViewportWidth * blurScale), 1.0f / (mViewportHeight * blurScale) );
Pass *pass = mat->getBestTechnique()->getPass(0);
GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
if (params->_findNamedConstantDefinition("pixelSize"))
params->setNamedConstant("pixelSize", pixelSize);
// this is the camera you're using
#ifndef SR_EDITOR
Camera *cam = mApp->mSplitMgr->mCameras.front();
#else
Camera *cam = mApp->mCamera;
#endif
if (params->_findNamedConstantDefinition("dofparams"))
{
Vector4 dofParams(0.0f,mApp->pSet->dof_focus,mApp->pSet->dof_far,1.0);
params->setNamedConstant("dofparams", dofParams);
}
}
}
示例5: setUpBaseParameters
void setUpBaseParameters(const GpuProgramParametersSharedPtr& params)
{
assert(params.isNull()==false);
struct AutoParamPair { String name; GpuProgramParameters::AutoConstantType type; };
//A list of auto params that might be present in the shaders generated
static const AutoParamPair AUTO_PARAMS[] = {
{ "vpWidth", GpuProgramParameters::ACT_VIEWPORT_WIDTH },
{ "vpHeight", GpuProgramParameters::ACT_VIEWPORT_HEIGHT },
{ "worldView", GpuProgramParameters::ACT_WORLDVIEW_MATRIX },
{ "invProj", GpuProgramParameters::ACT_INVERSE_PROJECTION_MATRIX },
{ "invView", GpuProgramParameters::ACT_INVERSE_VIEW_MATRIX },
{ "flip", GpuProgramParameters::ACT_RENDER_TARGET_FLIPPING },
{ "lightDiffuseColor", GpuProgramParameters::ACT_LIGHT_DIFFUSE_COLOUR },
{ "lightSpecularColor", GpuProgramParameters::ACT_LIGHT_SPECULAR_COLOUR },
{ "lightFalloff", GpuProgramParameters::ACT_LIGHT_ATTENUATION },
{ "lightPos", GpuProgramParameters::ACT_LIGHT_POSITION_VIEW_SPACE },
{ "lightDir", GpuProgramParameters::ACT_LIGHT_DIRECTION_VIEW_SPACE },
{ "spotParams", GpuProgramParameters::ACT_SPOTLIGHT_PARAMS },
{ "farClipDistance", GpuProgramParameters::ACT_FAR_CLIP_DISTANCE },
{ "shadowViewProjMat", 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);
}
}
}
示例6: frameUpdate
void GrassLoader::frameUpdate()
{
unsigned long currentTime = windTimer.getMilliseconds();
unsigned long ellapsedTime = currentTime - lastTime;
lastTime = currentTime;
float ellapsed = ellapsedTime / 1000.0f;
//Update the vertex shader parameters
std::list<GrassLayer*>::iterator it;
for (it = layerList.begin(); it != layerList.end(); ++it){
GrassLayer *layer = *it;
layer->_updateShaders();
GpuProgramParametersSharedPtr params = layer->material->getTechnique(0)->getPass(0)->getVertexProgramParameters();
if (layer->animate){
//Increment animation frame
layer->waveCount += ellapsed * (layer->animSpeed * Math::PI);
if (layer->waveCount > Math::PI*2) layer->waveCount -= Math::PI*2;
//Set vertex shader parameters
params->setNamedConstant("time", layer->waveCount);
params->setNamedConstant("frequency", layer->animFreq);
Vector3 direction = windDir * layer->animMag;
params->setNamedConstant("direction", Vector4(direction.x, direction.y, direction.z, 0));
}
}
}
示例7: populateParameterNames
//---------------------------------------------------------------------
void HighLevelGpuProgram::populateParameterNames(GpuProgramParametersSharedPtr params)
{
getConstantDefinitions();
params->_setNamedConstants(mConstantDefs);
// also set logical / physical maps for programs which use this
params->_setLogicalIndexes(mFloatLogicalToPhysical, mDoubleLogicalToPhysical, mIntLogicalToPhysical);
}
示例8: updatePassIterationUniforms
//-----------------------------------------------------------------------
void GLSLESProgramPipeline::updatePassIterationUniforms(GpuProgramParametersSharedPtr params)
{
if (params->hasPassIterationNumber())
{
size_t index = params->getPassIterationNumberIndex();
GLUniformReferenceIterator currentUniform = mGLUniformReferences.begin();
GLUniformReferenceIterator endUniform = mGLUniformReferences.end();
// Need to find the uniform that matches the multi pass entry
for (;currentUniform != endUniform; ++currentUniform)
{
// Get the index in the parameter real list
if (index == currentUniform->mConstantDef->physicalIndex)
{
#if OGRE_PLATFORM != OGRE_PLATFORM_NACL
GLuint progID = 0;
if (getVertexProgram() && currentUniform->mSourceProgType == GPT_VERTEX_PROGRAM)
{
progID = getVertexProgram()->getGLProgramHandle();
OGRE_CHECK_GL_ERROR(glProgramUniform1fvEXT(progID, currentUniform->mLocation, 1, params->getFloatPointer(index)));
}
if (mFragmentProgram && currentUniform->mSourceProgType == GPT_FRAGMENT_PROGRAM)
{
progID = mFragmentProgram->getGLProgramHandle();
OGRE_CHECK_GL_ERROR(glProgramUniform1fvEXT(progID, currentUniform->mLocation, 1, params->getFloatPointer(index)));
}
#endif
// There will only be one multipass entry
return;
}
}
}
}
示例9:
//---------------------------------------------------------------------
void TerrainMaterialGeneratorC::SM2Profile::ShaderHelper::defaultFpParams(
const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, const HighLevelGpuProgramPtr& prog)
{
GpuProgramParametersSharedPtr params = prog->getDefaultParameters();
params->setIgnoreMissingParams(true);
params->setNamedAutoConstant("fogColour", GpuProgramParameters::ACT_FOG_COLOUR);
params->setNamedAutoConstant("cFarDistance", Ogre::GpuProgramParameters::ACT_FAR_CLIP_DISTANCE);
params->setNamedAutoConstant("viewMatrix", GpuProgramParameters::ACT_WORLDVIEW_MATRIX); // tout sauf Z : VIEW_MATRIX
}
示例10: scaleBiasSpecular
//---------------------------------------------------------------------
void TerrainMaterialGeneratorA::SM2Profile::ShaderHelper::updateFpParams(
const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, const GpuProgramParametersSharedPtr& params)
{
params->setIgnoreMissingParams(true);
// TODO - parameterise this?
Vector4 scaleBiasSpecular(0.03, -0.04, 32, 1);
params->setNamedConstant("scaleBiasSpecular", scaleBiasSpecular);
}
示例11: bindAutoParameters
//-----------------------------------------------------------------------------
void ProgramProcessor::bindAutoParameters(Program* pCpuProgram, GpuProgramPtr pGpuProgram)
{
GpuProgramParametersSharedPtr pGpuParams = pGpuProgram->getDefaultParameters();
const UniformParameterList& progParams = pCpuProgram->getParameters();
UniformParameterConstIterator itParams;
for (itParams=progParams.begin(); itParams != progParams.end(); ++itParams)
{
const UniformParameterPtr pCurParam = *itParams;
const GpuConstantDefinition* gpuConstDef = pGpuParams->_findNamedConstantDefinition(pCurParam->getName());
if (gpuConstDef != NULL)
{
// Handle auto parameters.
if (pCurParam->isAutoConstantParameter())
{
if (pCurParam->isAutoConstantRealParameter())
{
pGpuParams->setNamedAutoConstantReal(pCurParam->getName(),
pCurParam->getAutoConstantType(),
pCurParam->getAutoConstantRealData());
}
else if (pCurParam->isAutoConstantIntParameter())
{
pGpuParams->setNamedAutoConstant(pCurParam->getName(),
pCurParam->getAutoConstantType(),
pCurParam->getAutoConstantIntData());
}
}
// Case this is not auto constant - we have to update its variability ourself.
else
{
gpuConstDef->variability |= pCurParam->getVariability();
// Update variability in the float map.
if (gpuConstDef->isSampler() == false)
{
GpuLogicalBufferStructPtr floatLogical = pGpuParams->getFloatLogicalBufferStruct();
if (floatLogical.get())
{
for (GpuLogicalIndexUseMap::const_iterator i = floatLogical->map.begin(); i != floatLogical->map.end(); ++i)
{
if (i->second.physicalIndex == gpuConstDef->physicalIndex)
{
i->second.variability |= gpuConstDef->variability;
break;
}
}
}
}
}
}
}
}
示例12:
//-----------------------------------------------------------------------
GpuProgramParametersSharedPtr D3D10HLSLProgram::createParameters(void)
{
// Call superclass
GpuProgramParametersSharedPtr params = HighLevelGpuProgram::createParameters();
// D3D HLSL uses column-major matrices
params->setTransposeMatrices(true);
return params;
}
示例13: bindProgramPassIterationParameters
void ATI_FS_GLGpuProgram::bindProgramPassIterationParameters(GpuProgramParametersSharedPtr params)
{
if (params->hasPassIterationNumber())
{
size_t physicalIndex = params->getPassIterationNumberIndex();
size_t logicalIndex = params->getFloatLogicalIndexForPhysicalIndex(physicalIndex);
const float* pFloat = params->getFloatPointer(physicalIndex);
glSetFragmentShaderConstantATI( GL_CON_0_ATI + (GLuint)logicalIndex, pFloat);
}
}
示例14: toneMapSettings
void HDRListener::notifyMaterialRender(uint32 pass_id, MaterialPtr &mat)
{
if (pass_id == 600 || pass_id == 800)
{
Pass *pass = mat->getBestTechnique()->getPass(0);
GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
if (params->_findNamedConstantDefinition("toneMapSettings"))
{
Vector4 toneMapSettings(1-mApp->pSet->hdrParam1, mApp->pSet->hdrParam2, mApp->pSet->hdrParam3, 1.0);
params->setNamedConstant("toneMapSettings", toneMapSettings);
}
if (params->_findNamedConstantDefinition("bloomSettings"))
{
Vector4 bloomSettings(mApp->pSet->hdrBloomorig*2, mApp->pSet->hdrBloomint, 1.0, 1.0);
params->setNamedConstant("bloomSettings", bloomSettings);
}
if (params->_findNamedConstantDefinition("vignettingSettings"))
{
Vector4 vignettingSettings(mApp->pSet->vignRadius, mApp->pSet->vignDarkness, 1.0, 1.0);
params->setNamedConstant("vignettingSettings", vignettingSettings);
}
}
else if(pass_id == 989)
{
Pass *pass = mat->getBestTechnique()->getPass(0);
GpuProgramParametersSharedPtr params = pass->getFragmentProgramParameters();
if (params->_findNamedConstantDefinition("AdaptationScale"))
{
params->setNamedConstant("AdaptationScale", mApp->pSet->hdrAdaptationScale);
}
}
}
示例15: generateFragmentShader
virtual GpuProgramPtr generateFragmentShader(Perm permutation)
{
/// Create shader
if (mMasterSource.empty())
{
DataStreamPtr ptrMasterSource;
if(GpuProgramManager::getSingleton().isSyntaxSupported("glsles"))
ptrMasterSource = ResourceGroupManager::getSingleton().openResource("DeferredShading/post/LightMaterial_ps.glsles",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
else
ptrMasterSource = ResourceGroupManager::getSingleton().openResource("DeferredShading/post/LightMaterial_ps.glsl",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
assert(ptrMasterSource.isNull()==false);
mMasterSource = ptrMasterSource->getAsString();
}
assert(mMasterSource.empty()==false);
// Create name
String name = mBaseName+StringConverter::toString(permutation)+"_ps";
// Create shader object
HighLevelGpuProgramPtr ptrProgram;
if(GpuProgramManager::getSingleton().isSyntaxSupported("glsles"))
{
ptrProgram = HighLevelGpuProgramManager::getSingleton().createProgram(name, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
"glsles", GPT_FRAGMENT_PROGRAM);
ptrProgram->setParameter("profiles", "glsles");
}
else
{
ptrProgram = HighLevelGpuProgramManager::getSingleton().createProgram(name, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
"glsl", GPT_FRAGMENT_PROGRAM);
ptrProgram->setParameter("profiles", "glsl150");
}
ptrProgram->setSource(mMasterSource);
// set up the preprocessor defines
// Important to do this before any call to get parameters, i.e. before the program gets loaded
ptrProgram->setParameter("preprocessor_defines", getPPDefines(permutation));
setUpBaseParameters(ptrProgram->getDefaultParameters());
// Bind samplers
GpuProgramParametersSharedPtr params = ptrProgram->getDefaultParameters();
int numSamplers = 0;
params->setNamedConstant("Tex0", (int)numSamplers++);
params->setNamedConstant("Tex1", (int)numSamplers++);
if(permutation & LightMaterialGenerator::MI_SHADOW_CASTER)
params->setNamedConstant("ShadowTex", (int)numSamplers++);
return GpuProgramPtr(ptrProgram);
}