Пример #1
0
//  util
//-------------------------------------------------------------------------------------
void BaseApp::CreateRTfixed()
{
	if (mShaderGenerator != NULL && mRoot->getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_FIXED_FUNCTION) == false)
	{
		// creates shaders for base material BaseWhite using the RTSS
		Ogre::MaterialPtr baseWhite = Ogre::MaterialManager::getSingleton().getByName("BaseWhite", Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);				
		baseWhite->setLightingEnabled(false);
		mShaderGenerator->createShaderBasedTechnique(
			"BaseWhite", 
			Ogre::MaterialManager::DEFAULT_SCHEME_NAME, 
			Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);	
		mShaderGenerator->validateMaterial(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME, 
			"BaseWhite");
		baseWhite->getTechnique(0)->getPass(0)->setVertexProgram(
			baseWhite->getTechnique(1)->getPass(0)->getVertexProgram()->getName());
		baseWhite->getTechnique(0)->getPass(0)->setFragmentProgram(
			baseWhite->getTechnique(1)->getPass(0)->getFragmentProgram()->getName());

		// creates shaders for base material BaseWhiteNoLighting using the RTSS
		mShaderGenerator->createShaderBasedTechnique(
			"BaseWhiteNoLighting", 
			Ogre::MaterialManager::DEFAULT_SCHEME_NAME, 
			Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);	
		mShaderGenerator->validateMaterial(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME, 
			"BaseWhiteNoLighting");
		Ogre::MaterialPtr baseWhiteNoLighting = Ogre::MaterialManager::getSingleton().getByName("BaseWhiteNoLighting", Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
		baseWhiteNoLighting->getTechnique(0)->getPass(0)->setVertexProgram(
			baseWhiteNoLighting->getTechnique(1)->getPass(0)->getVertexProgram()->getName());
		baseWhiteNoLighting->getTechnique(0)->getPass(0)->setFragmentProgram(
			baseWhiteNoLighting->getTechnique(1)->getPass(0)->getFragmentProgram()->getName());
	}
}
void createColorMaterial(const std::string& name, const Ogre::ColourValue& color, bool use_self_illumination)
{
    Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create( name, ROS_PACKAGE_NAME );
    mat->setAmbient(color * 0.5f);
    mat->setDiffuse(color);
    if( use_self_illumination )
    {
        mat->setSelfIllumination(color);
    }
    mat->setLightingEnabled(true);
    mat->setReceiveShadows(false);
}
Пример #3
0
void OgreApp::startDemo(void* uiWindow, void* uiView, unsigned int width, unsigned int height, const char* name)
#endif
{
    globals.playerName = name;
	new OgreFramework();
#if !defined(OGRE_IS_IOS)
    if (!OgreFramework::getSingletonPtr()->initOgre(this, this))
        return;
#else
	if (!OgreFramework::getSingletonPtr()->initOgre(uiWindow, uiView, width, height))
		return;
#endif

    
	m_bShutdown = false;
    
	OgreFramework::getSingletonPtr()->m_pLog->logMessage("Demo initialized!");
    
#ifdef INCLUDE_RTSHADER_SYSTEM
    initialiseRTShaderSystem(OgreFramework::getSingletonPtr()->m_pSceneMgrMain);
    Ogre::MaterialPtr baseWhite = Ogre::MaterialManager::getSingleton().getByName("BaseWhite", Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
    baseWhite->setLightingEnabled(false);
    mShaderGenerator->createShaderBasedTechnique(
                                                 "BaseWhite",
                                                 Ogre::MaterialManager::DEFAULT_SCHEME_NAME,
                                                 Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
    mShaderGenerator->validateMaterial(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME,
                                       "BaseWhite");
    baseWhite->getTechnique(0)->getPass(0)->setVertexProgram(
                                                             baseWhite->getTechnique(1)->getPass(0)->getVertexProgram()->getName());
    baseWhite->getTechnique(0)->getPass(0)->setFragmentProgram(
                                                               baseWhite->getTechnique(1)->getPass(0)->getFragmentProgram()->getName());
    
    // creates shaders for base material BaseWhiteNoLighting using the RTSS
    mShaderGenerator->createShaderBasedTechnique(
                                                 "BaseWhiteNoLighting",
                                                 Ogre::MaterialManager::DEFAULT_SCHEME_NAME,
                                                 Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
    mShaderGenerator->validateMaterial(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME,
                                       "BaseWhiteNoLighting");
    Ogre::MaterialPtr baseWhiteNoLighting = Ogre::MaterialManager::getSingleton().getByName("BaseWhiteNoLighting", Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
    baseWhiteNoLighting->getTechnique(0)->getPass(0)->setVertexProgram(
                                                                       baseWhiteNoLighting->getTechnique(1)->getPass(0)->getVertexProgram()->getName());
    baseWhiteNoLighting->getTechnique(0)->getPass(0)->setFragmentProgram(
                                                                         baseWhiteNoLighting->getTechnique(1)->getPass(0)->getFragmentProgram()->getName());
#endif
    
	setupDemoScene();
#if !((OGRE_PLATFORM == OGRE_PLATFORM_APPLE) && __LP64__)
	runDemo();
#endif
}
Пример #4
0
DebugDrawer::DebugDrawer(Ogre::SceneNode *node, btDynamicsWorld *world) :
	mNode(node), mWorld(world), m_debugMode(0)
{
	mLineDrawer = new DynamicLines(Ogre::RenderOperation::OT_LINE_LIST);
	mLineDrawer->setCastShadows(false); //`
	mNode->attachObject(mLineDrawer);

	Ogre::ResourceGroupManager::getSingleton().createResourceGroup("BtOgre");
	Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create("BtOgre/DebugLines", "BtOgre");
	mat->setReceiveShadows(false);
	mat->setLightingEnabled(false);
	//mat->setSelfIllumination(1,1,1);
	mLineDrawer->setMaterial("BtOgre/DebugLines");/**/  //crash debug..
}
Пример #5
0
	void SampleContext::createDummyScene()
	{
		mWindow->removeAllViewports();
		WindEngine::SceneManager* sm = mEngine->createSceneManager(WindEngine::ST_GENERIC, "DummyScene");
		WindEngine::Camera* cam = sm->createCamera("DummyCamera");
		mWindow->addViewport(cam);
#ifdef USE_RTSHADER_SYSTEM
		// Initialize shader generator.
		// Must be before resource loading in order to allow parsing extended material attributes.
		bool success = initializeRTShaderSystem(sm);
		if (!success)
		{
			OGRE_EXCEPT(Ogre::Exception::ERR_FILE_NOT_FOUND,
				"Shader Generator Initialization failed - Core shader libs path not found",
				"Sample::_setup");
		}
		if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_FIXED_FUNCTION) == false)
		{
			//newViewport->setMaterialScheme(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);

			// creates shaders for base material BaseWhite using the RTSS
			Ogre::MaterialPtr baseWhite = Ogre::MaterialManager::getSingleton().getByName("BaseWhite", Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
			baseWhite->setLightingEnabled(false);
			mShaderGenerator->createShaderBasedTechnique(
				"BaseWhite",
				Ogre::MaterialManager::DEFAULT_SCHEME_NAME,
				Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
			mShaderGenerator->validateMaterial(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME,
				"BaseWhite");
			baseWhite->getTechnique(0)->getPass(0)->setVertexProgram(
				baseWhite->getTechnique(1)->getPass(0)->getVertexProgram()->getName());
			baseWhite->getTechnique(0)->getPass(0)->setFragmentProgram(
				baseWhite->getTechnique(1)->getPass(0)->getFragmentProgram()->getName());

			// creates shaders for base material BaseWhiteNoLighting using the RTSS
			mShaderGenerator->createShaderBasedTechnique(
				"BaseWhiteNoLighting",
				Ogre::MaterialManager::DEFAULT_SCHEME_NAME,
				Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
			mShaderGenerator->validateMaterial(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME,
				"BaseWhiteNoLighting");
			Ogre::MaterialPtr baseWhiteNoLighting = Ogre::MaterialManager::getSingleton().getByName("BaseWhiteNoLighting", Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
			baseWhiteNoLighting->getTechnique(0)->getPass(0)->setVertexProgram(
				baseWhiteNoLighting->getTechnique(1)->getPass(0)->getVertexProgram()->getName());
			baseWhiteNoLighting->getTechnique(0)->getPass(0)->setFragmentProgram(
				baseWhiteNoLighting->getTechnique(1)->getPass(0)->getFragmentProgram()->getName());
		}
#endif // USE_RTSHADER_SYSTEM
	}
  std::string createMaterialIfNotExists(const float r, const float g, const float b, const float a)
  {
    char buf[128];
    sprintf(buf, "ShapeColor%f;%f;%f;%f",r,g,b,a);
    if(!Ogre::MaterialManager::getSingleton().getByName(buf, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME).isNull())
      return buf;

    Ogre::ColourValue color( r,g,b,a );
    Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create( buf, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
    mat->setAmbient(color * 0.01f);
    mat->setDiffuse(color);
    mat->setLightingEnabled(true);
    mat->setReceiveShadows(true);
    mat->setCullingMode(Ogre::CULL_NONE);

    return buf;
  }
Пример #7
0
void DemoApp::startDemo()
{
	new OgreFramework();
	if(!OgreFramework::getSingletonPtr()->initOgre("DemoApp v1.0", this, 0))
		return;
    
	m_bShutdown = false;
    
	OgreFramework::getSingletonPtr()->m_pLog->logMessage("Demo initialized!");
	
#ifdef USE_RTSHADER_SYSTEM
    initializeRTShaderSystem(OgreFramework::getSingletonPtr()->m_pSceneMgr);
    Ogre::MaterialPtr baseWhite = Ogre::MaterialManager::getSingleton().getByName("BaseWhite", Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);				
    baseWhite->setLightingEnabled(false);
    mShaderGenerator->createShaderBasedTechnique(
                                                 "BaseWhite", 
                                                 Ogre::MaterialManager::DEFAULT_SCHEME_NAME, 
                                                 Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);	
    mShaderGenerator->validateMaterial(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME, 
                                       "BaseWhite");
    baseWhite->getTechnique(0)->getPass(0)->setVertexProgram(
                                                             baseWhite->getTechnique(1)->getPass(0)->getVertexProgram()->getName());
    baseWhite->getTechnique(0)->getPass(0)->setFragmentProgram(
                                                               baseWhite->getTechnique(1)->getPass(0)->getFragmentProgram()->getName());
    
    // creates shaders for base material BaseWhiteNoLighting using the RTSS
    mShaderGenerator->createShaderBasedTechnique(
                                                 "BaseWhiteNoLighting", 
                                                 Ogre::MaterialManager::DEFAULT_SCHEME_NAME, 
                                                 Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);	
    mShaderGenerator->validateMaterial(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME, 
                                       "BaseWhiteNoLighting");
    Ogre::MaterialPtr baseWhiteNoLighting = Ogre::MaterialManager::getSingleton().getByName("BaseWhiteNoLighting", Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
    baseWhiteNoLighting->getTechnique(0)->getPass(0)->setVertexProgram(
                                                                       baseWhiteNoLighting->getTechnique(1)->getPass(0)->getVertexProgram()->getName());
    baseWhiteNoLighting->getTechnique(0)->getPass(0)->setFragmentProgram(
                                                                         baseWhiteNoLighting->getTechnique(1)->getPass(0)->getFragmentProgram()->getName());
#endif
    
	setupDemoScene();
#if !((OGRE_PLATFORM == OGRE_PLATFORM_APPLE) && __LP64__)
	runDemo();
#endif
}
Пример #8
0
    Ogre::MaterialPtr
    IntersectGrid::_createIntersectGridMaterial(void)
    {
        String name = "IntersectGridMaterial";

        Ogre::ResourcePtr res = Ogre::MaterialManager::getSingleton().getByName(name);
        if (!res.isNull())
            return res;

        Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create(name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
       
        material->setLightingEnabled(false);
        material->setSceneBlending(Ogre::SBF_SOURCE_ALPHA, Ogre::SBF_ONE_MINUS_SOURCE_ALPHA);
        material->setDepthWriteEnabled(false);
        // Use wireframe polygon mode
        material->getTechnique(0)->getPass(0)->setPolygonMode(Ogre::PM_WIREFRAME);

        return material;
    }
Пример #9
0
Ogre::MaterialPtr gkMaterialLoader::createRTSSMaterial(const gkString& matName, bool enableLight)
{
#ifdef OGREKIT_USE_RTSHADER_SYSTEM
	Ogre::RTShader::ShaderGenerator* shaderGenerator = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
	GK_ASSERT(shaderGenerator);

	Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName(matName, 
			Ogre::ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);

	if (material.isNull())
	{
		material = Ogre::MaterialManager::getSingleton().create(matName,
			Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
	}
	
	material->setLightingEnabled(enableLight);

	shaderGenerator->createShaderBasedTechnique(matName, 
		Ogre::MaterialManager::DEFAULT_SCHEME_NAME, Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);	
	shaderGenerator->validateMaterial(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME, matName);
	if (material->getNumTechniques() > 1)
	{
		material->getTechnique(0)->getPass(0)->setVertexProgram(
			material->getTechnique(1)->getPass(0)->getVertexProgram()->getName());
		material->getTechnique(0)->getPass(0)->setFragmentProgram(
			material->getTechnique(1)->getPass(0)->getFragmentProgram()->getName());
	}

	GK_ASSERT(!material->getTechnique(0)->getPass(0)->getVertexProgram().isNull());
	GK_ASSERT(!material->getTechnique(0)->getPass(0)->getFragmentProgram().isNull());

	return material;
#else
	return Ogre::MaterialPtr();
#endif
}
void ImageSelectionToolCustom::onInitialize()
{
    move_tool_->initialize( context_ );

    // Create our highlight rectangle
    Ogre::SceneManager* scene_manager = context_->getSceneManager();
    highlight_node_ = scene_manager->getRootSceneNode()->createChildSceneNode();

    std::stringstream ss;
    static int count = 0;
    ss << "ImageSelectionRect" << count++;
    highlight_rectangle_ = new Ogre::Rectangle2D(true);

    const static uint32_t texture_data[1] = { 0xffff0070 };
    Ogre::DataStreamPtr pixel_stream;
    pixel_stream.bind(new Ogre::MemoryDataStream( (void*)&texture_data[0], 4 ));

    Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton().loadRawData(ss.str() + "Texture", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, pixel_stream, 1, 1, Ogre::PF_R8G8B8A8, Ogre::TEX_TYPE_2D, 0);

    Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create(ss.str(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
    material->setLightingEnabled(false);
    //material->getTechnique(0)->getPass(0)->setPolygonMode(Ogre::PM_WIREFRAME);
    highlight_rectangle_->setMaterial(material->getName());
    Ogre::AxisAlignedBox aabInf;
    aabInf.setInfinite();
    highlight_rectangle_->setBoundingBox(aabInf);
    highlight_rectangle_->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY + 4);
    material->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
    material->setCullingMode(Ogre::CULL_NONE);

    Ogre::TextureUnitState* tex_unit = material->getTechnique(0)->getPass(0)->createTextureUnitState();
    tex_unit->setTextureName(tex->getName());
    tex_unit->setTextureFiltering( Ogre::TFO_NONE );

    highlight_node_->attachObject(highlight_rectangle_);
}
Пример #11
0
void gkMaterialLoader::loadSubMeshMaterial(gkSubMesh* mesh, const gkString& group)
{
	using namespace Ogre;

	gkMaterialProperties& gma = mesh->getMaterial();
	if (gma.m_name.empty())
		gma.m_name = "<gkBuiltin/DefaultMaterial>";

	Ogre::MaterialPtr oma = Ogre::MaterialManager::getSingleton().getByName(gma.m_name.c_str(), group);
	if (!oma.isNull())
		return;

	oma = Ogre::MaterialManager::getSingleton().create(gma.m_name, group);

	if (gma.m_mode & gkMaterialProperties::MA_INVISIBLE)
	{
		// disable writing to this material
		oma->setReceiveShadows(false);
		oma->setColourWriteEnabled(false);
		oma->setDepthWriteEnabled(false);
		oma->setDepthCheckEnabled(false);
		oma->setLightingEnabled(false);
		return;
	}

	if (gma.m_mode & gkMaterialProperties::MA_TWOSIDE)
	{
		oma->setCullingMode(Ogre::CULL_NONE);
		oma->setManualCullingMode(Ogre::MANUAL_CULL_NONE);
	}

	// apply lighting params

	bool enableLights = (gma.m_mode & gkMaterialProperties::MA_LIGHTINGENABLED) != 0;
	oma->setReceiveShadows((gma.m_mode & gkMaterialProperties::MA_RECEIVESHADOWS) != 0);

	oma->setLightingEnabled(enableLights);
	if (enableLights)
	{
		gkColor emissive, ambient, specular, diffuse;

		emissive    = gma.m_diffuse * gma.m_emissive;
		ambient     = gma.m_diffuse * gma.m_ambient;
		specular    = gma.m_specular * gma.m_spec;
		diffuse     = gma.m_diffuse * (gma.m_emissive + gma.m_refraction);

		emissive.a = ambient.a = specular.a = 1.f;

		oma->setSelfIllumination(emissive);
		oma->setAmbient(ambient);
		oma->setSpecular(specular);
		oma->setDiffuse(diffuse);
		oma->setShininess(gma.m_hardness);
	}
	
	Ogre::Pass* pass = oma->getTechnique(0)->getPass(0);

	bool matBlending = gkEngine::getSingleton().getUserDefs().matblending;

	if (matBlending && (gma.m_mode & gkMaterialProperties::MA_HASRAMPBLEND))
	{
		switch (gma.m_rblend)
		{
		case GK_BT_MULTIPLY:			
			pass->setSceneBlending(SBT_MODULATE);			
			break;
		case GK_BT_SUBTRACT:			
			pass->setSceneBlending(SBF_ONE_MINUS_SOURCE_COLOUR, SBF_ONE);
			break;
		case GK_BT_DARKEN:
			pass->setSceneBlendingOperation(SBO_MIN);
			pass->setSceneBlending(SBF_ONE, SBF_ONE);
			break;
		case GK_BT_LIGHTEN:
			pass->setSceneBlendingOperation(SBO_MAX);
			pass->setSceneBlending(SBF_ONE, SBF_ONE);
			break;
		case GK_BT_SCREEN:			
			pass->setSceneBlending(SBF_ONE_MINUS_DEST_COLOUR, SBF_ONE);
			break;
		case GK_BT_ADDITIVE:
			pass->setSceneBlending(SBT_ADD);
			break;
		case GK_BT_MIXTURE:
		default:
			pass->setSceneBlending(SBF_ONE, SBF_ZERO);
			break;
		}
	}

	bool hasNormap = false;
	bool rtss = gkEngine::getSingleton().getUserDefs().rtss;

	for (int i = 0; i < gma.m_totaltex; ++i)
	{		
		gkTextureProperties& gte = gma.m_textures[i];

#ifdef OGREKIT_USE_RTSHADER_SYSTEM
		if (gte.m_mode & gkTextureProperties::TM_NORMAL)
		{
			hasNormap = true;
			continue;
		}
#endif
		Ogre::TextureUnitState* otus = pass->createTextureUnitState(gte.m_name, gte.m_layer);

		LayerBlendOperationEx op = LBX_MODULATE;

		switch (gte.m_blend)
		{
		case GK_BT_ADDITIVE:
			op = LBX_ADD;
			break;

		case GK_BT_SUBTRACT:			
			op = LBX_SUBTRACT;
			break;

		case GK_BT_DARKEN:	
		case GK_BT_LIGHTEN:	
		case GK_BT_SCREEN:
		case GK_BT_COLOR:
			//break; TODO: support more mode

		case GK_BT_MULTIPLY:
		case GK_BT_MIXTURE:
		default:
			op = LBX_MODULATE;
			break;
		}

		if (i == 0)
			otus->setColourOperationEx(op, LBS_DIFFUSE, LBS_TEXTURE);		
		else
			otus->setColourOperationEx(op);

		otus->setTextureScale(gte.m_scale[0],gte.m_scale[1]);
	}



	if (gma.m_mode & gkMaterialProperties::MA_ALPHABLEND)
	{
		pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
		pass->setDepthWriteEnabled(false);
	}

	if (gma.m_mode & gkMaterialProperties::MA_ALPHACLIP)
	{
		pass->setAlphaRejectSettings(Ogre::CMPF_GREATER_EQUAL, 254);
	}

#ifdef OGREKIT_USE_RTSHADER_SYSTEM
	
	if (rtss)
	{
		//pass->setSpecular(ColourValue::Black);
		//pass->setShininess(0.0);

		RTShader::RenderState* rs = 0;
		RTShader::ShaderGenerator* sg = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
		bool ok = sg->createShaderBasedTechnique(gma.m_name, group, 
			Ogre::MaterialManager::DEFAULT_SCHEME_NAME, Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);

		if (ok && hasNormap)
		{
			rs = sg->getRenderState(RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME, gma.m_name, 0);
			rs->reset();

			for (int i = 0; i < gma.m_totaltex; ++i)
			{
				gkTextureProperties& gte = gma.m_textures[i];

				if (gte.m_mode & gkTextureProperties::TM_NORMAL)
				{
					GK_ASSERT(rs);

					RTShader::SubRenderState* srs= sg->createSubRenderState(RTShader::NormalMapLighting::Type);
				
					RTShader::NormalMapLighting* nsrs = static_cast<RTShader::NormalMapLighting*>(srs);
					if (gte.m_texmode & gkTextureProperties::TX_OBJ_SPACE)
						nsrs->setNormalMapSpace(RTShader::NormalMapLighting::NMS_OBJECT);
					else
						nsrs->setNormalMapSpace(RTShader::NormalMapLighting::NMS_TANGENT);
					nsrs->setNormalMapTextureName(gte.m_name);
					nsrs->setTexCoordIndex(gte.m_layer);

					rs->addTemplateSubRenderState(srs);
				}
			}

			sg->invalidateMaterial(RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME, gma.m_name);
		}
	}
#endif
}