Forráskód Böngészése

Apply texture sampler

Marko Pintera 13 éve
szülő
commit
5ec633729e

+ 3 - 1
CamelotD3D9Renderer/Source/CmD3D9RenderSystem.cpp

@@ -2775,7 +2775,9 @@ namespace CamelotEngine
 					size_t logicalIndex = i->first;
 					size_t logicalIndex = i->first;
 					TextureRef texture = params->getTexture(i->second.physicalIndex);
 					TextureRef texture = params->getTexture(i->second.physicalIndex);
 
 
-					_setTexture(logicalIndex, true, texture.getInternalPtr());
+					const SamplerState& samplerState = params->getSamplerState(i->second.physicalIndex);
+
+					_setTextureUnitSettings(logicalIndex, texture.getInternalPtr(), samplerState);
 				}
 				}
 			}
 			}
 		}
 		}

+ 1 - 1
CamelotForwardRenderer/Source/CmForwardRenderer.cpp

@@ -71,7 +71,7 @@ namespace CamelotEngine
 			{
 			{
 				setPass(material->getPass(i));
 				setPass(material->getPass(i));
 
 
-				material->applyPass(i); // TODO - applyPass method should be more like RenderSystem::applyPass(Material, passIdx)
+				material->applyPassParameters(i); // TODO - applyPass method should be more like RenderSystem::applyPass(Material, passIdx)
 				renderSystem->_render(mesh->getRenderOperation());
 				renderSystem->_render(mesh->getRenderOperation());
 			}
 			}
 		}
 		}

+ 4 - 0
CamelotGLRenderer/Source/CmGLRenderSystem.cpp

@@ -2531,6 +2531,10 @@ namespace CamelotEngine {
 				{
 				{
 					TextureRef curTexture = params->getTexture(def.physicalIndex);
 					TextureRef curTexture = params->getTexture(def.physicalIndex);
 					_setTexture(def.physicalIndex, true, curTexture.getInternalPtr());
 					_setTexture(def.physicalIndex, true, curTexture.getInternalPtr());
+
+					const SamplerState& samplerState = params->getSamplerState(def.physicalIndex);
+
+					_setTextureUnitSettings(def.physicalIndex, curTexture.getInternalPtr(), samplerState);
 				}
 				}
 			}
 			}
 		}
 		}

+ 1 - 1
CamelotRenderer/Include/CmMaterial.h

@@ -46,7 +46,7 @@ namespace CamelotEngine
 		/**
 		/**
 		 * @brief	Use the provided pass for rendering of all following objects.
 		 * @brief	Use the provided pass for rendering of all following objects.
 		 */
 		 */
-		void applyPass(UINT32 passIdx);
+		void applyPassParameters(UINT32 passIdx);
 
 
 		UINT32 getNumPasses() const;
 		UINT32 getNumPasses() const;
 
 

+ 1 - 1
CamelotRenderer/Include/CmRenderSystem.h

@@ -540,7 +540,7 @@ namespace CamelotEngine
 		only sets those settings which are different from the current settings for this
 		only sets those settings which are different from the current settings for this
 		unit, thus minimising render state changes.
 		unit, thus minimising render state changes.
 		*/
 		*/
-		virtual void _setTextureUnitSettings(size_t texUnit, const TexturePtr& texture, SamplerState& tl);
+		virtual void _setTextureUnitSettings(size_t texUnit, const TexturePtr& texture, const SamplerState& tl);
 		/** Turns off a texture unit. */
 		/** Turns off a texture unit. */
 		virtual void _disableTextureUnit(size_t texUnit);
 		virtual void _disableTextureUnit(size_t texUnit);
 		/** Disables all texture units from the given unit upwards */
 		/** Disables all texture units from the given unit upwards */

+ 1 - 10
CamelotRenderer/Source/CmMaterial.cpp

@@ -129,7 +129,7 @@ namespace CamelotEngine
 		return mShader->getBestTechnique()->getPass(passIdx);
 		return mShader->getBestTechnique()->getPass(passIdx);
 	}
 	}
 
 
-	void Material::applyPass(UINT32 passIdx)
+	void Material::applyPassParameters(UINT32 passIdx)
 	{
 	{
 		throwIfNotInitialized();
 		throwIfNotInitialized();
 
 
@@ -141,24 +141,15 @@ namespace CamelotEngine
 
 
 		GpuProgramRef vertProgram = curPass->getVertexProgram();
 		GpuProgramRef vertProgram = curPass->getVertexProgram();
 		if(vertProgram)
 		if(vertProgram)
-		{
-			renderSystem->bindGpuProgram(vertProgram->_getBindingDelegate());
 			renderSystem->bindGpuProgramParameters(GPT_VERTEX_PROGRAM, params.mVertParams, GPV_ALL);
 			renderSystem->bindGpuProgramParameters(GPT_VERTEX_PROGRAM, params.mVertParams, GPV_ALL);
-		}
 
 
 		GpuProgramRef fragProgram = curPass->getFragmentProgram();
 		GpuProgramRef fragProgram = curPass->getFragmentProgram();
 		if(fragProgram)
 		if(fragProgram)
-		{
-			renderSystem->bindGpuProgram(fragProgram->_getBindingDelegate());
 			renderSystem->bindGpuProgramParameters(GPT_FRAGMENT_PROGRAM, params.mFragParams, GPV_ALL);
 			renderSystem->bindGpuProgramParameters(GPT_FRAGMENT_PROGRAM, params.mFragParams, GPV_ALL);
-		}
 
 
 		GpuProgramRef geomProgram = curPass->getGeometryProgram();
 		GpuProgramRef geomProgram = curPass->getGeometryProgram();
 		if(geomProgram)
 		if(geomProgram)
-		{
-			renderSystem->bindGpuProgram(geomProgram->_getBindingDelegate());
 			renderSystem->bindGpuProgramParameters(GPT_GEOMETRY_PROGRAM, params.mGeomParams, GPV_ALL);
 			renderSystem->bindGpuProgramParameters(GPT_GEOMETRY_PROGRAM, params.mGeomParams, GPV_ALL);
-		}	
 	}
 	}
 
 
 	RTTITypeBase* Material::getRTTIStatic()
 	RTTITypeBase* Material::getRTTIStatic()

+ 1 - 1
CamelotRenderer/Source/CmRenderSystem.cpp

@@ -278,7 +278,7 @@ namespace CamelotEngine {
         return mActiveViewport;
         return mActiveViewport;
     }
     }
     //-----------------------------------------------------------------------
     //-----------------------------------------------------------------------
-    void RenderSystem::_setTextureUnitSettings(size_t texUnit, const TexturePtr& tex, SamplerState& tl)
+    void RenderSystem::_setTextureUnitSettings(size_t texUnit, const TexturePtr& tex, const SamplerState& tl)
     {
     {
         // This method is only ever called to set a texture unit to valid details
         // This method is only ever called to set a texture unit to valid details
         // The method _disableTextureUnit is called to turn a unit off
         // The method _disableTextureUnit is called to turn a unit off