瀏覽代碼

Changing the renderer: MS

Panagiotis Christopoulos Charitos 13 年之前
父節點
當前提交
3ab171c5df

+ 1 - 11
shaders/MaterialFragmentFunctions.glsl

@@ -2,10 +2,8 @@
 /// The file contains common functions for fragment operations
 #pragma anki include "shaders/Pack.glsl"
 
-
 #define MAX_SHININESS 128.0
 
-
 //==============================================================================
 /// @param[in] normal The fragment's normal in view space
 /// @param[in] tangent The tangent
@@ -33,7 +31,6 @@ vec3 getNormalFromTexture(in vec3 normal, in vec3 tangent, in float tangentW,
 }
 #endif
 
-
 //==============================================================================
 /// Just normalize
 #if defined(PASS_COLOR)
@@ -44,7 +41,6 @@ vec3 getNormalSimple(in vec3 normal)
 }
 #endif
 
-
 //==============================================================================
 /// Environment mapping calculations
 /// @param[in] vertPosViewSpace Fragment position in view space
@@ -70,7 +66,6 @@ vec3 getEnvironmentColor(in vec3 vertPosViewSpace, in vec3 normal,
 }
 #endif
 
-
 //==============================================================================
 /// Using a 4-channel texture and a tolerance discard the fragment if the 
 /// texture's alpha is less than the tolerance
@@ -105,7 +100,6 @@ vec3 getDiffuseColorAndDoAlphaTesting(
 #endif
 }
 
-
 //==============================================================================
 /// Just read the RGB color from texture
 #if defined(PASS_COLOR)
@@ -116,7 +110,6 @@ vec3 readRgbFromTexture(in sampler2D tex, in vec2 texCoords)
 }
 #endif
 
-
 //==============================================================================
 #define add2Vec3_DEFINED
 vec3 add2Vec3(in vec3 a, in vec3 b)
@@ -124,7 +117,6 @@ vec3 add2Vec3(in vec3 a, in vec3 b)
 	return a + b;
 }
 
-
 //==============================================================================
 /// Write the data to FAIs
 #if defined(PASS_COLOR)
@@ -136,8 +128,6 @@ void writeFais(
 	in float shininess, 
 	in float blurring)
 {
-	fMsNormalFai = vec3(packNormal(normal), blurring);
-	fMsDiffuseFai = diffCol;
-	fMsSpecularFai = vec4(specularCol, shininess / MAX_SHININESS);
+	fMsFai0 = uvec3(packUnorm4x8(vec4(diffCol, 1.0)), 0, 0);
 }
 #endif

+ 2 - 6
shaders/MaterialFragmentVariables.glsl

@@ -26,11 +26,7 @@ in vec3 vVertPosViewSpace;
 /// @name Fragment out
 /// @{
 #if defined(PASS_COLOR)
-layout(location = 0) out vec3 fMsNormalFai;
-#	define fMsNormalFai_DEFINED
-layout(location = 1) out vec3 fMsDiffuseFai;
-#	define fMsDiffuseFai_DEFINED
-layout(location = 2) out vec4 fMsSpecularFai;
-#	define fMsSpecularFai_DEFINED
+layout(location = 0) out uvec3 fMsFai0;
+#	define fMsFai0_DEFINED
 #endif
 /// @}

+ 5 - 3
src/gl/ShaderProgram.cpp

@@ -153,10 +153,12 @@ const char* ShaderProgram::stdSourceCode =
 	//"precision lowp float;\n"
 #if defined(NDEBUG)
 	"#pragma optimize(on)\n"
-	"#pragma debug(off)\n";
+	"#pragma debug(off)\n"
+	"#extension GL_ARB_gpu_shader5 : enable\n";
 #else
 	"#pragma optimize(off)\n"
-	"#pragma debug(on)\n";
+	"#pragma debug(on)\n"
+	"#extension GL_ARB_gpu_shader5 : enable\n";
 #endif
 
 thread_local const ShaderProgram* ShaderProgram::current = nullptr;
@@ -325,7 +327,7 @@ GLuint ShaderProgram::createAndCompileShader(const char* sourceCode,
 			<< "\n" << padding << "\nSource:\n" << padding << "\n";
 
 		// Prettyfy source
-		StringList lines = StringList::splitString(sourceCode, '\n', true);
+		StringList lines = StringList::splitString(fullSrc.c_str(), '\n', true);
 		int lineno = 0;
 		for(const std::string& line : lines)
 		{

+ 2 - 1
src/gl/Texture.cpp

@@ -194,12 +194,13 @@ void Texture::create(const Initializer& init)
 		glCompressedTexImage2D(target, 0, internalFormat,
 			width, height, 0, init.dataSize, init.data);
 		break;
-
 	default:
 		glTexImage2D(target, 0, internalFormat, width,
 			height, 0, format, type, init.data);
 	}
 
+	ANKI_CHECK_GL_ERROR();
+
 	if(init.repeat)
 	{
 		glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_REPEAT);

+ 1 - 1
src/renderer/Bl.cpp

@@ -106,7 +106,7 @@ void Bl::runBlur()
 	hBlurSProg->findUniformVariableByName("img")->set(
 		r->getPps().getPostPassFai());
 	hBlurSProg->findUniformVariableByName("msNormalFai")->set(
-		r->getMs().getNormalFai());
+		r->getMs().getFai0());
 	hBlurSProg->findUniformVariableByName("imgDimension")->set(
 		float(r->getWidth()));
 

+ 2 - 2
src/renderer/Ms.cpp

@@ -17,8 +17,8 @@ void Ms::init(const RendererInitializer& initializer)
 {
 	try
 	{
-		Renderer::createFai(r->getWidth(), r->getHeight(), GL_RGB32UI,
-			GL_RGB, GL_INT, fai0);
+		Renderer::createFai(r->getWidth(), r->getHeight(), GL_RGBA32UI,
+			GL_RGBA_INTEGER, GL_UNSIGNED_INT, fai0);
 		Renderer::createFai(r->getWidth(), r->getHeight(),
 			GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL,
 			GL_UNSIGNED_INT_24_8, depthFai);

+ 1 - 1
src/resource/Image.cpp

@@ -660,7 +660,7 @@ void Image::loadDds(const char* filename)
 			/ li->divSize * std::max(li->divSize, hdr.data.dwHeight)
 			/ li->divSize * li->blockBytes;
 
-		if(size != hdr.dwPitchOrLinearSize)
+		if(size != hdr.data.dwPitchOrLinearSize)
 		{
 			throw ANKI_EXCEPTION("Size in header and the calculated are "
 				"not the same");

+ 1 - 1
src/util/Exception.cpp

@@ -3,7 +3,7 @@
 #include <iostream>
 
 // Instead of throwing abort. Its easier to debug
-#define ANKI_ABORT_ON_THROW 1
+//#define ANKI_ABORT_ON_THROW 1
 
 namespace anki {