Fixed new 3D engine's fragment shader to work on some older GPUs by reducing the number of discard statements to one

This commit is contained in:
Bart Trzynadlowski 2016-08-24 22:21:18 +00:00
parent 4b184b05dc
commit 458684eb22

View file

@ -58,6 +58,8 @@ static const char *fragmentShaderBasic =
"vec4 colData;\n"
"vec4 finalData;\n"
"bool discardFragment = false;\n"
"tex1Data = vec4(1.0, 1.0, 1.0, 1.0);\n"
"if(textureEnabled==1) {\n"
@ -71,7 +73,7 @@ static const char *fragmentShaderBasic =
"if (alphaTest==1) {\n" // does it make any sense to do this later?
"if (tex1Data.a < (8.0/16.0)) {\n"
"discard;\n"
"discardFragment = true;\n"
"}\n"
"}\n"
@ -84,12 +86,14 @@ static const char *fragmentShaderBasic =
"finalData = tex1Data * colData;\n"
"if (finalData.a < (1.0/16.0)) {\n" // basically chuck out any totally transparent pixels value = 1/16 the smallest transparency level h/w supports
"discardFragment = true;\n"
"}\n"
"if (discardFragment) {\n"
"discard;\n"
"}\n"
"if (lightEnable==1)\n"
"{\n"
"if (lightEnable==1) {\n"
"vec3 lightIntensity;\n"
"vec3 sunVector;\n" // sun lighting vector (as reflecting away from vertex)
"float sunFactor;\n" // sun light projection along vertex normal (0.0 to 1.0)