Explorar el Código

Transform feedback

Panagiotis Christopoulos Charitos hace 15 años
padre
commit
39607f267d

+ 3 - 2
shaders/HwSkinningTrffbGeneric.glsl → shaders/TfHwSkinningGeneric.glsl

@@ -7,8 +7,8 @@ in vec3 position;
 in vec3 normal;
 in vec4 tangent;
 in float vertWeightBonesNum;
-in vec4  vertWeightBoneIds;
-in vec4  vertWeightWeights;
+in vec4 vertWeightBoneIds;
+in vec4 vertWeightWeights;
 
 const int MAX_BONES_PER_MESH = 60;
 uniform mat3 skinningRotations[MAX_BONES_PER_MESH];
@@ -55,3 +55,4 @@ void main()
 
 void main()
 {}
+

+ 4 - 1
src/Resources/ShaderProg.h

@@ -132,6 +132,9 @@ class ShaderProg: public Resource
 		static std::string createSrcCodeToCache(const char* sProgFPathName, const char* preAppendedSrcCode,
 		                                        const char* newFNamePrefix);
 
+		/// Reling the program. Used in transform feedback
+		void relink() const {link();}
+
 	//====================================================================================================================
 	// Private                                                                                                           =
 	//====================================================================================================================
@@ -161,7 +164,7 @@ class ShaderProg: public Resource
 
 		/// Link the shader program
 		/// @exception Exception
-		void link();
+		void link() const;
 
 		/// Resource load
 		void load(const char* filename);

+ 20 - 0
src/Scene/ModelNodePatch.cpp

@@ -32,6 +32,26 @@ ModelNodePatch::ModelNodePatch(const ModelPatch& modelPatch_, bool isSkinPatch):
 		                                modelPatch.getMesh().getVbo(Mesh::VBO_VERT_POSITIONS).getSizeInBytes(),
 		                                NULL,
 		                                GL_STATIC_DRAW);
+
+		tfVbos[TF_VBO_NORMALS].create(GL_ARRAY_BUFFER,
+		                              modelPatch.getMesh().getVbo(Mesh::VBO_VERT_NORMALS).getSizeInBytes(),
+		                              NULL,
+		                              GL_STATIC_DRAW);
+
+		tfVbos[TF_VBO_TANGENTS].create(GL_ARRAY_BUFFER,
+		                               modelPatch.getMesh().getVbo(Mesh::VBO_VERT_TANGENTS).getSizeInBytes(),
+		                               NULL,
+		                               GL_STATIC_DRAW);
+
+		//
+		// Load TF material and to TF stuff
+		//
+		tfMtl.loadRsrc("material/TfHwSkinning.mtl");
+
+		int id = tfMtl->getShaderProg().getGlId();
+		const char* tfVaryings[] = {"vPosition", "vNormal", "vTangent"};
+		glTransformFeedbackVaryings(id, 3, tfVaryings, GL_SEPARATE_ATTRIBS);
+		tfMtl->getShaderProg().relink();
 	}
 }
 

+ 2 - 0
src/Scene/ModelNodePatch.h

@@ -6,6 +6,7 @@
 #include "Vbo.h"
 #include "Mesh.h" // For the Vbos enum
 #include "Model.h"
+#include "RsrcPtr.h"
 
 
 class Material;
@@ -36,6 +37,7 @@ class ModelNodePatch
 		Vao mainVao; ///< VAO for MS and BS
 		Vao dpVao; ///< VAO for depth passes
 		Vao tfVao; ///< VAO for transform feedback
+		RsrcPtr<Material> tfMtl;
 
 		static void createVao(const Material& material, const boost::array<const Vbo*, Mesh::VBOS_NUM>& vbos, Vao& vao);
 };