Bladeren bron

- Writting the rendering code for MS and BS and SM
- Transforming the PPS shaders to GLSL 3.3

Panagiotis Christopoulos Charitos 15 jaren geleden
bovenliggende
commit
a5d5056d4a

File diff suppressed because it is too large
+ 1 - 2
build/debug/Makefile


+ 2 - 2
shaders/Final.glsl

@@ -8,13 +8,13 @@
 
 uniform sampler2D rasterImage;
 in vec2 vTexCoords;
-layout(location = 0) out vec3 fragColor;
+layout(location = 0) out vec3 fFragColor;
 
 void main()
 {
 	//if( gl_FragCoord.x > 0.5 ) discard;
 
-	fragColor.rgb = texture2D(rasterImage, vTexCoords).rgb;
+	fFragColor = texture2D(rasterImage, vTexCoords).rgb;
 	
 	//fragColor = vec3(1.0, 0.0, 1.0);
 

+ 19 - 19
shaders/GaussianBlurGeneric.glsl

@@ -15,8 +15,8 @@ attribute vec2 position;
 
 uniform float imgDimension = 0.0; ///< the img width for hspass or the img height for vpass
 
-varying vec2 vTexCoords;
-varying float vOffsets[2]; ///< For side pixels
+out vec2 vTexCoords;
+out float vOffsets[2]; ///< For side pixels
 
 const float _offset_[2] = float[](1.3846153846, 3.2307692308); ///< The offset of side pixels
 
@@ -50,12 +50,11 @@ void main()
 uniform sampler2D img; ///< Input FAI
 uniform float blurringDist = 0.0;
 
-varying vec2 vTexCoords;
-varying float vOffsets[2];
+in vec2 vTexCoords;
+in float vOffsets[2];
 
-/*
- * Determin color type
- */
+
+// Determin color type
 #if defined(COL_RGBA)
 	#define COL_TYPE vec4
 #elif defined(COL_RGB)
@@ -64,9 +63,7 @@ varying float vOffsets[2];
 	#define COL_TYPE float
 #endif
 
-/*
- * Determine tex fetch
- */
+// Determine tex fetch
 #if defined(COL_RGBA)
 	#define TEX_FETCH rgba
 #elif defined(COL_RGB)
@@ -76,32 +73,35 @@ varying float vOffsets[2];
 #endif
 
 
-const float _firstWeight_ = 0.2255859375;
-const float _weights_[2] = float[](0.314208984375, 0.06982421875);
+layout(location = 0) out COL_TYPE fFragColor;
+
+
+const float FIRST_WEIGHT = 0.2255859375;
+const float WEIGHTS[2] = float[](0.314208984375, 0.06982421875);
 
 
 void main()
 {
 	// the center (0,0) pixel
-	COL_TYPE _col_ = texture2D(img, vTexCoords).TEX_FETCH * _firstWeight_;
+	COL_TYPE _col_ = texture2D(img, vTexCoords).TEX_FETCH * FIRST_WEIGHT;
 
 	// side pixels
-	for(int i=0; i<2; i++)
+	for(int i = 0; i < 2; i++)
 	{
 		#if defined(HPASS)
 			vec2 _texCoords_ = vec2(vTexCoords.x + blurringDist + vOffsets[i], vTexCoords.y);
-			_col_ += texture2D(img, _texCoords_).TEX_FETCH * _weights_[i];
+			_col_ += texture2D(img, _texCoords_).TEX_FETCH * WEIGHTS[i];
 
 			_texCoords_.x = vTexCoords.x - blurringDist - vOffsets[i];
-			_col_ += texture2D(img, _texCoords_).TEX_FETCH * _weights_[i];
+			_col_ += texture2D(img, _texCoords_).TEX_FETCH * WEIGHTS[i];
 		#elif defined(VPASS)
 			vec2 _texCoords_ = vec2(vTexCoords.x, vTexCoords.y + blurringDist + vOffsets[i]);
-			_col_ += texture2D(img, _texCoords_).TEX_FETCH * _weights_[i];
+			_col_ += texture2D(img, _texCoords_).TEX_FETCH * WEIGHTS[i];
 
 			_texCoords_.y = vTexCoords.y - blurringDist - vOffsets[i];
-			_col_ += texture2D(img, _texCoords_).TEX_FETCH * _weights_[i];
+			_col_ += texture2D(img, _texCoords_).TEX_FETCH * WEIGHTS[i];
 		#endif
 	}
 
-	gl_FragData[0].TEX_FETCH = _col_;
+	fFragColor = _col_;
 }

+ 6 - 7
shaders/PpsPostPass.glsl

@@ -5,12 +5,13 @@
 #pragma anki fragShaderBegins
 
 #pragma anki include "shaders/photoshop_filters.glsl"
-#pragma anki include "shaders/median_filter.glsl"
 
 uniform sampler2D ppsPrePassFai;
 uniform sampler2D ppsHdrFai;
 
-varying vec2 vTexCoords;
+in vec2 vTexCoords;
+
+layout(location = 0) out vec3 fFragColor;
 
 
 //======================================================================================================================
@@ -40,7 +41,7 @@ vec3 saturation(in vec3 col, in float factor)
 //======================================================================================================================
 void main(void)
 {
-	vec3 color = texture2D(ppsPrePassFai, vTexCoords).rgb;
+	fFragColor = texture2D(ppsPrePassFai, vTexCoords).rgb;
 
 	/*const float gamma = 0.7;
 	color.r = pow(color.r, 1.0 / gamma);
@@ -49,11 +50,9 @@ void main(void)
 
 	#if defined(HDR_ENABLED)
 		vec3 hdr = texture2D(ppsHdrFai, vTexCoords).rgb;
-		color += hdr;
+		fFragColor += hdr;
 	#endif
 
-	color = BlendHardLight(vec3(0.6, 0.62, 0.4), color);
-
-	gl_FragData[0].rgb = color;
+	fFragColor = BlendHardLight(vec3(0.6, 0.62, 0.4), fFragColor);
 }
 

+ 5 - 5
shaders/PpsPrePass.glsl

@@ -7,7 +7,9 @@
 uniform sampler2D isFai;
 uniform sampler2D ppsSsaoFai;
 
-varying vec2 vTexCoords;
+in vec2 vTexCoords;
+
+layout(location = 0) out vec3 fFragColor;
 
 
 //======================================================================================================================
@@ -15,13 +17,11 @@ varying vec2 vTexCoords;
 //======================================================================================================================
 void main(void)
 {
-	vec3 color = texture2D(isFai, vTexCoords).rgb;
+	fFragColor = texture2D(isFai, vTexCoords).rgb;
 
 	#if defined(SSAO_ENABLED)
 		float ssaoFactor = texture2D(ppsSsaoFai, vTexCoords).r;
-		color *= ssaoFactor;
+		fFragColor *= ssaoFactor;
 	#endif
-
-	gl_FragData[0].rgb = color;
 }
 

+ 6 - 3
shaders/PpsSsao.glsl

@@ -12,7 +12,10 @@ uniform sampler2D msDepthFai;
 uniform sampler2D noiseMap;
 uniform sampler2D msNormalFai;
 
-varying vec2 vTexCoords;
+in vec2 vTexCoords;
+
+layout(location = 0) out float fFragColor;
+
 const float totStrength = 1.3;
 const float strength = 0.07;
 const float offset = 18.0;
@@ -59,7 +62,7 @@ void main(void)
 	vec3 ray, se, occNorm;
 	float occluderDepth, depthDifference, normDiff;
 
-	for( int i=0; i<SAMPLES; ++i )
+	for(int i=0; i<SAMPLES; ++i)
 	{
 		// get a vector (randomized inside of a sphere with radius 1.0) from a texture and reflect it
 		ray = radD*reflect(pSphere[i],fres);
@@ -85,5 +88,5 @@ void main(void)
 
 	// output the result
 	float ao = 1.0-totStrength*bl*invSamples;
-	gl_FragColor.r = ao /** MAX_SSAO_DISTANCE*/;
+	fFragColor = ao /** MAX_SSAO_DISTANCE*/;
 }

+ 6 - 4
shaders/PpsSsaoBlur.glsl

@@ -6,10 +6,12 @@
 
 #pragma anki include "shaders/median_filter.glsl"
 
-varying vec2 vTexCoords;
-
 uniform sampler2D tex;
 
+in vec2 vTexCoords;
+
+layout(location = 0) out float fFragColor;
+
 void main()
 {
 	#if defined( _PPS_SSAO_PASS_0_ )
@@ -27,7 +29,7 @@ void main()
 																			-6.0 * offset, 6.0 * offset*/ );
 
 	float factor = 0.0;
-	for( int i=0; i<KERNEL_SIZE; i++ )
+	for(int i=0; i<KERNEL_SIZE; i++)
 	{
 		#if defined( _PPS_SSAO_PASS_0_ )
 			factor += texture2D( tex, vTexCoords + vec2(kernel[i], 0.0) ).a;
@@ -35,5 +37,5 @@ void main()
 			factor += texture2D( tex, vTexCoords + vec2(0.0, kernel[i]) ).a;
 		#endif		
 	}
-	gl_FragData[0].a = factor / float(KERNEL_SIZE);
+	fFragColor = factor / float(KERNEL_SIZE);
 }

+ 22 - 6
src/Misc/PropertyTree.cpp

@@ -60,17 +60,33 @@ float getFloat(const boost::property_tree::ptree& pt)
 }
 
 
+//======================================================================================================================
+// getVec2                                                                                                             =
+//======================================================================================================================
+Vec2 getVec2(const boost::property_tree::ptree& pt)
+{
+	const boost::property_tree::ptree& tree = pt.get_child("vec2");
+	return Vec2(tree.get<float>("x"), tree.get<float>("y"));
+}
+
+
 //======================================================================================================================
 // getVec3                                                                                                             =
 //======================================================================================================================
 Vec3 getVec3(const boost::property_tree::ptree& pt)
 {
-	const boost::property_tree::ptree& vec3Tree = pt.get_child("vec3");
-	Vec3 v3;
-	v3.x = vec3Tree.get<float>("x");
-	v3.y = vec3Tree.get<float>("y");
-	v3.z = vec3Tree.get<float>("z");
-	return v3;
+	const boost::property_tree::ptree& tree = pt.get_child("vec3");
+	return Vec3(tree.get<float>("x"), tree.get<float>("y"), tree.get<float>("z"));
+}
+
+
+//======================================================================================================================
+// getVec4                                                                                                             =
+//======================================================================================================================
+Vec4 getVec4(const boost::property_tree::ptree& pt)
+{
+	const boost::property_tree::ptree& tree = pt.get_child("vec4");
+	return Vec4(tree.get<float>("x"), tree.get<float>("y"), tree.get<float>("z"), tree.get<float>("w"));
 }
 
 

+ 6 - 0
src/Misc/PropertyTree.h

@@ -23,9 +23,15 @@ extern boost::optional<bool> getBoolOptional(const boost::property_tree::ptree&
 /// Get a @code<float>0.0</float>@endcode
 extern float getFloat(const boost::property_tree::ptree& pt);
 
+/// Get a @code<vec2><x>0.0</x><y>0.0</y></vec2>@endcode
+extern Vec2 getVec2(const boost::property_tree::ptree& pt);
+
 /// Get a @code<vec3><x>0.0</x><y>0.0</y><z>0.0</z></vec3>@endcode
 extern Vec3 getVec3(const boost::property_tree::ptree& pt);
 
+/// Get a @code<vec4><x>0.0</x><y>0.0</y><z>0.0</z><w>0.0</w></vec4>@endcode
+extern Vec4 getVec4(const boost::property_tree::ptree& pt);
+
 } // end namespace
 
 #endif

+ 71 - 56
src/Renderer/Bs.cpp

@@ -1,8 +1,13 @@
+#include <boost/ptr_container/ptr_vector.hpp>
 #include "Bs.h"
 #include "Renderer.h"
 #include "App.h"
 #include "Scene.h"
 #include "ShaderProg.h"
+#include "Model.h"
+#include "ModelNode.h"
+#include "Material.h"
+#include "Mesh.h"
 
 
 //======================================================================================================================
@@ -81,71 +86,81 @@ void Bs::run()
 
 	glDepthMask(false);
 
-	// render the meshes
-	/// @todo Uncomment this
-	/*for(Vec<MeshNode*>::iterator it=app->getScene().meshNodes.begin(); it!=app->getScene().meshNodes.end(); it++)
+	// render the models
+	Vec<ModelNode*>::const_iterator it = app->getScene().modelNodes.begin();
+	for(; it != app->getScene().modelNodes.end(); ++it)
 	{
-		MeshNode* meshNode = (*it);
-
-		if(meshNode->mesh->material.get() == NULL)
-		{
-			throw EXCEPTION("Mesh \"" + meshNode->mesh->getRsrcName() + "\" doesnt have material" );
-		}
-
-		if(!meshNode->mesh->material->renderInBlendingStage())
-		{
-			continue;
-		}
-
-		// refracts
-		if(meshNode->mesh->material->getStdUniVar(Material::SUV_PPS_PRE_PASS_FAI))
+		const ModelNode& mn = *(*it);
+		boost::ptr_vector<Model::SubModel>::const_iterator it = mn.getModel().getSubModels().begin();
+		for(; it != mn.getModel().getSubModels().end(); it++)
 		{
-			// render to the temp FAI
-			refractFbo.bind();
-
-			glEnable(GL_STENCIL_TEST);
-			glClear(GL_STENCIL_BUFFER_BIT);
-			glStencilFunc(GL_ALWAYS, 0x1, 0x1);
-			glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
-
-			r.setupMaterial(*meshNode->mesh->material, *meshNode, r.getCamera());
-			glDisable(GL_BLEND); // a hack
-			meshNode->render();
-
-			// render the temp FAI to prePassFai
-			fbo.bind();
+			const Model::SubModel& sm = *it;
 
-			glStencilFunc(GL_EQUAL, 0x1, 0x1);
-			glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+			if(!sm.getMaterial().renderInBlendingStage())
+			{
+				continue;
+			}
 
-			if(meshNode->mesh->material->renderInBlendingStage())
+			// refracts ?
+			if(sm.getMaterial().getStdUniVar(Material::SUV_PPS_PRE_PASS_FAI))
 			{
-				glEnable(GL_BLEND);
-				glBlendFunc(meshNode->mesh->material->getBlendingSfactor(), meshNode->mesh->material->getBlendingDfactor());
+				//
+				// Stage 0: Render to the temp FAI
+				//
+				refractFbo.bind();
+
+				glEnable(GL_STENCIL_TEST);
+				glClear(GL_STENCIL_BUFFER_BIT);
+				glStencilFunc(GL_ALWAYS, 0x1, 0x1);
+				glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
+
+				r.setupShaderProg(sm.getMaterial(), mn, r.getCamera());
+				glDisable(GL_BLEND); // a hack
+
+				sm.getVao().bind();
+				glDrawElements(GL_TRIANGLES, sm.getMesh().getVertIdsNum(), GL_UNSIGNED_SHORT, 0);
+				sm.getVao().unbind();
+
+				//
+				// Stage 1: Render the temp FAI to prePassFai
+				//
+				fbo.bind();
+
+				glStencilFunc(GL_EQUAL, 0x1, 0x1);
+				glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+
+				if(sm.getMaterial().isBlendingEnabled())
+				{
+					glEnable(GL_BLEND);
+					glBlendFunc(sm.getMaterial().getBlendingSfactor(), sm.getMaterial().getBlendingDfactor());
+				}
+				else
+				{
+					glDisable(GL_BLEND);
+				}
+
+				refractSProg->bind();
+				refractSProg->findUniVar("fai")->setTexture(refractFai, 0);
+
+				r.drawQuad();
+
+				// cleanup
+				glStencilFunc(GL_ALWAYS, 0x1, 0x1);
+				glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
+				glClear(GL_STENCIL_BUFFER_BIT);
+				glDisable(GL_STENCIL_TEST);
 			}
+			// no rafraction
 			else
 			{
-				glDisable(GL_BLEND);
-			}
-
-			refractSProg->bind();
-			refractSProg->findUniVar("fai")->setTexture(refractFai, 0);
+				r.setupShaderProg(sm.getMaterial(), mn, r.getCamera());
 
-			r.drawQuad();
-
-			// cleanup
-			glStencilFunc(GL_ALWAYS, 0x1, 0x1);
-			glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
-			glClear(GL_STENCIL_BUFFER_BIT);
-			glDisable(GL_STENCIL_TEST);
-		}
-		else
-		{
-			fbo.bind();
-			r.setupMaterial(*meshNode->mesh->material, *meshNode, r.getCamera());
-			meshNode->render();
-		}
-	}*/
+				sm.getVao().bind();
+				glDrawElements(GL_TRIANGLES, sm.getMesh().getVertIdsNum(), GL_UNSIGNED_SHORT, 0);
+				sm.getVao().unbind();
+			}
+		} // end for all subModels
+	} // end for all modelNodes
 
 	glDepthMask(true);
 	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // the rendering above fucks the polygon mode

+ 1 - 1
src/Renderer/Hdr.h

@@ -42,7 +42,7 @@ class Hdr: private RenderingPass
 		RsrcPtr<ShaderProg> vblurSProg;
 		float blurringDist;
 		uint blurringIterations;
-		float exposure; ///< @todo
+		float exposure; ///< How bright is the HDR
 		bool enabled;
 		float renderingQuality;
 

+ 2 - 11
src/Renderer/Ms.cpp

@@ -1,7 +1,5 @@
 #include "Ms.h"
 #include "Renderer.h"
-#include "App.h"
-#include "Scene.h"
 #include "Camera.h"
 #include "Ez.h"
 #include "ModelNode.h"
@@ -95,15 +93,8 @@ void Ms::run()
 		glDepthFunc(GL_EQUAL);
 	}
 
-	// render the meshes
-	for(Vec<ModelNode*>::const_iterator it = app->getScene().modelNodes.begin();
-			it != app->getScene().modelNodes.end(); ++it)
-	{
-		const ModelNode& md = *(*it);
-		r.renderModelNode(md, r.getCamera(), Renderer::MNRT_NORMAL);
-	}
-
-	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // the rendering above fucks the polygon mode
+	// render all
+	r.renderAllModelNodes(r.getCamera(), Renderer::MNRT_MS);
 
 	// restore depth
 	if(ez->isEnabled())

+ 48 - 21
src/Renderer/Renderer.cpp

@@ -94,9 +94,9 @@ void Renderer::drawQuad()
 
 
 //======================================================================================================================
-// setupMaterial                                                                                                       =
+// setupShaderProg                                                                                                     =
 //======================================================================================================================
-void Renderer::setupMaterial(const Material& mtl, const SceneNode& sceneNode, const Camera& cam) const
+void Renderer::setupShaderProg(const Material& mtl, const ModelNode& modelNode, const Camera& cam) const
 {
 	mtl.getShaderProg().bind();
 	uint textureUnit = 0;
@@ -138,7 +138,7 @@ void Renderer::setupMaterial(const Material& mtl, const SceneNode& sceneNode, co
 	//
 	// calc needed matrices
 	//
-	Mat4 modelMat(sceneNode.getWorldTransform());
+	Mat4 modelMat(modelNode.getWorldTransform());
 	const Mat4& projectionMat = cam.getProjectionMatrix();
 	const Mat4& viewMat = cam.getViewMatrix();
 	Mat4 modelViewMat;
@@ -256,6 +256,21 @@ void Renderer::setupMaterial(const Material& mtl, const SceneNode& sceneNode, co
 		(*it).set(textureUnit);
 	}
 
+	//
+	// Set the bone transformations
+	//
+	if(modelNode.hasSkeleton())
+	{
+		RASSERT_THROW_EXCEPTION(!mtl.hasHwSkinning()); // it has skel controller but no skinning
+
+		// first the uniforms
+		mtl.getStdUniVar(Material::SUV_SKINNING_ROTATIONS)->setMat3(&modelNode.getBoneRotations()[0],
+		                                                            modelNode.getBoneRotations().size());
+
+		mtl.getStdUniVar(Material::SUV_SKINNING_TRANSLATIONS)->setVec3(&modelNode.getBoneTranslations()[0],
+		                                                               modelNode.getBoneTranslations().size());
+	}
+
 	ON_GL_FAIL_THROW_EXCEPTION();
 }
 
@@ -265,13 +280,21 @@ void Renderer::setupMaterial(const Material& mtl, const SceneNode& sceneNode, co
 //======================================================================================================================
 void Renderer::renderModelNode(const ModelNode& modelNode, const Camera& cam, ModelNodeRenderType type) const
 {
-	for(uint i = 0; i < modelNode.getModel().getSubModels().size(); i++)
+	boost::ptr_vector<Model::SubModel>::const_iterator it = modelNode.getModel().getSubModels().begin();
+	for(; it != modelNode.getModel().getSubModels().end(); it++)
 	{
-		const Model::SubModel& subModel = modelNode.getModel().getSubModels()[i];
+		const Model::SubModel& subModel = *it;
+
+		if((type == MNRT_MS && subModel.getMaterial().renderInBlendingStage()) ||
+		   (type == MNRT_BS && !subModel.getMaterial().renderInBlendingStage()) ||
+		   (type == MNRT_DP && subModel.getMaterial().renderInBlendingStage()))
+		{
+			continue;
+		}
 
 		const Material* mtl;
 		const Vao* vao;
-		if(type == MNRT_NORMAL)
+		if(type == MNRT_MS || type == MNRT_BS)
 		{
 			mtl = &subModel.getMaterial();
 			vao = &subModel.getVao();
@@ -282,21 +305,8 @@ void Renderer::renderModelNode(const ModelNode& modelNode, const Camera& cam, Mo
 			vao = &subModel.getDpVao();
 		}
 
-		// Material
-		setupMaterial(*mtl, modelNode, cam);
-
-		// Render
-		if(modelNode.hasSkeleton())
-		{
-			RASSERT_THROW_EXCEPTION(!mtl->hasHwSkinning()); // it has skel controller but no skinning
-
-			// first the uniforms
-			mtl->getStdUniVar(Material::SUV_SKINNING_ROTATIONS)->setMat3(&modelNode.getBoneRotations()[0],
-			                                                             modelNode.getBoneRotations().size());
-
-			mtl->getStdUniVar(Material::SUV_SKINNING_TRANSLATIONS)->setVec3(&modelNode.getBoneTranslations()[0],
-			                                                                modelNode.getBoneTranslations().size());
-		}
+		// Shader
+		setupShaderProg(*mtl, modelNode, cam);
 
 		vao->bind();
 		glDrawElements(GL_TRIANGLES, subModel.getMesh().getVertIdsNum(), GL_UNSIGNED_SHORT, 0);
@@ -305,6 +315,23 @@ void Renderer::renderModelNode(const ModelNode& modelNode, const Camera& cam, Mo
 }
 
 
+//======================================================================================================================
+// renderAllModelNodes                                                                                                 =
+//======================================================================================================================
+void Renderer::renderAllModelNodes(const Camera& cam, ModelNodeRenderType type) const
+{
+	Vec<ModelNode*>::const_iterator it = app->getScene().modelNodes.begin();
+	for(; it != app->getScene().modelNodes.end(); ++it)
+	{
+		const ModelNode& md = *(*it);
+		renderModelNode(md, cam, type);
+	}
+
+	// the rendering above fucks the polygon mode
+	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+}
+
+
 //======================================================================================================================
 // unproject                                                                                                           =
 //======================================================================================================================

+ 16 - 10
src/Renderer/Renderer.h

@@ -19,7 +19,7 @@
 
 class Camera;
 class RendererInitializer;
-class SceneNode;
+class ModelNode;
 class ModelNode;
 
 
@@ -39,11 +39,12 @@ class Renderer: public Object
 	// Public                                                                                                            =
 	//====================================================================================================================
 	public:
-		/// The two types of rendering a ModelNode
+		/// The types of rendering a ModelNode
 		enum ModelNodeRenderType
 		{
-			MNRT_NORMAL,
-			MNRT_DEPTH
+			MNRT_MS, ///< In material stage
+			MNRT_DP, ///< In a depth pass
+			MNRT_BS  ///< In blending stage
 		};
 
 		Renderer(Object* parent);
@@ -93,16 +94,21 @@ class Renderer: public Object
 		/// OpenGL wrapper
 		static void setViewport(uint x, uint y, uint w, uint h) {glViewport(x, y, w, h);}
 
-		/// This functions sets the GL state using a material and a few other things
-		/// @param mtl The material containing the shader program
-		/// @param sceneNode Needed for some matrices
-		/// @param cam Needed for some matrices
-		void setupMaterial(const class Material& mtl, const SceneNode& sceneNode, const Camera& cam) const;
-
+		/// This function:
+		/// - binds the shader program
+		/// - loads the uniforms
+		/// - sets the GL state
+		/// @param mtl The material containing the shader program and the locations
+		/// @param modelNode Needed for some matrices (model) and the bone stuff (rotations & translations)
+		/// @param cam Needed for some matrices (view & projection)
+		void setupShaderProg(const class Material& mtl, const ModelNode& modelNode, const Camera& cam) const;
 
 		/// Render ModelNode. The method sets up the shader and renders the geometry
 		void renderModelNode(const ModelNode& modelNode, const Camera& cam, ModelNodeRenderType type) const;
 
+		/// Render all ModelNodes
+		void renderAllModelNodes(const Camera& cam, ModelNodeRenderType type) const;
+
 		/// Draws a quad. Actually it draws 2 triangles because OpenGL will no longer support quads
 		/// @param vertCoordsAttribLoc The attribute location of the vertex positions
 		void drawQuad();

+ 2 - 15
src/Renderer/Sm.cpp

@@ -91,21 +91,8 @@ void Sm::run(const Camera& cam)
 	glPolygonOffset(2.0, 2.0); // keep the values as low as possible!!!!
 	glEnable(GL_POLYGON_OFFSET_FILL);
 
-	// render all meshes
-	/// @todo Uncomment
-	/*for(Vec<MeshNode*>::iterator it=app->getScene().meshNodes.begin(); it!=app->getScene().meshNodes.end(); it++)
-	{
-		MeshNode* meshNode = (*it);
-		if(meshNode->mesh->material->renderInBlendingStage())
-		{
-			continue;
-		}
-
-		//RASSERT_THROW_EXCEPTION(meshNode->mesh->material->dpMtl.get() == NULL);
-
-		r.setupMaterial(meshNode->mesh->material->getDepthMtl(), *meshNode, cam);
-		meshNode->renderDepth();
-	}*/
+	// render all
+	r.renderAllModelNodes(cam, Renderer::MNRT_DP);
 
 	// restore GL
 	glDisable(GL_POLYGON_OFFSET_FILL);

+ 2 - 2
src/Resources/Material.cpp

@@ -321,7 +321,7 @@ void Material::load(const char* filename)
 						break;
 						// vec2
 					case GL_FLOAT_VEC2:
-						/// @todo
+						userDefinedVars.push_back(new UserDefinedUniVar(uni, PropertyTree::getVec2(valueTree)));
 						break;
 						// vec3
 					case GL_FLOAT_VEC3:
@@ -329,7 +329,7 @@ void Material::load(const char* filename)
 						break;
 						// vec4
 					case GL_FLOAT_VEC4:
-						/// @todo
+						userDefinedVars.push_back(new UserDefinedUniVar(uni, PropertyTree::getVec4(valueTree)));
 						break;
 				};
 			} // end for all userDefinedVars

Some files were not shown because too many files changed in this diff