本文整理汇总了C++中ogre::TextureUnitState::setTextureAddressingMode方法的典型用法代码示例。如果您正苦于以下问题:C++ TextureUnitState::setTextureAddressingMode方法的具体用法?C++ TextureUnitState::setTextureAddressingMode怎么用?C++ TextureUnitState::setTextureAddressingMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::TextureUnitState
的用法示例。
在下文中一共展示了TextureUnitState::setTextureAddressingMode方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildDepthShadowMaterial
//-------------------------------------------------------------------------------
Ogre::MaterialPtr CSceneManagerEditor::buildDepthShadowMaterial(Ogre::MaterialPtr cpyMat)
{
if(mShadowsTechnique->get() >= (int)Ogre::SHADOWTYPE_TEXTURE_ADDITIVE && mShadowsTechnique->get() <= (int)Ogre::SHADOWTYPE_TEXTURE_MODULATIVE_INTEGRATED)
{
Ogre::String matName = "DepthShadows/" + cpyMat->getName();
Ogre::MaterialPtr ret = Ogre::MaterialManager::getSingleton().getByName(matName);
if (ret.isNull())
{
ret = cpyMat->clone(matName);
Ogre::Technique *t = ret->getTechnique(0);
t->setShadowCasterMaterial("Ogre/shadow/depth/caster");
Ogre::Pass *p = t->getPass(0);
p->setVertexProgram("Ogre/shadow/receiver/depth/pssm3/vp");
p->setFragmentProgram("Ogre/shadow/receiver/depth/pssm3/fp");
Ogre::TextureUnitState *tu = p->createTextureUnitState();
tu->setName("shadow0");
tu->setContentType(Ogre::TextureUnitState::CONTENT_SHADOW);
tu->setTextureAddressingMode(Ogre::TextureUnitState::TAM_BORDER);
tu->setTextureBorderColour(Ogre::ColourValue(1,1,1,1));
tu = p->createTextureUnitState();
tu->setName("shadow1");
tu->setContentType(Ogre::TextureUnitState::CONTENT_SHADOW);
tu->setTextureAddressingMode(Ogre::TextureUnitState::TAM_BORDER);
tu->setTextureBorderColour(Ogre::ColourValue(1,1,1,1));
tu = p->createTextureUnitState();
tu->setName("shadow2");
tu->setContentType(Ogre::TextureUnitState::CONTENT_SHADOW);
tu->setTextureAddressingMode(Ogre::TextureUnitState::TAM_BORDER);
tu->setTextureBorderColour(Ogre::ColourValue(1,1,1,1));
Ogre::Vector4 splitPoints;
const Ogre::PSSMShadowCameraSetup::SplitPointList& splitPointList =
static_cast<Ogre::PSSMShadowCameraSetup*>(mPSSMSetup.get())->getSplitPoints();
for (int i = 0; i < 3; ++i)
{
splitPoints[i] = splitPointList[i];
}
p->getFragmentProgramParameters()->setNamedConstant("pssmSplitPoints", splitPoints);
}
return ret;
}
else
return cpyMat;
}
示例2: AddMaterial
void TerrainProjectionMarker::AddMaterial(const string& matName)
{
// check if material is already added or there's no material
if( _targetMaterials.find(matName) != _targetMaterials.end() ||
matName.empty() )
{
return;
}
string matName2 = "StoreMat";
// get the material ptr
Ogre::MaterialPtr mat = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().getByName(matName);
// create a new pass in the material to render the decal
Ogre::Pass* pass = mat->getTechnique(0)->createPass();
// set up the decal's texture unit
Ogre::TextureUnitState *texState = pass->createTextureUnitState(GetTextureName());
texState->setProjectiveTexturing(true, _projectionFrustum);
texState->setTextureAddressingMode(Ogre::TextureUnitState::TAM_WRAP);
texState->setTextureFiltering(Ogre::FO_POINT, Ogre::FO_LINEAR, Ogre::FO_NONE);
texState->setAlphaOperation(Ogre::LBX_ADD);
// set our pass to blend the decal over the model's regular texture
pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
pass->setDepthBias(2.5f, 2.5f);
pass->setDepthCheckEnabled(false);
// set the decal to be self illuminated instead of lit by scene lighting
pass->setLightingEnabled(false);
// save pass in map
_targetMaterials[matName] = pass;
}
示例3: setAtmosphereDepthImage
void SkyDome::setAtmosphereDepthImage (const Ogre::String& atmosphereDepth)
{
if (!mShadersEnabled) {
return;
}
Ogre::TextureUnitState* atmosphereTus =
mMaterial->getTechnique (0)->getPass (0)->getTextureUnitState(1);
atmosphereTus->setTextureName (atmosphereDepth, Ogre::TEX_TYPE_1D);
atmosphereTus->setTextureAddressingMode (Ogre::TextureUnitState::TAM_CLAMP, Ogre::TextureUnitState::TAM_WRAP, Ogre::TextureUnitState::TAM_WRAP);
}
示例4: setSkyGradientsImage
void SkyDome::setSkyGradientsImage (const Ogre::String& gradients)
{
Ogre::TextureUnitState* gradientsTus =
mMaterial->getTechnique (0)->getPass (0)->getTextureUnitState(0);
gradientsTus->setTextureAddressingMode (Ogre::TextureUnitState::TAM_CLAMP);
// Per 1.4 compatibility. Not tested with recent svn.
#if OGRE_VERSION < ((1 << 16) | (3 << 8))
gradientsTus->setTextureName (gradients, Ogre::TEX_TYPE_2D, -1, true);
#else
gradientsTus->setTextureName (gradients, Ogre::TEX_TYPE_2D);
gradientsTus->setIsAlpha (true);
#endif
}
示例5: addShadow
void Simple::addShadow(Ogre::Technique* technique, const TerrainPageShadow* terrainPageShadow, Ogre::MaterialPtr material, std::set<std::string>& managedTextures) const
{
Ogre::Pass* shadowPass = technique->createPass();
shadowPass->setSceneBlending(Ogre::SBT_MODULATE);
shadowPass->setLightingEnabled(false);
// shadowPass->setFog(true, Ogre::FOG_NONE);
Ogre::TextureUnitState * textureUnitStateSplat = shadowPass->createTextureUnitState();
Ogre::TexturePtr texture = updateShadowTexture(material, terrainPageShadow, managedTextures);
textureUnitStateSplat->setTextureName(texture->getName());
textureUnitStateSplat->setTextureCoordSet(0);
textureUnitStateSplat->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
textureUnitStateSplat->setTextureFiltering(Ogre::TFO_ANISOTROPIC);
}
示例6: setImage
void OgreCursor::setImage(const std::string& filename)
{
//std::cerr << __PRETTY_FUNCTION__ << filename << std::endl;
_texture = Ogre::TextureManager::getSingleton().load(filename, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); //"General"
Ogre::TextureUnitState *pTexState;
if (_material->getTechnique(0)->getPass(0)->getNumTextureUnitStates())
{
pTexState = _material->getTechnique(0)->getPass(0)->getTextureUnitState(0);
}
else
{
pTexState = _material->getTechnique(0)->getPass(0)->createTextureUnitState(_texture->getName());
}
pTexState->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
pTexState->setTextureName(filename);
_material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
}
示例7: registerPass
void Decal::registerPass(Ogre::Pass* _Pass)
{
unregister();
_Pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
_Pass->setCullingMode(Ogre::CULL_NONE);
_Pass->setDepthBias(1,1);
_Pass->setLightingEnabled(false);
_Pass->setDepthWriteEnabled(false);
Ogre::TextureUnitState *DecalTexture = _Pass->createTextureUnitState(mTextureName);
DecalTexture->setProjectiveTexturing(true, mProjector);
DecalTexture->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
DecalTexture->setTextureFiltering(Ogre::FO_LINEAR, Ogre::FO_LINEAR, Ogre::FO_NONE);
DecalTexture->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_TEXTURE, Ogre::LBS_MANUAL, 1.0, mTransparency);
mRegisteredPass = _Pass;
}
示例8: CreateRenderTargetOverlay
void RenderWindow::CreateRenderTargetOverlay(int width, int height)
{
width = max(1, width);
height = max(1, height);
Ogre::TexturePtr renderTarget = Ogre::TextureManager::getSingleton().createManual(
rttTextureName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D, width, height, 0, Ogre::PF_A8R8G8B8, Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
Ogre::MaterialPtr rttMaterial = Ogre::MaterialManager::getSingleton().create(
rttMaterialName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::TextureUnitState *rttTuState = rttMaterial->getTechnique(0)->getPass(0)->createTextureUnitState();
rttTuState->setTextureName(rttTextureName);
rttTuState->setTextureFiltering(Ogre::TFO_NONE);
rttTuState->setNumMipmaps(1);
rttTuState->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
rttMaterial->setFog(true, Ogre::FOG_NONE); ///\todo Check, shouldn't here be false?
rttMaterial->setReceiveShadows(false);
rttMaterial->setTransparencyCastsShadows(false);
rttMaterial->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBF_SOURCE_ALPHA, Ogre::SBF_ONE_MINUS_SOURCE_ALPHA);
rttMaterial->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
rttMaterial->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
rttMaterial->getTechnique(0)->getPass(0)->setLightingEnabled(false);
rttMaterial->getTechnique(0)->getPass(0)->setCullingMode(Ogre::CULL_NONE);
overlayContainer = Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "MainWindow Overlay Panel");
overlayContainer->setMaterialName(rttMaterialName);
overlayContainer->setMetricsMode(Ogre::GMM_PIXELS);
overlayContainer->setPosition(0, 0);
overlayContainer->setDimensions((Ogre::Real)width, (Ogre::Real)height);
overlayContainer->setPosition(0,0);
overlay = Ogre::OverlayManager::getSingleton().create("MainWindow Overlay");
overlay->add2D(static_cast<Ogre::OverlayContainer *>(overlayContainer));
overlay->setZOrder(500);
overlay->show();
// ResizeOverlay(width, height);
}
示例9: createMaterial
Ogre::MaterialPtr OgrePlanarReflectionMaterial::createMaterial(const Ogre::TexturePtr& texture, const Ogre::Camera& projectionCamera)
{
using namespace::Ogre;
Ogre::MaterialPtr matPtr = MaterialManager::getSingleton().create(this->getName(),"General");
Ogre::TextureUnitState* t;
if(! textureFilename.getValue().empty() )
{
t = matPtr->getTechnique(0)->getPass(0)->createTextureUnitState(textureFilename.getValue());
}
t = matPtr->getTechnique(0)->getPass(0)->createTextureUnitState(texture->getName() );
t->setColourOperationEx(Ogre::LBX_BLEND_MANUAL, Ogre::LBS_TEXTURE, Ogre::LBS_CURRENT,
Ogre::ColourValue::White, Ogre::ColourValue::White,
blendingFactor.getValue());
t->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
t->setProjectiveTexturing(true,&projectionCamera);
matPtr->compile();
return matPtr;
}
示例10: addLightingPass
void Simple::addLightingPass(Ogre::Technique* technique, std::set<std::string>& managedTextures) const
{
Ogre::Pass* lightingPass = technique->createPass();
lightingPass->setSceneBlending(Ogre::SBT_MODULATE);
lightingPass->setLightingEnabled(false);
Ogre::TextureUnitState * textureUnitStateSplat = lightingPass->createTextureUnitState();
//we need an unique name for our alpha texture
std::stringstream lightingTextureNameSS;
lightingTextureNameSS << technique->getParent()->getName() << "_lighting";
const Ogre::String lightingTextureName(lightingTextureNameSS.str());
Ogre::TexturePtr texture = static_cast<Ogre::TexturePtr>(Ogre::Root::getSingletonPtr()->getTextureManager()->getByName(lightingTextureName));
if (texture.isNull()) {
texture = Ogre::Root::getSingletonPtr()->getTextureManager()->createManual(lightingTextureName, "General", Ogre::TEX_TYPE_2D, mPage.getBlendMapSize(), mPage.getBlendMapSize(), 1, Ogre::PF_L8, Ogre::TU_DYNAMIC_WRITE_ONLY);
managedTextures.insert(texture->getName());
}
Ogre::Image ogreImage;
ogreImage.loadDynamicImage(const_cast<unsigned char*>(mLightingImage->getData()), mLightingImage->getResolution(), mLightingImage->getResolution(), 1, Ogre::PF_L8);
texture->loadImage(ogreImage);
//blit the whole image to the hardware buffer
Ogre::PixelBox sourceBox(ogreImage.getPixelBox());
//blit for each mipmap
for (unsigned int i = 0; i <= texture->getNumMipmaps(); ++i) {
Ogre::HardwarePixelBufferSharedPtr hardwareBuffer(texture->getBuffer(0, i));
hardwareBuffer->blitFromMemory(sourceBox);
}
textureUnitStateSplat->setTextureName(texture->getName());
textureUnitStateSplat->setTextureCoordSet(0);
textureUnitStateSplat->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
textureUnitStateSplat->setTextureFiltering(Ogre::TFO_ANISOTROPIC);
}
示例11: createScene
void RenderState::createScene()
{
////////////////////// Volume texture
// breadVolume.createTexture("media/fields/imagen3-1.field", "volumeTex");
// breadVolume.createTexture("media/fields/mengel3d.field", "volumeTex");
// breadVolume.createTexture("media/fields/3Dbread.256.field", "volumeTex");
breadDensityVolume.createTexture("media/fields/warped.field", "densityTex");
breadDensityTex = breadDensityVolume.getTexturePtr();
if (breadDensityTex.isNull()) {
printf("Error generating density texture");
exit();
}
breadCrustVolume.createTexture("media/fields/warpedC.field", "crustTex");
breadCrustTex = breadCrustVolume.getTexturePtr();
if (breadCrustTex.isNull()) {
printf("Error generating crust texture");
exit();
}
breadOcclusionVolume.createTexture("media/fields/warpedO.field", "occlusionTex");
breadOcclusionTex = breadOcclusionVolume.getTexturePtr();
if (breadOcclusionTex.isNull()) {
printf("Error generating occlusion texture");
exit();
}
///////////////////// Volume bounding cubes
breadVolumeBoundingCubes.create(breadDensityVolume, 32, 1, 255, _sceneMgr);
//////////// Background color
Ogre::Viewport* vp = OgreFramework::getSingletonPtr()->_viewport;
vp->setBackgroundColour (ColourValue(0.1,0.1,0.1));
//////////// Light
_sceneMgr->setAmbientLight(ColourValue(0.1,0.1,0.1));
light = _sceneMgr->createLight("Light");
// light->setType(Light::LT_POINT);
light->setType(Light::LT_SPOTLIGHT);
light->setPosition(100,100,100);
light->setDirection(100,-100,100);
light->setDiffuseColour(1,1,1);
light->setSpecularColour(1.0,1.0,1.0);
light->setSpotlightRange(Radian(M_PI/2), Radian(M_PI/3));
// light->setAttenuation(20, 0.5, 1, 1);
//////////// Shadows
// _sceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);
// _sceneMgr->setShadowTextureSettings( 256, 2);
// _sceneMgr->setShadowTextureConfig( 0, 512, 512, PF_FLOAT16_R, 50 );
////////////////////// BREAD
breadEntity = _sceneMgr->createEntity("BreadEntity", "Cube01.mesh");
breadNode = _sceneMgr->getRootSceneNode()->createChildSceneNode("BreadNode");
breadNode->attachObject(breadEntity);
breadNode->setOrientation(Quaternion::IDENTITY);
breadNode->setPosition(Vector3(0, 0, 0));
breadNode->setScale(Vector3(20,20,20));
// breadEntity->setRenderQueueGroup(RENDER_QUEUE_8);
breadEntity->setCastShadows(true);
breadEntity->getSubEntity(0)->setMaterialName("Bread","General");
breadMat = breadEntity->getSubEntity(0)->getMaterial();
Ogre::Pass* breadPass = breadMat->getTechnique(0)->getPass(0);
Ogre::TextureUnitState* posTU = breadPass->createTextureUnitState("rayPos");
Ogre::TextureUnitState* dirTU = breadPass->createTextureUnitState("rayDir");
posTU->setTextureName("rayPos");
dirTU->setTextureName("rayDir");
posTU->setTextureFiltering(TFO_NONE);
dirTU->setTextureFiltering(TFO_NONE);
posTU->setTextureAddressingMode(TextureUnitState::TAM_CLAMP);
dirTU->setTextureAddressingMode(TextureUnitState::TAM_CLAMP);
/////////////////////// TABLE
tableEntity = _sceneMgr->createEntity("PlaneEntity", "Plane.mesh");
tableEntity->getSubEntity(0)->setMaterialName("Table","General");
tableEntity->setCastShadows(false);
tableNode = _sceneMgr->getRootSceneNode()->createChildSceneNode("PlaneNode");
tableNode->attachObject(tableEntity);
tableNode->setOrientation(Quaternion::IDENTITY);
tableNode->setPosition(Vector3(0, 0, 0));
tableNode->setScale(Vector3(10,10,10));
/////////////////////// KNIFE
knifeEntity = _sceneMgr->createEntity("KnifeEntity", "knife.mesh");
knifeEntity->getSubEntity(0)->setMaterialName("Knife","General");
knifeEntity->setCastShadows(false);
knifeNode = _sceneMgr->getRootSceneNode()->createChildSceneNode("KnifeNode");
knifeNode->attachObject(knifeEntity);
Quaternion ori(Radian(-0.5), Vector3(0,1,0));
knifeNode->setOrientation(ori);
knifeNode->setPosition(Vector3(30, 1, -30));
knifeNode->setScale(Vector3(50,50,50));
//.........这里部分代码省略.........
示例12: create
Ogre::MaterialPtr MaterialGenerator::create(bool renderCompositeMap, bool displayCompositeMap)
{
assert(!renderCompositeMap || !displayCompositeMap);
static int count = 0;
std::stringstream name;
name << "terrain/mat" << count++;
if (!mShaders)
{
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create(name.str(),
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::Technique* technique = mat->getTechnique(0);
technique->removeAllPasses();
if (displayCompositeMap)
{
Ogre::Pass* pass = technique->createPass();
pass->setVertexColourTracking(Ogre::TVC_AMBIENT|Ogre::TVC_DIFFUSE);
pass->createTextureUnitState(mCompositeMap)->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
}
else
{
assert(mLayerList.size() == mBlendmapList.size()+1);
std::vector<Ogre::TexturePtr>::iterator blend = mBlendmapList.begin();
for (std::vector<LayerInfo>::iterator layer = mLayerList.begin(); layer != mLayerList.end(); ++layer)
{
Ogre::Pass* pass = technique->createPass();
pass->setLightingEnabled(false);
pass->setVertexColourTracking(Ogre::TVC_NONE);
// TODO: How to handle fog?
pass->setFog(true, Ogre::FOG_NONE);
bool first = (layer == mLayerList.begin());
Ogre::TextureUnitState* tus;
if (!first)
{
pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
pass->setDepthFunction(Ogre::CMPF_EQUAL);
tus = pass->createTextureUnitState((*blend)->getName());
tus->setAlphaOperation(Ogre::LBX_BLEND_TEXTURE_ALPHA,
Ogre::LBS_TEXTURE,
Ogre::LBS_TEXTURE);
tus->setColourOperationEx(Ogre::LBX_BLEND_DIFFUSE_ALPHA,
Ogre::LBS_TEXTURE,
Ogre::LBS_TEXTURE);
tus->setIsAlpha(true);
tus->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
float scale = (16/(16.f+1.f));
tus->setTextureScale(1.f/scale,1.f/scale);
}
// Add the actual layer texture on top of the alpha map.
tus = pass->createTextureUnitState(layer->mDiffuseMap);
if (!first)
tus->setColourOperationEx(Ogre::LBX_BLEND_DIFFUSE_ALPHA,
Ogre::LBS_TEXTURE,
Ogre::LBS_CURRENT);
tus->setTextureScale(1/16.f,1/16.f);
if (!first)
++blend;
}
if (!renderCompositeMap)
{
Ogre::Pass* lightingPass = technique->createPass();
lightingPass->setSceneBlending(Ogre::SBT_MODULATE);
lightingPass->setVertexColourTracking(Ogre::TVC_AMBIENT|Ogre::TVC_DIFFUSE);
lightingPass->setFog(true, Ogre::FOG_NONE);
}
}
return mat;
}
#if TERRAIN_USE_SHADER
else
{
sh::MaterialInstance* material = sh::Factory::getInstance().createMaterialInstance (name.str());
material->setProperty ("allow_fixed_function", sh::makeProperty<sh::BooleanValue>(new sh::BooleanValue(false)));
if (displayCompositeMap)
{
sh::MaterialInstancePass* p = material->createPass ();
p->setProperty ("vertex_program", sh::makeProperty<sh::StringValue>(new sh::StringValue("terrain_vertex")));
p->setProperty ("fragment_program", sh::makeProperty<sh::StringValue>(new sh::StringValue("terrain_fragment")));
p->mShaderProperties.setProperty ("is_first_pass", sh::makeProperty(new sh::BooleanValue(true)));
p->mShaderProperties.setProperty ("render_composite_map", sh::makeProperty(new sh::BooleanValue(false)));
p->mShaderProperties.setProperty ("display_composite_map", sh::makeProperty(new sh::BooleanValue(true)));
p->mShaderProperties.setProperty ("num_layers", sh::makeProperty (new sh::StringValue("0")));
p->mShaderProperties.setProperty ("num_blendmaps", sh::makeProperty (new sh::StringValue("0")));
p->mShaderProperties.setProperty ("normal_map_enabled", sh::makeProperty (new sh::BooleanValue(false)));
p->mShaderProperties.setProperty ("parallax_enabled", sh::makeProperty (new sh::BooleanValue(false)));
p->mShaderProperties.setProperty ("normal_maps",
//.........这里部分代码省略.........
示例13: addPassToTechnique
//.........这里部分代码省略.........
// textureUnitState->setTextureAddressingMode(Ogre::TextureUnitState::TAM_WRAP);
// /* textureUnitState->setTextureCoordSet(0);*/
// textureUnitState->setTextureScale(0.025, 0.025);
// textureUnitState->setColourOperationEx(Ogre::LBX_BLEND_CURRENT_ALPHA, Ogre::LBS_TEXTURE, Ogre::LBS_CURRENT);
//
// /* Ogre::TextureUnitState * alphaTextureState= pass->createTextureUnitState();
// alphaTextureState->setTextureName(mTextureName);
// // alphaTextureState->setTextureName(splatTextureName);
// alphaTextureState->setTextureCoordSet(0);
// alphaTextureState->setTextureFiltering(Ogre::TFO_ANISOTROPIC);
// alphaTextureState->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
// alphaTextureState->setColourOperationEx(Ogre::LBX_BLEND_DIFFUSE_ALPHA, Ogre::LBS_CURRENT, Ogre::LBS_TEXTURE);
//
//
//
// // detailTextureState->setAlphaOperation(Ogre::LBX_SOURCE1, Ogre::LBS_TEXTURE, Ogre::LBS_TEXTURE);
// // detailTextureState->setColourOperationEx(Ogre::LBX_SOURCE1, Ogre::LBS_CURRENT, Ogre::LBS_CURRENT);
//
// Ogre::TextureUnitState * detailTextureState = pass->createTextureUnitState();
// detailTextureState ->setTextureName(splatTextureName);
// // detailTextureState ->setTextureName(mTextureName);
// detailTextureState ->setTextureAddressingMode(Ogre::TextureUnitState::TAM_WRAP);
// detailTextureState ->setTextureCoordSet(0);
// detailTextureState ->setTextureScale(0.01, 0.01);
// //detailTextureState ->setColourOperationEx(Ogre::LBX_BLEND_CURRENT_ALPHA, Ogre::LBS_TEXTURE, Ogre::LBS_CURRENT);*/
//
// }
//
Ogre::Pass* Simple::addPassToTechnique(const TerrainPageGeometry& geometry, Ogre::Technique* technique, const Layer& layer, std::set<std::string>& managedTextures) const
{
//check if we instead can reuse the existing pass
// if (technique->getNumPasses() != 0) {
// Ogre::Pass* pass = technique->getPass(technique->getNumPasses() - 1);
// if (4 - pass->getNumTextureUnitStates() >= 2) {
// //there's more than two texture units available, use those instead of creating a new pass
// S_LOG_VERBOSE("Reusing existing pass. ("<< pass->getNumTextureUnitStates() << " of "<< mNumberOfTextureUnitsOnCard << " texture unit used)");
// addTextureUnitsToPass(pass, splatTextureName);
// return pass;
// }
//
// }
const OgreImage& ogreImage = *layer.blendMap;
Ogre::Image image;
image.loadDynamicImage(const_cast<unsigned char*>(ogreImage.getData()), ogreImage.getResolution(), ogreImage.getResolution(), 1, Ogre::PF_A8);
std::stringstream splatTextureNameSS;
splatTextureNameSS << "terrain_" << mPage.getWFPosition().x() << "_" << mPage.getWFPosition().y() << "_" << technique->getNumPasses();
const Ogre::String splatTextureName(splatTextureNameSS.str());
Ogre::TexturePtr blendMapTexture;
if (Ogre::Root::getSingletonPtr()->getTextureManager()->resourceExists(splatTextureName)) {
blendMapTexture = static_cast<Ogre::TexturePtr>(Ogre::Root::getSingletonPtr()->getTextureManager()->getByName(splatTextureName));
blendMapTexture->loadImage(image);
Ogre::HardwarePixelBufferSharedPtr hardwareBuffer(blendMapTexture->getBuffer());
//blit the whole image to the hardware buffer
Ogre::PixelBox sourceBox(image.getPixelBox());
hardwareBuffer->blitFromMemory(sourceBox);
} else {
blendMapTexture = Ogre::Root::getSingletonPtr()->getTextureManager()->loadImage(splatTextureName, "General", image, Ogre::TEX_TYPE_2D, 0);
managedTextures.insert(blendMapTexture->getName());
}
//we need to create the image, update it and then destroy it again (to keep the memory usage down)
// if (layer->getBlendMapTextureName() == "") {
// //no texture yet; let's create one
// layer->createBlendMapImage();
// layer->updateBlendMapImage(geometry);
// layer->createTexture();
// } else {
// //a texture exists, so we just need to update the image
// layer->updateBlendMapImage(geometry); //calling this will also update the texture since the method will blit the image onto it
// }
Ogre::Pass* pass = technique->createPass();
pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
pass->setAmbient(1, 1, 1);
pass->setDiffuse(1, 1, 1, 1);
pass->setLightingEnabled(false);
Ogre::TextureUnitState * textureUnitState = pass->createTextureUnitState();
textureUnitState->setTextureName(layer.surfaceLayer.getDiffuseTextureName());
textureUnitState->setTextureAddressingMode(Ogre::TextureUnitState::TAM_WRAP);
textureUnitState->setTextureCoordSet(0);
textureUnitState->setTextureScale(1.0f / layer.surfaceLayer.getScale(), 1.0f / layer.surfaceLayer.getScale());
Ogre::TextureUnitState * textureUnitStateSplat = pass->createTextureUnitState();
textureUnitStateSplat->setTextureName(blendMapTexture->getName());
textureUnitStateSplat->setTextureCoordSet(0);
textureUnitStateSplat->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP);
textureUnitStateSplat->setTextureFiltering(Ogre::TFO_ANISOTROPIC);
// textureUnitStateSplat->setAlphaOperation(Ogre::LBX_SOURCE1, Ogre::LBS_TEXTURE, Ogre::LBS_TEXTURE);
textureUnitStateSplat->setAlphaOperation(Ogre::LBX_BLEND_DIFFUSE_COLOUR, Ogre::LBS_TEXTURE, Ogre::LBS_CURRENT);
textureUnitStateSplat->setColourOperationEx(Ogre::LBX_SOURCE1, Ogre::LBS_CURRENT, Ogre::LBS_CURRENT);
return pass;
}