Przeglądaj źródła

- Bug fixing. The engine now compiles and runs

Panagiotis Christopoulos Charitos 14 lat temu
rodzic
commit
8d3c35fb31

+ 2 - 0
build/clean

@@ -0,0 +1,2 @@
+#!/bin/bash
+rm -rf CMakeCache.txt CMakeFiles Makefile cmake_install.cmake src

+ 0 - 0
build/gen-makefile-dbg → build/genmakefiledbg


+ 11 - 10
shaders/IsLpGeneric.glsl

@@ -50,7 +50,7 @@ const float MAX_SHININESS = 128.0;
 /// @return frag pos in view space
 vec3 getFragPosVSpace()
 {
-	float depth = texture2D(msDepthFai, vTexCoords).r;
+	float depth = texture(msDepthFai, vTexCoords).r;
 
 	/*if(depth == 1.0)
 	{
@@ -103,11 +103,11 @@ float pcfLow(in vec3 shadowUv)
 		vec2(-1.0, 0.0)
 	);
 	
-	float shadowCol = shadow2D(shadowMap, shadowUv).r;
+	float shadowCol = texture(shadowMap, shadowUv);
 	for(int i = 0; i < KERNEL_SIZE; i++)
 	{
 		vec3 uv = vec3(shadowUv.xy + (KERNEL[i] * mapScale), shadowUv.z);
-		shadowCol += shadow2D(shadowMap, uv).r;
+		shadowCol += texture(shadowMap, uv);
 	}
 	
 	shadowCol *= (1.0 / 9.0);
@@ -135,7 +135,7 @@ vec3 doPhong(in vec3 fragPosVspace, out float fragLightDist)
 	vec3 lightDir = frag2LightVec * inversesqrt(fragLightDist);
 
 	// Read the normal
-	vec3 normal = unpackNormal(texture2D(msNormalFai, vTexCoords).rg);
+	vec3 normal = unpackNormal(texture(msNormalFai, vTexCoords).rg);
 
 	// Lambert term
 	float lambertTerm = dot(normal, lightDir);
@@ -147,12 +147,12 @@ vec3 doPhong(in vec3 fragPosVspace, out float fragLightDist)
 	lambertTerm = max(0.0, lambertTerm);
 
 	// Diffuce
-	vec3 diffuse = texture2D(msDiffuseFai, vTexCoords).rgb;
+	vec3 diffuse = texture(msDiffuseFai, vTexCoords).rgb;
 	diffuse *= lightDiffuseCol;
 	vec3 color = diffuse * lambertTerm;
 
 	// Specular
-	vec4 specularMix = texture2D(msSpecularFai, vTexCoords); // the MS specular
+	vec4 specularMix = texture(msSpecularFai, vTexCoords); // the MS specular
 	                                      // FAI has the color and the shininess
 	vec3 specular = specularMix.xyz;
 	float shininess = specularMix.w * MAX_SHININESS;
@@ -177,7 +177,8 @@ vec3 doPointLight(in vec3 fragPosVspace)
 	// calculations we export it
 	float fragLightDist;
 	vec3 color = doPhong(fragPosVspace, fragLightDist);
-	return color * getAttenuation(fragLightDist);
+	vec3 ret = color * getAttenuation(fragLightDist);
+	return ret;
 }
 
 
@@ -201,7 +202,7 @@ vec3 doSpotLight(in vec3 fragPosVspace)
 #	if defined(PCF_ENABLED)
 		float shadowCol = pcfLow(texCoords3);
 #	else
-		float shadowCol = shadow2D(shadowMap, texCoords3).r;
+		float shadowCol = texture(shadowMap, texCoords3);
 #	endif
 
 		if(shadowCol == 0.0)
@@ -213,7 +214,7 @@ vec3 doSpotLight(in vec3 fragPosVspace)
 		float fragLightDist;
 		vec3 color = doPhong(fragPosVspace, fragLightDist);
 
-		vec3 lightTexCol = texture2DProj(lightTex, texCoords2.xyz).rgb;
+		vec3 lightTexCol = textureProj(lightTex, texCoords2.xyz).rgb;
 		float att = getAttenuation(fragLightDist);
 
 #if defined(SHADOW_ENABLED)
@@ -249,6 +250,6 @@ void main()
 	//gl_FragData[0] = gl_FragData[0] - gl_FragData[0] + vec4(1, 0, 1, 1);
 	/*#if defined(SPOT_LIGHT_ENABLED)
 	fColor = fColor - fColor + vec3(1, 0, 1);
-	//gl_FragData[0] = vec4(texture2D(msDepthFai, vTexCoords).rg), 1.0);
+	//gl_FragData[0] = vec4(texture(msDepthFai, vTexCoords).rg), 1.0);
 	#endif*/
 }

+ 22 - 9
shaders/MaterialFragmentFunctions.glsl

@@ -22,7 +22,7 @@ vec3 getNormalFromTexture(in vec3 normal, in vec3 tangent, in float tangentW,
 
 	mat3 tbnMat = mat3(t, b, n);
 
-	vec3 nAtTangentspace = (texture2D(map, texCoords).rgb - 0.5) * 2.0;
+	vec3 nAtTangentspace = (texture(map, texCoords).rgb - 0.5) * 2.0;
 
 	return normalize(tbnMat * nAtTangentspace);
 #else
@@ -66,7 +66,7 @@ vec3 getEnvironmentColor(in vec3 vertPosViewSpace, in vec3 normal,
 	float m = 2.0 * length(r);
 	vec2 semTexCoords = r.xy / m + 0.5;
 
-	vec3 semCol = texture2D(map, semTexCoords).rgb;
+	vec3 semCol = texture(map, semTexCoords).rgb;
 	return semCol;
 #else
 	return vec3(0.0);
@@ -89,14 +89,14 @@ vec3 getDiffuseColorAndDoAlphaTesting(
 	in float tolerance)
 {
 #if defined(COLOR_PASS)
-	vec4 col = texture2D(map, texCoords);
+	vec4 col = texture(map, texCoords);
 	if(col.a < tolerance)
 	{
 		discard;
 	}
 	return col.rgb;
 #else
-	float a = texture2D(map, texCoords).a;
+	float a = texture(map, texCoords).a;
 	if(a < tolerance)
 	{
 		discard;
@@ -107,25 +107,38 @@ vec3 getDiffuseColorAndDoAlphaTesting(
 
 
 //==============================================================================
-// readColor3FromTexture                                                       =
+// readRgbFromTexture                                                          =
 //==============================================================================
 /// Just read the RGB color from texture
-vec3 readColor3FromTexture(in sampler2D tex, in vec2 texCoords)
+vec3 readRgbFromTexture(in sampler2D tex, in vec2 texCoords)
 {
 #if defined(COLOR_PASS)
-	return texture2D(tex, texCoords).rgb;
+	return texture(tex, texCoords).rgb;
 #else
 	return vec3(0.0);
 #endif
 }
 
 
+//==============================================================================
+// add2Vec2                                                                    =
+//==============================================================================
+vec3 add2Vec2(in vec3 a, in vec3 b)
+{
+	return a + b;
+}
+
+
 //==============================================================================
 // writeFais                                                                   =
 //==============================================================================
 /// XXX
-void writeFais(in vec3 diffCol, in vec3 normal, in vec3 specularCol,
-	in float shininess, in float blurring)
+void writeFais(
+	in vec3 diffCol, 
+	in vec3 normal, 
+	in vec3 specularCol,
+	in float shininess, 
+	in float blurring)
 {
 #if defined(COLOR_PASS)
 	fMsNormalFai = vec3(packNormal(normal), blurring);

+ 14 - 0
shaders/MaterialFragmentVariables.glsl

@@ -1,3 +1,17 @@
+/// @name Uniforms
+/// @{
+uniform float blurring;
+/// @}
+
+/// @name Varyings
+/// @{
+in vec2 vTexCoords;
+in vec3 vNormal;
+in vec3 vTangent;
+in float vTangentW;
+in vec3 vVertPosViewSpace;
+/// @}
+
 /// @name Fragment out
 /// @{
 #if defined(COLOR_PASS)

+ 0 - 18
shaders/MaterialVertex.glsl

@@ -4,16 +4,10 @@
 /// @name Attributes
 /// @{
 layout(location = 0) in vec3 position;
-#if defined(USING_TEX_COORDS_ATTRIB)
 layout(location = 3) in vec2 texCoords;
-#endif
 #if defined(COLOR_PASS)
-#	if defined(USING_NORMAL_ATTRIB)
 layout(location = 1) in vec3 normal;
-#	endif
-#	if defined(USING_TANGENT_ATTRIB)
 layout(location = 2) in vec4 tangent;
-#	endif
 #endif
 /// @}
 
@@ -26,17 +20,11 @@ uniform mat4 modelViewMat;
 
 /// @name Varyings
 /// @{
-#if defined(USING_TEX_COORDS_ATTRIB)
 out vec2 vTexCoords;
-#endif
 #if defined(COLOR_PASS)
-#	if defined(USING_NORMAL_ATTRIB)
 out vec3 vNormal;
-#	endif
-#	if defined(USING_TANGENT_ATTRIB)
 out vec3 vTangent;
 out float vTangentW;
-#	endif
 out vec3 vVertPosViewSpace; ///< For env mapping. AKA view vector
 #endif
 /// @}
@@ -49,19 +37,13 @@ out vec3 vVertPosViewSpace; ///< For env mapping. AKA view vector
 void main()
 {
 #if defined(COLOR_PASS)
-#	if defined(USING_NORMAL_ATTRIB)
 	vNormal = normalMat * normal;
-#	endif
-#	if defined(USING_TANGENT_ATTRIB)
 	vTangent = normalMat * vec3(tangent);
 	vTangentW = tangent.w;
-#	endif
 	vVertPosViewSpace = vec3(modelViewMat * vec4(position, 1.0));
 #endif
 
-#if defined(USING_TEX_COORDS_ATTRIB)
 	vTexCoords = texCoords;
-#endif
 
 	gl_Position = modelViewProjectionMat * vec4(position, 1.0);
 }

+ 5 - 3
src/Main.cpp

@@ -126,8 +126,8 @@ void init()
 {
 	INFO("Other init...");
 
-	Material mtl;
-	mtl.load("lala.mtl");
+	/*Material mtl;
+	mtl.load("lala.mtl");*/
 
 	srand(unsigned(time(NULL)));
 
@@ -231,9 +231,11 @@ void init()
 	//node->setLocalTransform(Transform(Vec3(0.0, -0.0, 0.0), Mat3::getIdentity(), 0.01));
 
 	// particle emitter
+	/*
+	XXX
 	partEmitter = new ParticleEmitterNode(false, NULL);
 	partEmitter->init("asdf");
-	partEmitter->getLocalTransform().setOrigin(Vec3(3.0, 0.0, 0.0));
+	partEmitter->getLocalTransform().setOrigin(Vec3(3.0, 0.0, 0.0));*/
 
 	return;
 

+ 2 - 2
src/event/SceneColor.cpp

@@ -15,7 +15,7 @@ SceneColor::SceneColor(float startTime, float duration,
 :	Event(SCENE_COLOR, startTime, duration),
 	finalColor(finalColor_)
 {
-	originalColor = SceneSingleton::get().getAmbientCol();
+	originalColor = SceneSingleton::get().getAmbientColor();
 }
 
 
@@ -49,7 +49,7 @@ void SceneColor::updateSp(float /*prevUpdateTime*/, float crntTime)
 	float d = crntTime - getStartTime(); // delta
 	float dp = d / float(getDuration()); // delta as persentage
 
-	SceneSingleton::get().setAmbientCol(
+	SceneSingleton::get().setAmbientColor(
 		interpolate(originalColor, finalColor, dp));
 }
 

+ 10 - 7
src/r/Is.cpp

@@ -1,7 +1,3 @@
-#include <boost/lexical_cast.hpp>
-#include <boost/foreach.hpp>
-#include <boost/array.hpp>
-
 #include "Is.h"
 #include "Renderer.h"
 #include "scene/Camera.h"
@@ -15,10 +11,17 @@
 #include "Smo.h"
 #include "scene/Scene.h"
 
+#include <boost/lexical_cast.hpp>
+#include <boost/foreach.hpp>
+#include <boost/array.hpp>
+
 
 namespace r {
 
 
+#define BLEND_ENABLE true
+
+
 //==============================================================================
 // Constructor                                                                 =
 //==============================================================================
@@ -225,7 +228,7 @@ void Is::spotLightPass(const SpotLight& light)
 		fbo.bind();
 
 		// and restore blending and depth test
-		GlStateMachineSingleton::get().enable(GL_BLEND, true);
+		GlStateMachineSingleton::get().enable(GL_BLEND, BLEND_ENABLE);
 		glBlendFunc(GL_ONE, GL_ONE);
 		GlStateMachineSingleton::get().enable(GL_DEPTH_TEST, false);
 		GlStateMachineSingleton::get().setViewport(0, 0,
@@ -339,10 +342,10 @@ void Is::run()
 
 	// ambient pass
 	GlStateMachineSingleton::get().enable(GL_DEPTH_TEST, false);
-	ambientPass(SceneSingleton::get().getAmbientCol());
+	ambientPass(SceneSingleton::get().getAmbientColor());
 
 	// light passes
-	GlStateMachineSingleton::get().enable(GL_BLEND, true);
+	GlStateMachineSingleton::get().enable(GL_BLEND, BLEND_ENABLE);
 	glBlendFunc(GL_ONE, GL_ONE);
 	GlStateMachineSingleton::get().enable(GL_STENCIL_TEST);
 

+ 7 - 6
src/r/MainRenderer.cpp

@@ -22,8 +22,7 @@ namespace r {
 //==============================================================================
 MainRenderer::MainRenderer():
 	dbg(*this),
-	screenshotJpegQuality(90),
-	deformer(new Deformer(*this))
+	screenshotJpegQuality(90)
 {}
 
 
@@ -54,6 +53,7 @@ void MainRenderer::init(const RendererInitializer& initializer_)
 		renderingQuality;
 	Renderer::init(initializer);
 	dbg.init(initializer);
+	deformer.reset(new Deformer(*this));
 	INFO("Main renderer initialized");
 }
 
@@ -63,6 +63,7 @@ void MainRenderer::init(const RendererInitializer& initializer_)
 //==============================================================================
 void MainRenderer::initGl()
 {
+	glewExperimental = GL_TRUE;
 	GLenum err = glewInit();
 	if(err != GLEW_OK)
 	{
@@ -82,7 +83,7 @@ void MainRenderer::initGl()
 	//glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &maxColorAtachments);
 	int& tun = Texture::getTextureUnitsNum();
 	glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &tun);
-	glClearColor(0.1, 0.1, 0.1, 1.0);
+	glClearColor(0.1, 0.1, 0.0, 1.0);
 	glClearDepth(1.0);
 	glClearStencil(0);
 	glDepthFunc(GL_LEQUAL);
@@ -139,9 +140,9 @@ void MainRenderer::render(Camera& cam_)
 	GlStateMachineSingleton::get().enable(GL_DEPTH_TEST, false);
 	GlStateMachineSingleton::get().enable(GL_BLEND, false);
 	sProg->bind();
-	//sProg->getUniformVariableByName("rasterImage")->set(ms.getNormalFai(), 0);
-	//sProg->getUniformVariableByName("rasterImage")->
-	//	set(pps.getSsao().getFai(), 0);
+	//sProg->getUniformVariableByName("rasterImage").set(ms.getDiffuseFai(), 0);
+	//sProg->getUniformVariableByName("rasterImage").
+	//	set(is.getFai(), 0);
 	sProg->getUniformVariableByName("rasterImage").set(pps.getPostPassFai(), 0);
 	drawQuad();
 }

+ 1 - 1
src/r/Ms.cpp

@@ -113,7 +113,7 @@ void Ms::run()
 		glDepthFunc(GL_EQUAL);
 	}
 
-	//glClear(GL_COLOR_BUFFER_BIT);
+	glClear(GL_COLOR_BUFFER_BIT);
 
 	// render all
 	BOOST_FOREACH(const RenderableNode* node,

+ 6 - 1
src/r/SceneDrawer.cpp

@@ -221,7 +221,7 @@ void SceneDrawer::setupShaderProg(
 
 	if(mtl.buildinVariableExits(Mvb::MV_SCENE_AMBIENT_COLOR, pt))
 	{
-		Vec3 col(SceneSingleton::get().getAmbientCol());
+		Vec3 col(SceneSingleton::get().getAmbientColor());
 		mtl.getBuildinVariable(Mvb::MV_SCENE_AMBIENT_COLOR).
 			getShaderProgramUniformVariable(pt).set(&col);
 	}
@@ -241,6 +241,11 @@ void SceneDrawer::setupShaderProg(
 	//
 	BOOST_FOREACH(const MaterialRuntimeVariable& udvr, mtlr.getVariables())
 	{
+		if(!udvr.getMaterialUserVariable().inPass(pt))
+		{
+			continue;
+		}
+
 		boost::apply_visitor(UsrDefVarVisitor(udvr, r, pt, textureUnit),
 			udvr.getDataVariant());
 	}

+ 5 - 5
src/rsrc/Image.cpp

@@ -70,20 +70,20 @@ void Image::loadCompressedTga(std::fstream& fs, uint& bpp)
 	height = header6[3] * 256 + header6[2];
 	bpp	= header6[4];
 
-	if((width <= 0) || (height <= 0) || ((bpp != 24) && (bpp !=32)))
+	if((width <= 0) || (height <= 0) || ((bpp != 24) && (bpp != 32)))
 	{
 		throw EXCEPTION("Invalid texture information");
 	}
 
 
 	int bytesPerPxl = (bpp / 8);
-	int image_size = bytesPerPxl * width * height;
-	data.resize(image_size);
+	int imageSize = bytesPerPxl * width * height;
+	data.resize(imageSize);
 
 	uint pixelcount = height * width;
 	uint currentpixel = 0;
-	uint currentbyte	= 0;
-	unsigned char colorbuffer [4];
+	uint currentbyte = 0;
+	unsigned char colorbuffer[4];
 
 	do
 	{

+ 14 - 12
src/rsrc/MaterialBuildinVariable.cpp

@@ -10,8 +10,8 @@
 // Statics                                                                     =
 //==============================================================================
 
-ConstCharPtrHashMap<MaterialBuildinVariable::MatchingVariable>::Type
-	MaterialBuildinVariable::buildinNameToEnum = boost::assign::map_list_of
+MaterialBuildinVariable::StrToMatchingVariable
+	MaterialBuildinVariable::strToMatchingVariable = boost::assign::map_list_of
 	("position", MV_POSITION)
 	("tangent", MV_TANGENT)
 	("normal", MV_NORMAL)
@@ -35,8 +35,9 @@ ConstCharPtrHashMap<MaterialBuildinVariable::MatchingVariable>::Type
 	("blurring", MV_BLURRING);
 
 
-boost::unordered_map<MaterialBuildinVariable::MatchingVariable, GLenum>
-	MaterialBuildinVariable::buildinToGlType = boost::assign::map_list_of
+MaterialBuildinVariable::MatchingVariableToGlType
+	MaterialBuildinVariable::matchingVariableToGlType =
+	boost::assign::map_list_of
 	(MV_POSITION, GL_FLOAT_VEC3)
 	(MV_TANGENT, GL_FLOAT_VEC4)
 	(MV_NORMAL, GL_FLOAT_VEC3)
@@ -44,7 +45,7 @@ boost::unordered_map<MaterialBuildinVariable::MatchingVariable, GLenum>
 	(MV_MODEL_MAT, GL_FLOAT_MAT4)
 	(MV_VIEW_MAT, GL_FLOAT_MAT4)
 	(MV_PROJECTION_MAT, GL_FLOAT_MAT4)
-	(MV_PROJECTION_MAT, GL_FLOAT_MAT4)
+	(MV_MODELVIEW_MAT, GL_FLOAT_MAT4)
 	(MV_VIEWPROJECTION_MAT, GL_FLOAT_MAT4)
 	(MV_NORMAL_MAT, GL_FLOAT_MAT3)
 	(MV_MODELVIEWPROJECTION_MAT, GL_FLOAT_MAT4)
@@ -91,25 +92,26 @@ MaterialBuildinVariable::MaterialBuildinVariable(
 bool MaterialBuildinVariable::isBuildin(const char* name,
 	MatchingVariable* var, GLenum* dataType)
 {
-	ConstCharPtrHashMap<MatchingVariable>::Type::const_iterator it =
-		buildinNameToEnum.find(name);
+	StrToMatchingVariable::const_iterator it = strToMatchingVariable.find(name);
 
-	if(it == buildinNameToEnum.end())
+	if(it == strToMatchingVariable.end())
 	{
 		return false;
 	}
 
+	MatchingVariable mv = it->second;
+
 	if(var)
 	{
-		*var = it->second;
+		*var = mv;
 	}
 
 	if(dataType)
 	{
-		boost::unordered_map<MatchingVariable, GLenum>::const_iterator it2 =
-			buildinToGlType.find(it->second);
+		MatchingVariableToGlType::const_iterator it2 =
+			matchingVariableToGlType.find(mv);
 
-		ASSERT(it2 != buildinToGlType.end());
+		ASSERT(it2 != matchingVariableToGlType.end());
 
 		*dataType = it2->second;
 	}

+ 10 - 2
src/rsrc/MaterialBuildinVariable.h

@@ -60,11 +60,19 @@ class MaterialBuildinVariable: public MaterialVariable
 			GLenum* dataType = NULL);
 
 	private:
+		/// From string to MatchingVariable
+		typedef ConstCharPtrHashMap<MatchingVariable>::Type
+			StrToMatchingVariable;
+
+		/// From MatchingVariable to GL type (GLenum)
+		typedef boost::unordered_map<MatchingVariable, GLenum>
+			MatchingVariableToGlType;
+
 		/// Given a name of a variable find its MaterialBuildinVariable enum
-		static ConstCharPtrHashMap<MatchingVariable>::Type buildinNameToEnum;
+		static StrToMatchingVariable strToMatchingVariable;
 
 		/// Given a MaterialBuildinVariable enum it gives the GL type
-		static boost::unordered_map<MatchingVariable, GLenum> buildinToGlType;
+		static MatchingVariableToGlType matchingVariableToGlType;
 
 		MatchingVariable bEnum;
 };

+ 19 - 7
src/rsrc/MaterialShaderProgramCreator.cpp

@@ -184,6 +184,18 @@ void MaterialShaderProgramCreator::parseShaderFileForFunctionDefinitions(
 				throw PARSER_EXCEPTION_EXPECTED("identifier");
 			}
 
+			/*if(token->getValue().getString() == std::string("lowp") ||
+				token->getValue().getString() == std::string("highp") ||
+				token->getValue().getString() == std::string("mediump"))
+			{
+				getNextTokenAndSkipNewlines(scanner);
+
+				if(token->getCode() != scanner::TC_IDENTIFIER)
+				{
+					throw PARSER_EXCEPTION_EXPECTED("identifier");
+				}
+			}*/
+
 			try
 			{
 				argDef->dataType = txtToGlType.at(
@@ -383,22 +395,22 @@ void MaterialShaderProgramCreator::parseShaderProgramTag(
 	}
 
 	//
-	// <operators></operators>
+	// <operations></operations>
 	//
 	srcLines.push_back("\nvoid main()\n{");
 
-	const ptree& opsPt = pt.get_child("operators");
+	const ptree& opsPt = pt.get_child("operations");
 
 	BOOST_FOREACH(const ptree::value_type& v, opsPt)
 	{
-		if(v.first != "operator")
+		if(v.first != "operation")
 		{
-			throw EXCEPTION("Expected operator and not: " + v.first);
+			throw EXCEPTION("Expected operation and not: " + v.first);
 		}
 
 		const ptree& opPt = v.second;
 		parseOperatorTag(opPt);
-	} // end for all operators
+	} // end for all operations
 
 	srcLines.push_back("}\n");
 
@@ -540,7 +552,7 @@ void MaterialShaderProgramCreator::parseOperatorTag(
 	// Write return value
 	if(def->returnDataType != GL_NONE)
 	{
-		line << def->returnDataTypeTxt << " operatorOut" << id << " = ";
+		line << def->returnDataTypeTxt << " operationOut" << id << " = ";
 	}
 
 	// Func name
@@ -553,7 +565,7 @@ void MaterialShaderProgramCreator::parseOperatorTag(
 		if(v.first != "argument")
 		{
 			throw EXCEPTION("Unexpected tag \"" + v.first +
-				"\" for operator: " + boost::lexical_cast<std::string>(id));
+				"\" for operation: " + boost::lexical_cast<std::string>(id));
 
 		}
 

+ 4 - 2
src/rsrc/MaterialShaderProgramCreator.h

@@ -14,7 +14,9 @@ class Scanner;
 }
 
 
-/// XXX
+/// Creator of shader programs. This class parses between
+/// <shaderProgam></shaderProgram> located inside a <material></material>
+/// and creates the source of a custom program.
 class MaterialShaderProgramCreator
 {
 	public:
@@ -113,7 +115,7 @@ class MaterialShaderProgramCreator
 		/// Used by parseShaderFileForFunctionDefinitions to skip preprocessor
 		/// definitions. Takes into account the backslashes. For example for
 		/// @code
-		/// #define lala \\
+		/// #define lala \\ _
 		/// 	10
 		/// @endcode
 		/// it skips from define to 10

+ 5 - 1
src/rsrc/MaterialVariable.cpp

@@ -28,7 +28,7 @@ MaterialVariable::MaterialVariable(
 				oneSProgVar = sProgVars[i];
 			}
 
-			// All the sprog vars need to have same GL data type
+			// Sanity check: All the sprog vars need to have same GL data type
 			if(oneSProgVar->getGlDataType() != sProgVars[i]->getGlDataType() ||
 				oneSProgVar->getType() != sProgVars[i]->getType())
 			{
@@ -36,6 +36,10 @@ MaterialVariable::MaterialVariable(
 					shaderProgVarName);
 			}
 		}
+		else
+		{
+			sProgVars[i] = NULL;
+		}
 	}
 
 	// Extra sanity checks

+ 3 - 2
src/rsrc/MaterialVariable.h

@@ -32,7 +32,7 @@ class MaterialVariable
 		typedef boost::array<const ShaderProgramVariable*,
 			PASS_TYPES_NUM> ShaderProgramVariables;
 
-		/// XXX
+		/// Constructor
 		MaterialVariable(
 			Type type,
 			const char* shaderProgVarName,
@@ -46,7 +46,8 @@ class MaterialVariable
 		const ShaderProgramVariable& getShaderProgramVariable(
 			PassType p) const;
 
-		/// XXX
+		/// Check if pass p needs this variable. Check if the shader program
+		/// of p contains this variable or not
 		bool inPass(PassType p) const {return sProgVars[p] != NULL;}
 
 		/// Get the GL data type of all the shader program variables

+ 6 - 1
src/rsrc/ShaderProgram.cpp

@@ -25,9 +25,14 @@
 
 const char* ShaderProgram::stdSourceCode =
 	"#version 330 core\n"
-	"precision lowp float;\n"
+	//"precision lowp float;\n"
+#if defined(NDEBUG)
 	"#pragma optimize(on)\n"
 	"#pragma debug(off)\n";
+#else
+	"#pragma optimize(of)\n"
+	"#pragma debug(on)\n";
+#endif
 
 
 //==============================================================================

+ 21 - 11
src/rsrc/ShaderProgramPrePreprocessor.cpp

@@ -265,10 +265,8 @@ void ShaderProgramPrePreprocessor::parseStartPragma(scanner::Scanner& scanner,
 	cbp->definedInFile = filename;
 	cbp->definedInLine = scanner.getLineNumber();
 	cbp->globalLine = sourceLines.size() + 1;
-	sourceLines.push_back("#line " +
-		boost::lexical_cast<std::string>(scanner.getLineNumber()) +
-		' ' + boost::lexical_cast<std::string>(depth) +
-		" // " + lines[scanner.getLineNumber() - 1]);
+	addLinePreProcExpression(scanner.getLineNumber(), depth,
+		lines[scanner.getLineNumber() - 1].c_str());
 }
 
 
@@ -286,16 +284,13 @@ void ShaderProgramPrePreprocessor::parseIncludePragma(
 		std::string filename = token->getValue().getString();
 
 		//int line = sourceLines.size();
-		sourceLines.push_back("#line 0 " +
-			boost::lexical_cast<std::string>(depth + 1) +
-			" // " + lines[scanner.getLineNumber() - 1]);
+		addLinePreProcExpression(0, depth + 1,
+			lines[scanner.getLineNumber() - 1].c_str());
 
 		parseFileForPragmas(filename.c_str(), depth + 1);
 
-		sourceLines.push_back("#line " +
-			boost::lexical_cast<std::string>(scanner.getLineNumber()) + ' ' +
-			boost::lexical_cast<std::string>(depth) + " // end of " +
-			lines[scanner.getLineNumber() - 1]);
+		addLinePreProcExpression(scanner.getLineNumber(), depth,
+			(" // end of " + lines[scanner.getLineNumber() - 1]).c_str());
 	}
 	else
 	{
@@ -348,3 +343,18 @@ void ShaderProgramPrePreprocessor::parseTrffbVarying(scanner::Scanner& scanner,
 		throw PARSER_EXCEPTION_EXPECTED("identifier");
 	}
 }
+
+
+//==============================================================================
+// addLinePreProcExpression                                                    =
+//==============================================================================
+void ShaderProgramPrePreprocessor::addLinePreProcExpression(
+	uint line, uint depth, const char* cmnt)
+{
+	/*sourceLines.push_back("#line " +
+		boost::lexical_cast<std::string>(line) +
+		' ' +
+		boost::lexical_cast<std::string>(depth) +
+		" // " +
+		cmnt);*/
+}

+ 3 - 0
src/rsrc/ShaderProgramPrePreprocessor.h

@@ -137,6 +137,9 @@ class ShaderProgramPrePreprocessor
 			const std::string& what) const;
 
 		void printSourceLines() const;  ///< For debugging
+
+		/// Add a in the source lines a: #line <line> <depth> // cmnt
+		void addLinePreProcExpression(uint line, uint depth, const char* cmnt);
 };
 
 

+ 1 - 1
src/scene/Scene.h

@@ -51,7 +51,7 @@ class Scene
 
 		/// @name Accessors
 		/// @{
-		GETTER_SETTER(Vec3, ambientCol, getAmbientCol, setAmbientCol)
+		GETTER_SETTER(Vec3, ambientCol, getAmbientColor, setAmbientColor)
 		phys::MasterContainer& getPhysMasterContainer();
 		const phys::MasterContainer& getPhysMasterContainer() const;
 		const VisibilityTester& getVisibilityTester() const;

+ 3 - 3
src/script/Scene/Scene.bpi.cpp

@@ -10,9 +10,9 @@ WRAP(Scene)
 	WRAP_CONTAINER(Scene::Types<ModelNode>::Container)
 
 	class_<Scene, noncopyable>("Scene", no_init)
-		.def("setAmbientCol", &Scene::setAmbientCol)
-		.def("getAmbientCol", (const Vec3& (Scene::*)() const)(&
-			Scene::getAmbientCol),
+		.def("setAmbientColor", &Scene::setAmbientColor)
+		.def("getAmbientColor", (const Vec3& (Scene::*)() const)(&
+			Scene::getAmbientColor),
 			return_value_policy<reference_existing_object>())
 
 		.def("getCameras", (Scene::Types<Camera>::Container& (Scene::*)())(&