Browse Source

More fixes

Panagiotis Christopoulos Charitos 8 years ago
parent
commit
c689631cb2
4 changed files with 10 additions and 47 deletions
  1. 4 4
      programs/MsGeneric.ankiprog
  2. 0 38
      sandbox/Main.cpp
  3. 3 2
      shaders/FsCommonFrag.glsl
  4. 3 3
      tools/scene/ExporterMaterial.cpp

+ 4 - 4
programs/MsGeneric.ankiprog

@@ -161,8 +161,8 @@ void main()
 		float roughness = texture(roughnessTex, uv).r;
 	#endif
 
-	#if metallicTex_DEFINED
-		float metallic = texture(metallicTex, uv).r;
+	#if metalTex_DEFINED
+		float metallic = texture(metalTex, uv).r;
 	#endif
 
 	#if normalTex_DEFINED
@@ -171,8 +171,8 @@ void main()
 		vec3 normal = normalize(in_normal);
 	#endif
 
-	#if emissionTex_DEFINED
-		vec3 emission = texture(emissionTex, uv).rgb;
+	#if emissiveTex_DEFINED
+		vec3 emission = texture(emissiveTex, uv).rgb;
 	#endif
 
 	writeRts(diffColor, normal, specColor, roughness, subsurface, emission, metallic);

+ 0 - 38
sandbox/Main.cpp

@@ -59,44 +59,6 @@ Error MyApp::init(int argc, char* argv[])
 	getInput().moveCursor(Vec2(0.0));
 #endif
 
-	{
-		ShaderProgramResourcePtr prog;
-		ANKI_CHECK(getResourceManager().loadResource("programs/MsGeneric.ankiprog", prog));
-
-		Array<ShaderProgramResourceMutation, 10> mm;
-		mm[0].m_mutator = prog->tryFindMutator("INSTANCE_COUNT");
-		mm[0].m_value = 4;
-		mm[1].m_mutator = prog->tryFindMutator("LOD");
-		mm[1].m_value = 1;
-		mm[2].m_mutator = prog->tryFindMutator("PASS");
-		mm[2].m_value = 0;
-		mm[3].m_mutator = prog->tryFindMutator("DIFFUSE_TEX");
-		mm[3].m_value = 1;
-		mm[4].m_mutator = prog->tryFindMutator("SPECULAR_TEX");
-		mm[4].m_value = 0;
-		mm[5].m_mutator = prog->tryFindMutator("ROUGHNESS_TEX");
-		mm[5].m_value = 1;
-		mm[6].m_mutator = prog->tryFindMutator("METAL_TEX");
-		mm[6].m_value = 1;
-		mm[7].m_mutator = prog->tryFindMutator("NORMAL_TEX");
-		mm[7].m_value = 1;
-		mm[8].m_mutator = prog->tryFindMutator("PARALLAX");
-		mm[8].m_value = 0;
-		mm[9].m_mutator = prog->tryFindMutator("EMISSIVE_TEX");
-		mm[9].m_value = 1;
-
-		Array<ShaderProgramResourceConstantValue, 2> consts;
-		consts[0].m_variable = prog->tryFindInputVariable("specColor");
-		consts[0].m_vec3 = Vec3(1.0);
-		consts[1].m_variable = prog->tryFindInputVariable("subsurface");
-		consts[1].m_vec3 = Vec3(1.0);
-
-		const ShaderProgramResourceVariant* v;
-		prog->getOrCreateVariant(mm, consts, v);
-
-		return ErrorCode::USER_DATA;
-	}
-
 	// Load scene
 	ScriptResourcePtr script;
 	ANKI_CHECK(resources.loadResource(argv[2], script));

+ 3 - 2
shaders/FsCommonFrag.glsl

@@ -23,6 +23,7 @@ layout(ANKI_TEX_BINDING(1, 0)) uniform sampler2D anki_msDepthRt;
 #define anki_u_time u_time
 #define RENDERER_SIZE (u_lightingUniforms.rendererSizeTimePad1.xy * 0.5)
 
+// Varyings
 layout(location = 0) flat in float in_alpha;
 layout(location = 1) in vec2 in_uv;
 layout(location = 2) in vec3 in_posViewSpace;
@@ -121,12 +122,12 @@ void particleAlpha(vec4 color, vec4 scaleColor, vec4 biasColor)
 	writeGBuffer(color * scaleColor + biasColor);
 }
 
-void fog(in sampler2D depthMap, in vec3 color, in float fogScale)
+void fog(vec3 color, float fogScale)
 {
 	const vec2 screenSize = 1.0 / RENDERER_SIZE;
 
 	vec2 texCoords = gl_FragCoord.xy * screenSize;
-	float depth = texture(depthMap, texCoords).r;
+	float depth = texture(anki_msDepthRt, texCoords).r;
 	float diff;
 
 	if(depth < 1.0)

+ 3 - 3
tools/scene/ExporterMaterial.cpp

@@ -145,8 +145,8 @@ void Exporter::exportMaterial(const aiMaterial& mtl) const
 		if(mtl.GetTexture(aiTextureType_REFLECTION, 0, &path) == AI_SUCCESS)
 		{
 			std::string metallicTex = m_texrpath + getFilename(path.C_Str());
-			xml = replaceAllString(
-				xml, "%metallic%", "<input shaderInput=\"metallicTex\" value=\"" + metallicTex + "\"/>");
+			xml =
+				replaceAllString(xml, "%metallic%", "<input shaderInput=\"metalTex\" value=\"" + metallicTex + "\"/>");
 
 			xml = replaceAllString(xml, "%metalTexMutator%", "1");
 		}
@@ -197,7 +197,7 @@ void Exporter::exportMaterial(const aiMaterial& mtl) const
 		{
 			std::string emissiveTex = m_texrpath + getFilename(path.C_Str());
 			xml = replaceAllString(
-				xml, "%emission%", "<input shaderInput=\"emissionTex\" value=\"" + emissiveTex + "\"/>");
+				xml, "%emission%", "<input shaderInput=\"emissiveTex\" value=\"" + emissiveTex + "\"/>");
 
 			xml = replaceAllString(xml, "%emissiveTexMutator%", "1");
 		}