void renderProjection(Storm3D_Scene &scene, Storm3D_Spotlight *spot)
	{
		glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
		glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);

		if(!decals.empty())
		{
			glDepthMask(GL_FALSE);
			glEnable(GL_BLEND);
			glDisable(GL_ALPHA_TEST);
			glBlendFunc(GL_SRC_ALPHA, GL_ONE);

			D3DXMATRIX tm;

			int materialIndex = 0;
			int startIndex = 0;
			int endIndex = 0;

			if(spot->getType() == IStorm3D_Spotlight::Point)
				pointVertexShader.apply();
			else if(spot->getType() == IStorm3D_Spotlight::Directional)
				dirVertexShader.apply();
			else if(spot->getType() == IStorm3D_Spotlight::Flat)
				flatVertexShader.apply();

			vertices.apply(0);
			int prevBindOffs = 0;

			Storm3D_ShaderManager::GetSingleton()->SetWorldTransform(tm);
			Storm3D_ShaderManager::GetSingleton()->SetTransparencyFactor(0.75f);

			for(;;)
			{
				materialIndex = decals[startIndex]->materialIndex;
				materials[materialIndex].applyProjection(spot->getColorMultiplier());

				int decalAmount = decals.size();
				for(int i = startIndex + 1; i < decalAmount; ++i)
				{
					if(decals[i]->materialIndex != materialIndex)
						break;

					endIndex = i;
				}

				int renderAmount = endIndex - startIndex + 1;

				if (prevBindOffs != startIndex * 4) {
					vertices.apply(0, (startIndex * 4) * VERTEX_SIZE);
					prevBindOffs = startIndex * 4;
				}
				indices.render(renderAmount * 2, renderAmount * 4);
				startIndex = ++endIndex;

				scene.AddPolyCounter(renderAmount * 2);
				if(startIndex >= decalAmount)
					break;
			}

			Storm3D_ShaderManager::GetSingleton()->SetTransparencyFactor(1.f);

			glBlendFunc(GL_ONE, GL_ONE);
			glEnable(GL_BLEND);
		}

		glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
		glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
	}
	void render(Storm3D_Scene &scene)
	{
		findDecals(scene);

		createIndexBuffers();
		createVertexBuffers();

		// Render
		if(!decals.empty())
		{
			glDepthMask(GL_FALSE);
			glEnable(GL_BLEND);
			glDisable(GL_ALPHA_TEST);
			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

			D3DXMATRIX tm;

			pixelShader.apply();
			vertexShader.apply();
			vertices.apply(0);
			// ugly HACK!
			int prevBindOffs = 0;
			Storm3D_ShaderManager::GetSingleton()->SetWorldTransform(tm);

			float outfactor[4] = { outFactor.r, outFactor.g, outFactor.b, 1.0f };
			glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 8, outfactor);
			float infactor[4] = { inFactor.r, inFactor.g, inFactor.b, 1.0f };
			glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, 9, infactor);

			int materialIndex = 0;
			int startIndex = 0;
			int endIndex = 0;

			for(;;)
			{
				materialIndex = decals[startIndex]->materialIndex;
				materials[materialIndex].apply();

				int decalAmount = decals.size();
				for(int i = startIndex + 1; i < decalAmount; ++i)
				{
					if(decals[i]->materialIndex != materialIndex)
						break;

					endIndex = i;
				}

				int renderAmount = endIndex - startIndex + 1;

				if (prevBindOffs != startIndex * 4) {
					vertices.apply(0, (startIndex * 4) * VERTEX_SIZE);
					prevBindOffs = startIndex * 4;
				}
				indices.render(renderAmount * 2, renderAmount * 4);
				startIndex = ++endIndex;

				scene.AddPolyCounter(renderAmount * 2);
				if(startIndex >= decalAmount)
					break;
			}

			glDisable(GL_BLEND);
		}
	}