int lua_Technique_removeParameter(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 2: { if ((lua_type(state, 1) == LUA_TUSERDATA) && (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL)) { // Get parameter 1 off the stack. const char* param1 = gameplay::ScriptUtil::getString(2, false); Technique* instance = getInstance(state); instance->removeParameter(param1); return 0; } lua_pushstring(state, "lua_Technique_removeParameter - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 2)."); lua_error(state); break; } } return 0; }
void MaterialFactory::setShadowsEnabled(bool bEnable) { for (std::vector<MaterialDefinition*>::iterator it=mDefinitions.begin(); it!=mDefinitions.end(); ++it) { MaterialPtr mat = MaterialManager::getSingleton().getByName( (*it)->getName() ); if (mat.isNull()) continue; Material::TechniqueIterator techIt = mat->getTechniqueIterator(); while (techIt.hasMoreElements()) { Technique* tech = techIt.getNext(); Technique::PassIterator passIt = tech->getPassIterator(); while (passIt.hasMoreElements()) { Pass* pass = passIt.getNext(); if (pass->hasFragmentProgram()) { if ( pass->getFragmentProgramParameters()->_findNamedConstantDefinition("enableShadows", false)) pass->getFragmentProgramParameters()->setNamedConstant("enableShadows", Real(bEnable)); } } } } }
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 }
void BatchPage::build() { batch->build(); BatchedGeometry::SubBatchIterator it = batch->getSubBatchIterator(); while (it.hasMoreElements()){ BatchedGeometry::SubBatch *subBatch = it.getNext(); MaterialPtr mat = subBatch->getMaterial(); //Disable specular unless a custom shader is being used. //This is done because the default shader applied by BatchPage //doesn't support specular, and fixed-function needs to look //the same as the shader (for computers with no shader support) for (int t = 0; t < mat->getNumTechniques(); ++t){ Technique *tech = mat->getTechnique(t); for (int p = 0; p < tech->getNumPasses(); ++p){ Pass *pass = tech->getPass(p); if (pass->getVertexProgramName() == "") pass->setSpecular(0, 0, 0, 1); } } //Store the original materials unfadedMaterials.push_back(subBatch->getMaterial()); } _updateShaders(); }
int GameScript::getSafeTextureUnitState(TextureUnitState **tu, const String materialName, int techniqueNum, int passNum, int textureUnitNum) { try { MaterialPtr m = MaterialManager::getSingleton().getByName(materialName); if (m.isNull()) return 1; // verify technique if (techniqueNum < 0 || techniqueNum > m->getNumTechniques()) return 2; Technique *t = m->getTechnique(techniqueNum); if (!t) return 2; //verify pass if (passNum < 0 || passNum > t->getNumPasses()) return 3; Pass *p = t->getPass(passNum); if (!p) return 3; //verify texture unit if (textureUnitNum < 0 || textureUnitNum > p->getNumTextureUnitStates()) return 4; TextureUnitState *tut = p->getTextureUnitState(textureUnitNum); if (!tut) return 4; *tu = tut; return 0; } catch(Exception e) { SLOG("Exception in getSafeTextureUnitState(): " + e.getFullDescription()); } return 1; }
//----------------------------------------------------------------------------- /// void BatchPage::build() { m_pBatchGeom->build(); BatchedGeometry::TSubBatchIterator it = m_pBatchGeom->getSubBatchIterator(); while (it.hasMoreElements()) { BatchedGeometry::SubBatch *subBatch = it.getNext(); const MaterialPtr &ptrMat = subBatch->getMaterial(); //Disable specular unless a custom shader is being used. //This is done because the default shader applied by BatchPage //doesn't support specular, and fixed-function needs to look //the same as the shader (for computers with no shader support) for (unsigned short t = 0, tCnt = ptrMat->getNumTechniques(); t < tCnt; ++t) { Technique *tech = ptrMat->getTechnique(t); for (unsigned short p = 0, pCnt = tech->getNumPasses(); p < pCnt; ++p) { Pass *pass = tech->getPass(p); //if (pass->getVertexProgramName() == "") // pass->setSpecular(0, 0, 0, 1); if (!pass->hasVertexProgram()) pass->setSpecular(0.f, 0.f, 0.f, 1.f); } } //Store the original materials m_vecUnfadedMaterials.push_back(subBatch->getMaterial()); } _updateShaders(); }
void Model::setMaterialNodeBinding(Material *material) { GP_ASSERT(material); if (_node) { material->setNodeBinding(_node); unsigned int techniqueCount = material->getTechniqueCount(); for (unsigned int i = 0; i < techniqueCount; ++i) { Technique* technique = material->getTechniqueByIndex(i); GP_ASSERT(technique); technique->setNodeBinding(_node); unsigned int passCount = technique->getPassCount(); for (unsigned int j = 0; j < passCount; ++j) { Pass* pass = technique->getPassByIndex(j); GP_ASSERT(pass); pass->setNodeBinding(_node); } } } }
static int lua_Technique_addRef(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 1: { if ((lua_type(state, 1) == LUA_TUSERDATA)) { Technique* instance = getInstance(state); instance->addRef(); return 0; } lua_pushstring(state, "lua_Technique_addRef - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 1)."); lua_error(state); break; } } return 0; }
static int lua_Technique_getPassCount(lua_State* state) { // Get the number of parameters. int paramCount = lua_gettop(state); // Attempt to match the parameters to a valid binding. switch (paramCount) { case 1: { if ((lua_type(state, 1) == LUA_TUSERDATA)) { Technique* instance = getInstance(state); unsigned int result = instance->getPassCount(); // Push the return value onto the stack. lua_pushunsigned(state, result); return 1; } lua_pushstring(state, "lua_Technique_getPassCount - Failed to match the given parameters to a valid function signature."); lua_error(state); break; } default: { lua_pushstring(state, "Invalid number of parameters (expected 1)."); lua_error(state); break; } } return 0; }
void App::createRoadSelMtr(String sMtrName) { MaterialPtr mat = MaterialManager::getSingleton().getByName(sMtrName); if (!mat.isNull() && mat->getNumTechniques()>0) { /*unsigned short np = mat->getTechnique(0)->getNumPasses()-1; // last unsigned! try { if (mat->getTechnique(0)->getPass(np)->hasFragmentProgram() && mat->getTechnique(0)->getPass(np)->getFragmentProgramParameters()->_findNamedConstantDefinition("pssmSplitPoints",false) ) mat->getTechnique(0)->getPass(np)->getFragmentProgramParameters()->setNamedConstant("pssmSplitPoints", splitPoints); } catch(...) { }*/ // create selected materials for road if (StringUtil::startsWith(sMtrName,"road",false) || StringUtil::startsWith(sMtrName,"pipe",false) ) { String selName = sMtrName + "_sel"; MaterialPtr selMtr = MaterialManager::getSingleton().getByName(selName); if (selMtr.isNull()) { // once //LogO("new sel mtr: " +selName); MaterialPtr sel = mat->clone(selName); Technique* tech = sel->getTechnique(0); Pass* p = tech->createPass(); p->setSceneBlending(SBT_ADD); p->setDepthBias(3.f);// p->setAmbient(0,0,0); p->setDiffuse(0,0,0,0); p->setSpecular(0,0,0,0); p->setDepthCheckEnabled(false); p->setDepthWriteEnabled(true); p->setCullingMode(CULL_NONE); p->setFragmentProgram("sel_ps"); //p->setSelfIllumination(0,0.1,0.2); } } } }
void SpriteShape::Draw(IGraphicsDevice *device, RenderState &state) { IGraphicsContext *context = device->GetContext(); Effect *effect = context->GetEffect("Sprite"); if(mHasBackgroundImage) { effect->SetActiveTechnique("SpriteTexture"); } else { effect->SetActiveTechnique("SpriteColor"); } glm::mat4 wvp = state.GetWorldViewProjection(); state.SetShaderData(mWVPIndex, &wvp); state.SetShaderData(mFrameIndex, &mFrame); state.SetShaderData(mTextureFrameIndex, &mTexFrame); state.SetShaderData(mBackgroundColorIndex, &mBackgroundColor); if(mBackgroundImage) { state.SetShaderData(mBackgroundImageIndex, mBackgroundImage); } state.SetShaderData(mBorderWidthIndex, &mBorderWidth); state.SetShaderData(mBorderColorIndex, &mBorderColor); if(sSpriteVertexBuffer) { Technique *technique = effect->GetActiveTechnique(); technique->Begin(); while(technique->HasNextPass()) { sSpriteVertexBuffer->Activate(); technique->ProcessNextPass(device, state); device->Draw(PrimitiveTypeTriangleStrip, 4, 0); } } }
//----------------------------------------------------------------------- void RenderQueue::addRenderable(Renderable* pRend, uint8 groupID, ushort priority) { // Find group RenderQueueGroup* pGroup = getQueueGroup(groupID); Technique* pTech; // tell material it's been used if (!pRend->getMaterial().isNull()) pRend->getMaterial()->touch(); // Check material & technique supplied (the former since the default implementation // of getTechnique is based on it for backwards compatibility if(pRend->getMaterial().isNull() || !(pTech = pRend->getTechnique())) { // Use default base white MaterialPtr baseWhite = MaterialManager::getSingleton().getByName("BaseWhite"); pTech = baseWhite->getTechnique(0); } if (mRenderableListener) { // Allow listener to override technique and to abort if (!mRenderableListener->renderableQueued(pRend, groupID, priority, &pTech, this)) return; // rejected // tell material it's been used (incase changed) pTech->getParent()->touch(); } pGroup->addRenderable(pRend, pTech, priority); }
void App::materialCreated(sh::MaterialInstance* m, const std::string& configuration, unsigned short lodIndex) { Technique* t = static_cast<sh::OgreMaterial*>(m->getMaterial())->getOgreTechniqueForConfiguration (configuration, lodIndex); if (pSet->shadow_type == Sh_None) { t->setShadowCasterMaterial(""); return; } /*if (m->hasProperty("transparent") && m->hasProperty("cull_hardware") && sh::retrieveValue<sh::StringValue>(m->getProperty("cull_hardware"), 0).get() == "none") { // Crash !? assert(!MaterialManager::getSingleton().getByName("PSSM/shadow_caster_nocull").isNull ()); t->setShadowCasterMaterial("shadowcaster_nocull"); }*/ if (m->hasProperty("instancing") && sh::retrieveValue<sh::StringValue>(m->getProperty("instancing"), 0).get() == "true") { t->setShadowCasterMaterial("shadowcaster_instancing"); } if (!m->hasProperty("transparent") || !sh::retrieveValue<sh::BooleanValue>(m->getProperty("transparent"), 0).get()) { t->setShadowCasterMaterial("shadowcaster_noalpha"); } }
void visit(Renderable* rend, ushort lodIndex, bool isDebug, Any* pAny = 0) { Technique* tech = rend->getTechnique(); bool techReceivesShadows = tech && tech->getParent()->getReceiveShadows(); anyReceiveShadows = anyReceiveShadows || techReceivesShadows || !tech; }
void Material::ReleaseShaders() { for (unsigned i = 0; i < techniques_.Size(); ++i) { Technique* tech = techniques_[i].technique_; if (tech) tech->ReleaseShaders(); } }
int main(int argc, char **argv) { //Initialize glut glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_RGBA | GLUT_DOUBLE); glutInitWindowPosition(50, 25); glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT); glutCreateWindow("GL Test"); glutDisplayFunc(Render); glutIdleFunc(Render); glutSpecialFunc(keyHandler); glutKeyboardFunc(specialHandler); glutPassiveMotionFunc(mouseHandler); //Initialize glew GLenum res = glewInit(); if(res != GLEW_OK) return 1; //Set up GL state glFrontFace(GL_CCW); glCullFace(GL_BACK); glEnable(GL_CULL_FACE); glDepthFunc(GL_LEQUAL); glEnable(GL_DEPTH_TEST); //Set up renderer eye = new Camera(WINDOW_WIDTH, WINDOW_HEIGHT); eye->mPos = glm::vec3(0.0f, 0.0f, 3.0f); pipeline.setCamera(eye); //Set up the technique tech.usePipeline(&pipeline); solid.usePipeline(&pipeline); //Load scene Light::PntLight light; light.mPos = glm::vec3(1.0f, 0.0f, 0.0f); light.mCol = glm::vec3(1.0f, 0.0f, 0.0f); LoadedMesh dragonMesh = LoadedMesh("Assets/Dragon/Dargon posing.obj"); Entity dragon = Entity(&dragonMesh); LoadedMesh potMesh = LoadedMesh("Assets/teapot.obj"); Entity pot = Entity(&potMesh); pot.updateScale(glm::vec3(0.1f, 0.1f, 0.1f)); scene.addEntity(dragon); scene.addEntity(pot); scene.addLight(light); //Start loop glutMainLoop(); return 0; }
//----------------------------------------------------------------------- void DeferredLightRenderOperation::execute(SceneManager *sm, RenderSystem *rs) { Ogre::Camera* cam = mViewport->getCamera(); mAmbientLight->updateFromCamera(cam); Technique* tech = mAmbientLight->getMaterial()->getBestTechnique(); injectTechnique(sm, tech, mAmbientLight, 0); const LightList& lightList = sm->_getLightsAffectingFrustum(); for (LightList::const_iterator it = lightList.begin(); it != lightList.end(); it++) { Light* light = *it; Ogre::LightList ll; ll.push_back(light); //if (++i != 2) continue; //if (light->getType() != Light::LT_DIRECTIONAL) continue; //if (light->getDiffuseColour() != ColourValue::Red) continue; LightsMap::iterator dLightIt = mLights.find(light); DLight* dLight = 0; if (dLightIt == mLights.end()) { dLight = createDLight(light); } else { dLight = dLightIt->second; dLight->updateFromParent(); } dLight->updateFromCamera(cam); tech = dLight->getMaterial()->getBestTechnique(); //Update shadow texture if (dLight->getCastChadows()) { SceneManager::RenderContext* context = sm->_pauseRendering(); sm->prepareShadowTextures(cam, mViewport, &ll); sm->_resumeRendering(context); Pass* pass = tech->getPass(0); TextureUnitState* tus = pass->getTextureUnitState("ShadowMap"); assert(tus); const TexturePtr& shadowTex = sm->getShadowTexture(0); if (tus->_getTexturePtr() != shadowTex) { tus->_setTexturePtr(shadowTex); } } injectTechnique(sm, tech, dLight, &ll); } }
//-------------------------------------------------------------------------------- static void setTextureAndTexAniFPS(const MaterialPtr& _material, const String& _texture, Real _texAniFPS) { Technique* technique = _material->getTechnique(0); Pass* pass = technique->getPass(0); if(_texture.empty()) { pass->removeAllTextureUnitStates(); } else { TextureManager& tmgr = TextureManager::getSingleton(); Ogre::TextureUnitState* tus = pass->getNumTextureUnitStates() ? pass->getTextureUnitState(0) : pass->createTextureUnitState(); if(_texAniFPS == 0) { TexturePtr ogreTexture = tmgr.createOrRetrieve(_texture).first; const String& ogreTexName = ogreTexture->getName(); tus->setTextureName(ogreTexName); } else { vector<String>::type ogreTexNames; TexturePtr ogreTexture = tmgr.createOrRetrieve(_texture).first; ogreTexNames.push_back(ogreTexture->getName()); size_t dotpos = _texture.rfind('.'); if(dotpos != String::npos && dotpos >= 1 && '0' <= _texture[dotpos-1] && _texture[dotpos-1] < '9') { String tmpname = _texture; char& dig0 = tmpname[dotpos - 1]; ++dig0; while(!tmgr.getByName(tmpname).isNull() || tmgr.canLoadResource(tmpname, TextureManager::GROUP_NAME)) { TexturePtr ogreTexture = tmgr.createOrRetrieve(tmpname).first; ogreTexNames.push_back(ogreTexture->getName()); ++dig0; if(dig0 > '9') { if(dotpos >= 2 && '0' <= _texture[dotpos-2] && _texture[dotpos-2] < '9') { char& dig1 = tmpname[dotpos-2]; ++dig1; dig0 = '0'; } else break; } } } Real duration = ogreTexNames.size() / _texAniFPS; tus->setAnimatedTextureName(&ogreTexNames[0], ogreTexNames.size(), duration); } } }
void Material::CreateInputLayout(const std::string& technique_name, const std::string& pass_name, D3D11_INPUT_ELEMENT_DESC* input_element_descriptions, UINT input_element_description_count) { Technique* technique = effect_->TechniquesByName().at(technique_name); assert(technique != nullptr); Pass* pass = technique->PassesByName().at(pass_name); assert(pass != nullptr); ID3D11InputLayout* input_layout; pass->CreateInputLayout(input_element_descriptions, input_element_description_count, &input_layout); input_layout_.insert(std::pair<Pass*, ID3D11InputLayout*>(pass, input_layout)); }
void MaterialGenerator::createOccluderTechnique() { Technique* occluderpasstech = mMaterial->createTechnique(); occluderpasstech->setName("occluder"); occluderpasstech->setSchemeName("occluder"); Pass* occluderpass = occluderpasstech->createPass(); HighLevelGpuProgramManager& hmgr = HighLevelGpuProgramManager::getSingleton(); // choose vertex program std::string vprogname = "occluder_vs"; if ( mDef->mProps->transparent ) vprogname = "occluder_coord_vs"; //TODO:this is a workaround until a valid sun material is available to be used. if(StringUtil::startsWith(this->mDef->getName(), "sky/")) { //use the sky object as the sun vprogname = mVertexProgram->getName(); } // choose fragment program std::string fprogname = "occluder_ps"; if ( mDef->mProps->transparent ) fprogname = "occluder_alpha_ps"; //TODO:this is a workaround until a valid sun material is available to be used. if(StringUtil::startsWith(this->mDef->getName(), "sky/")) { //use the sky object as the sun fprogname = mFragmentProgram->getName(); } occluderpass->setVertexProgram(vprogname); occluderpass->setFragmentProgram(fprogname); if (mDef->mProps->alphaRejectValue > 0) occluderpass->setAlphaRejectSettings(mDef->mProps->alphaRejectFunc, mDef->mProps->alphaRejectValue); if ( !mDef->mProps->transparent ) { occluderpass->setCullingMode( chooseCullingMode() ); if(StringUtil::startsWith(this->mDef->getName(), "sky/")) { //Set the sky object as the sun occluderpass->createTextureUnitState( mDiffuseMap ); } } else { occluderpass->setCullingMode( CULL_NONE ); occluderpass->setAlphaRejectSettings(CMPF_GREATER_EQUAL, 128); occluderpass->createTextureUnitState( mDiffuseMap ); } }
void LightInstanceBatchHW::injectRender() { if( (mRenderOperation.numberOfInstances = updateVertexBuffer( mCurrentCamera )) ) { Technique* tech = mMaterial->getBestTechnique(); for (size_t i=0; i<tech->getNumPasses(); ++i) { mManager->_injectRenderWithPass(tech->getPass(i), this, false); } } }
//----------------------------------------------------------------------- bool HardwareSkinning::preAddToRenderState(const RenderState* renderState, Pass* srcPass, Pass* dstPass) { bool isValid = true; Technique* pFirstTech = srcPass->getParent()->getParent()->getTechnique(0); const Any& hsAny = pFirstTech->getUserObjectBindings().getUserAny(HS_DATA_BIND_NAME); if (hsAny.isEmpty() == false) { HardwareSkinning::SkinningData pData = (any_cast<HardwareSkinning::SkinningData>(hsAny)); isValid = pData.isValid; //If the skinning data is being passed through the material, we need to create an instance of the appropriate //skinning type and set its parameters here setHardwareSkinningParam(pData.maxBoneCount, pData.maxWeightCount, pData.skinningType, pData.correctAntipodalityHandling, pData.scalingShearingSupport); } //If there is no associated technique, default to linear skinning as a pass-through if(mActiveTechnique.isNull()) { setHardwareSkinningParam(0, 0, ST_LINEAR, false, false); } int boneCount = mActiveTechnique->getBoneCount(); int weightCount = mActiveTechnique->getWeightCount(); bool doBoneCalculations = isValid && (boneCount != 0) && (boneCount <= 256) && (weightCount != 0) && (weightCount <= 4) && ((mCreator == NULL) || (boneCount <= mCreator->getMaxCalculableBoneCount())); mActiveTechnique->setDoBoneCalculations(doBoneCalculations); if ((doBoneCalculations) && (mCreator)) { //update the receiver and caster materials if (dstPass->getParent()->getShadowCasterMaterial().isNull()) { dstPass->getParent()->setShadowCasterMaterial( mCreator->getCustomShadowCasterMaterial(mSkinningType, weightCount - 1)); } if (dstPass->getParent()->getShadowReceiverMaterial().isNull()) { dstPass->getParent()->setShadowReceiverMaterial( mCreator->getCustomShadowReceiverMaterial(mSkinningType, weightCount - 1)); } } return true; }
void Material::CreateInputLayout(const std::string& techniqueName, const std::string& passName, D3D11_INPUT_ELEMENT_DESC* inputElementDescriptions, UINT inputElementDescriptionCount) { Technique* technique = mEffect->TechniquesByName().at(techniqueName); assert(technique != nullptr); Pass* pass = technique->PassesByName().at(passName); assert(pass != nullptr); ID3D11InputLayout* inputLayout; pass->CreateInputLayout(inputElementDescriptions, inputElementDescriptionCount, &inputLayout); mInputLayouts.insert(std::pair<Pass*, ID3D11InputLayout*>(pass, inputLayout)); }
TechniqueController* MaterialController::createTechnique(const String& name) { Technique* t = mMaterialPtr->createTechnique(); t->setName(name); // Create controller TechniqueController* tc = new TechniqueController(t); mTechniqueControllers.push_back(tc); fireEvent(TechniqueAdded, MaterialEventArgs(this, tc)); return tc; }
Technique* Material::getTechnique(const char* id) const { for (unsigned int i = 0, count = _techniques.size(); i < count; ++i) { Technique* t = _techniques[i]; if (strcmp(t->getId(), id) == 0) { return t; } } return NULL; }
void MaterialManager::initialise() { Material * default_mat = create("BaseWhite"); Technique* tec = default_mat->createTechnique(); tec->SetColorEnabled(true); tec->SetObjectColor(Color::White); GpuProgram* program = tec->CreateGpuProgram(); Shader* vsShader = ShaderManager::getSingleton()->CreateShader("Basic.vert"); program->mVertexShader = vsShader; Shader* fsShader = ShaderManager::getSingleton()->CreateShader("BasicObjectColor.frag"); program->mFragmentShader = fsShader; }
//------------------------------------------------------------------------ MatGenParams MaterialUtil::getMatGenParams(const MaterialPtr& _material) { if(!_material->getNumTechniques()) return MatGenParams(); Technique* technique = _material->getTechnique(0); UserObjectBindings& uob = technique->getUserObjectBindings(); Any matGenParamsAny = uob.getUserAny( USER_MAT_GEN_PARAMS ); if(matGenParamsAny.isEmpty()) return MatGenParams(); return *any_cast<MatGenParams>(&matGenParamsAny); }
void MaterialInstance::setSceneBlending (SceneBlendType sbt) { mSBT = sbt; if (!mCopyMat.isNull ()) { Material::TechniqueIterator techniqueIt = mCopyMat->getTechniqueIterator (); while (techniqueIt.hasMoreElements ()) { Technique *t = techniqueIt.getNext (); Technique::PassIterator passIt = t->getPassIterator (); while (passIt.hasMoreElements ()) { passIt.getNext ()->setSceneBlending (mSBT); } } } }
// 把地形的障碍区域显示Pass移除 void TerrainEditorPlugin::removeTerrainBlockerPass(ETTerrain *terrain) { MaterialPtr mat = terrain->getTerrainImpl()->getMaterial(); Technique *tech = mat->getTechnique(0); // 看有没有这个Blocker的Pass,如果有就删除之 for(size_t i = 0 ; i < tech->getNumPasses() ; i ++) { if(tech->getPass(i)->getName() == "Blocker") { tech->removePass(i); return; } } }
//--------------------------------------------------------------------- MaterialPtr TerrainMaterialGeneratorA::SM2Profile::generate(const Terrain* terrain) { // re-use old material if exists MaterialPtr mat = terrain->_getMaterial(); if (mat.isNull()) { MaterialManager& matMgr = MaterialManager::getSingleton(); // it's important that the names are deterministic for a given terrain, so // use the terrain pointer as an ID const String& matName = terrain->getMaterialName(); mat = matMgr.getByName(matName); if (mat.isNull()) { mat = matMgr.create(matName, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); } } // clear everything mat->removeAllTechniques(); // Automatically disable normal & parallax mapping if card cannot handle it // We do this rather than having a specific technique for it since it's simpler GpuProgramManager& gmgr = GpuProgramManager::getSingleton(); if (!gmgr.isSyntaxSupported("ps_4_0") && !gmgr.isSyntaxSupported("ps_3_0") && !gmgr.isSyntaxSupported("ps_2_x") && !gmgr.isSyntaxSupported("fp40") && !gmgr.isSyntaxSupported("arbfp1") && !gmgr.isSyntaxSupported("glsl") && !gmgr.isSyntaxSupported("glsles")) { setLayerNormalMappingEnabled(false); setLayerParallaxMappingEnabled(false); } addTechnique(mat, terrain, HIGH_LOD); // LOD if(mCompositeMapEnabled) { addTechnique(mat, terrain, LOW_LOD); Material::LodValueList lodValues; lodValues.push_back(TerrainGlobalOptions::getSingleton().getCompositeMapDistance()); mat->setLodLevels(lodValues); Technique* lowLodTechnique = mat->getTechnique(1); lowLodTechnique->setLodIndex(1); } updateParams(mat, terrain); return mat; }