WIP Kraken updated OSX support
This commit is contained in:
@@ -27,6 +27,8 @@
|
||||
|
||||
//#extension GL_EXT_shadow_samplers : require
|
||||
|
||||
out vec4 colorOut;
|
||||
|
||||
#if ENABLE_RIM_COLOR == 1
|
||||
uniform lowp vec3 rim_color;
|
||||
uniform mediump float rim_power;
|
||||
@@ -61,20 +63,20 @@
|
||||
#if HAS_NORMAL_MAP == 1
|
||||
uniform sampler2D normalTexture;
|
||||
#else
|
||||
varying mediump vec3 normal;
|
||||
in mediump vec3 normal;
|
||||
#endif
|
||||
|
||||
#if HAS_DIFFUSE_MAP == 1 || HAS_NORMAL_MAP == 1 || HAS_SPEC_MAP == 1 || HAS_REFLECTION_MAP == 1
|
||||
varying highp vec2 texCoord;
|
||||
in highp vec2 texCoord;
|
||||
#endif
|
||||
#if HAS_NORMAL_MAP_OFFSET == 1 || HAS_NORMAL_MAP_SCALE == 1
|
||||
varying highp vec2 normal_uv;
|
||||
in highp vec2 normal_uv;
|
||||
#else
|
||||
#define normal_uv texCoord
|
||||
#endif
|
||||
#else
|
||||
#if HAS_DIFFUSE_MAP == 1
|
||||
varying highp vec2 texCoord;
|
||||
in highp vec2 texCoord;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -86,7 +88,7 @@
|
||||
|
||||
#if GBUFFER_PASS == 1
|
||||
#if HAS_NORMAL_MAP == 1
|
||||
varying highp mat3 tangent_to_view_matrix;
|
||||
in highp mat3 tangent_to_view_matrix;
|
||||
#else
|
||||
uniform highp mat4 model_view_inverse_transpose_matrix;
|
||||
#endif
|
||||
@@ -94,7 +96,7 @@
|
||||
#if HAS_DIFFUSE_MAP == 1 && ALPHA_TEST == 1
|
||||
uniform sampler2D diffuseTexture;
|
||||
#if HAS_DIFFUSE_MAP_OFFSET == 1 || HAS_DIFFUSE_MAP_SCALE == 1
|
||||
varying highp vec2 diffuse_uv;
|
||||
in highp vec2 diffuse_uv;
|
||||
#else
|
||||
#define diffuse_uv texCoord
|
||||
#endif
|
||||
@@ -124,17 +126,17 @@
|
||||
uniform lowp vec3 material_reflection;
|
||||
uniform samplerCube reflectionCubeTexture;
|
||||
#if HAS_NORMAL_MAP == 1
|
||||
varying highp mat3 tangent_to_world_matrix;
|
||||
in highp mat3 tangent_to_world_matrix;
|
||||
#define NEED_EYEVEC
|
||||
|
||||
uniform highp mat4 model_matrix;
|
||||
#else
|
||||
varying mediump vec3 reflectionVec;
|
||||
in mediump vec3 reflectionVec;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef NEED_EYEVEC
|
||||
varying mediump vec3 eyeVec;
|
||||
in mediump vec3 eyeVec;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -144,46 +146,46 @@
|
||||
#else
|
||||
uniform sampler2D shadowTexture1;
|
||||
#endif
|
||||
varying highp vec4 shadowMapCoord1;
|
||||
in highp vec4 shadowMapCoord1;
|
||||
#endif
|
||||
|
||||
#if HAS_LIGHT_MAP == 1
|
||||
uniform sampler2D lightmapTexture;
|
||||
varying mediump vec2 lightmap_uv;
|
||||
in mediump vec2 lightmap_uv;
|
||||
#endif
|
||||
|
||||
#if SHADOW_QUALITY >= 2
|
||||
uniform sampler2D shadowTexture2;
|
||||
varying highp vec4 shadowMapCoord2;
|
||||
in highp vec4 shadowMapCoord2;
|
||||
#endif
|
||||
|
||||
#if SHADOW_QUALITY >= 3
|
||||
uniform sampler2D shadowTexture3;
|
||||
varying highp vec4 shadowMapCoord3;
|
||||
in highp vec4 shadowMapCoord3;
|
||||
#endif
|
||||
|
||||
#if ENABLE_PER_PIXEL == 1
|
||||
varying mediump vec3 lightVec;
|
||||
varying mediump vec3 halfVec;
|
||||
in mediump vec3 lightVec;
|
||||
in mediump vec3 halfVec;
|
||||
#else
|
||||
varying mediump float lamberFactor;
|
||||
varying mediump float specularFactor;
|
||||
in mediump float lamberFactor;
|
||||
in mediump float specularFactor;
|
||||
#endif
|
||||
|
||||
#if (HAS_SPEC_MAP_OFFSET == 1|| HAS_SPEC_MAP_SCALE == 1) && ENABLE_PER_PIXEL == 1
|
||||
varying mediump vec2 spec_uv;
|
||||
in mediump vec2 spec_uv;
|
||||
#else
|
||||
#define spec_uv texCoord
|
||||
#endif
|
||||
|
||||
#if (HAS_REFLECTION_MAP_OFFSET == 1|| HAS_REFLECTION_MAP_SCALE == 1) && ENABLE_PER_PIXEL == 1
|
||||
varying mediump vec2 reflection_uv;
|
||||
in mediump vec2 reflection_uv;
|
||||
#else
|
||||
#define reflection_uv texCoord
|
||||
#endif
|
||||
|
||||
#if HAS_DIFFUSE_MAP_OFFSET == 1 || HAS_DIFFUSE_MAP_SCALE == 1
|
||||
varying highp vec2 diffuse_uv;
|
||||
in highp vec2 diffuse_uv;
|
||||
#else
|
||||
#define diffuse_uv texCoord
|
||||
#endif
|
||||
@@ -197,12 +199,12 @@
|
||||
void main()
|
||||
{
|
||||
#if ALPHA_TEST == 1 && HAS_DIFFUSE_MAP == 1
|
||||
mediump vec4 diffuseMaterial = texture2D(diffuseTexture, diffuse_uv);
|
||||
mediump vec4 diffuseMaterial = texture(diffuseTexture, diffuse_uv);
|
||||
if(diffuseMaterial.a < 0.5) discard;
|
||||
#endif
|
||||
|
||||
#if GBUFFER_PASS == 1 && ALPHA_TEST == 1
|
||||
if(texture2D(diffuseTexture, diffuse_uv).a < 0.5) discard;
|
||||
if(texture(diffuseTexture, diffuse_uv).a < 0.5) discard;
|
||||
#endif
|
||||
|
||||
#if GBUFFER_PASS == 2 || GBUFFER_PASS == 3
|
||||
@@ -210,7 +212,7 @@ void main()
|
||||
#endif
|
||||
|
||||
#if GBUFFER_PASS == 3
|
||||
lowp vec4 gbuffer_sample = texture2D(gbuffer_frame, gbuffer_uv);
|
||||
lowp vec4 gbuffer_sample = texture(gbuffer_frame, gbuffer_uv);
|
||||
mediump vec3 gbuffer_lamber_factor = gbuffer_sample.rgb * 5.0;
|
||||
lowp float gbuffer_specular_factor = gbuffer_sample.a;
|
||||
#endif
|
||||
@@ -218,18 +220,18 @@ void main()
|
||||
#if GBUFFER_PASS == 1
|
||||
#if HAS_NORMAL_MAP == 1
|
||||
// lookup normal from normal map, move from [0,1] to [-1, 1] range, normalize
|
||||
mediump vec3 normal = normalize(2.0 * texture2D(normalTexture,normal_uv).rgb - 1.0);
|
||||
mediump vec3 normal = normalize(2.0 * texture(normalTexture,normal_uv).rgb - 1.0);
|
||||
mediump vec3 view_space_normal = tangent_to_view_matrix * normal;
|
||||
#else
|
||||
mediump vec3 view_space_normal = vec3(model_view_inverse_transpose_matrix * vec4(normal, 1.0));
|
||||
#endif
|
||||
gl_FragColor = vec4(view_space_normal * 0.5 + 0.5, material_shininess / 100.0);
|
||||
colorOut = vec4(view_space_normal * 0.5 + 0.5, material_shininess / 100.0);
|
||||
#else
|
||||
#if HAS_DIFFUSE_MAP == 1
|
||||
#if ALPHA_TEST == 1
|
||||
diffuseMaterial.a = 1.0;
|
||||
#else
|
||||
mediump vec4 diffuseMaterial = texture2D(diffuseTexture, diffuse_uv);
|
||||
mediump vec4 diffuseMaterial = texture(diffuseTexture, diffuse_uv);
|
||||
#endif
|
||||
|
||||
#else
|
||||
@@ -239,7 +241,7 @@ void main()
|
||||
#if ENABLE_PER_PIXEL == 1
|
||||
#if HAS_NORMAL_MAP == 1
|
||||
// lookup normal from normal map, move from [0,1] to [-1, 1] range, normalize
|
||||
mediump vec3 normal = normalize(2.0 * texture2D(normalTexture,normal_uv).rgb - 1.0);
|
||||
mediump vec3 normal = normalize(2.0 * texture(normalTexture,normal_uv).rgb - 1.0);
|
||||
#endif
|
||||
|
||||
#if GBUFFER_PASS == 3
|
||||
@@ -277,7 +279,7 @@ void main()
|
||||
#if DEBUG_PSSM == 1
|
||||
diffuseMaterial = diffuseMaterial * vec4(0.75, 0.75, 0.5, 1.0) + vec4(0.0, 0.0, 0.5, 0.0);
|
||||
#endif
|
||||
shadowMapDepth = texture2D(shadowTexture1, shadowMapPos).z;
|
||||
shadowMapDepth = texture(shadowTexture1, shadowMapPos).z;
|
||||
vertexShadowDepth = (shadowMapCoord1 / shadowMapCoord1.w).z;
|
||||
}
|
||||
#endif
|
||||
@@ -292,14 +294,14 @@ void main()
|
||||
diffuseMaterial = diffuseMaterial * vec4(0.75, 0.75, 0.5, 1.0) + vec4(0.0, 0.0, 0.5 * diffuseMaterial.a, 0.0);
|
||||
#endif
|
||||
highp vec2 shadowMapPos = (shadowMapCoord1 / shadowMapCoord1.w).st;
|
||||
shadowMapDepth = texture2D(shadowTexture1, shadowMapPos).z;
|
||||
shadowMapDepth = texture(shadowTexture1, shadowMapPos).z;
|
||||
vertexShadowDepth = (shadowMapCoord1 / shadowMapCoord1.w).z;
|
||||
} else if(shadowMapCoord2.s >= -1.0 && shadowMapCoord2.s <= 1.0 && shadowMapCoord2.t >= -1.0 && shadowMapCoord2.t <= 1.0 && shadowMapCoord2.z >= 0.0 && shadowMapCoord2.z <= 1.0) {
|
||||
#if DEBUG_PSSM == 1
|
||||
diffuseMaterial = diffuseMaterial * vec4(0.75, 0.50, 0.75, 1.0) + vec4(0.0, 0.5 * diffuseMaterial.a, 0.0, 0.0);
|
||||
#endif
|
||||
highp vec2 shadowMapPos = (shadowMapCoord2 / shadowMapCoord2.w).st;
|
||||
shadowMapDepth = texture2D(shadowTexture2, shadowMapPos).z;
|
||||
shadowMapDepth = texture(shadowTexture2, shadowMapPos).z;
|
||||
vertexShadowDepth = (shadowMapCoord2 / shadowMapCoord2.w).z;
|
||||
}
|
||||
#if SHADOW_QUALITY >= 3
|
||||
@@ -308,7 +310,7 @@ void main()
|
||||
diffuseMaterial = diffuseMaterial * vec4(0.50, 0.75, 0.75, 1.0) + vec4(0.5 * diffuseMaterial.a, 0.0, 0.0, 0.0);
|
||||
#endif
|
||||
highp vec2 shadowMapPos = (shadowMapCoord3 / shadowMapCoord3.w).st;
|
||||
shadowMapDepth = texture2D(shadowTexture3, shadowMapPos).z;
|
||||
shadowMapDepth = texture(shadowTexture3, shadowMapPos).z;
|
||||
vertexShadowDepth = (shadowMapCoord3 / shadowMapCoord3.w).z;
|
||||
}
|
||||
|
||||
@@ -330,38 +332,38 @@ void main()
|
||||
|
||||
#if ENABLE_AMBIENT == 1
|
||||
// -------------------- Add ambient light and alpha component --------------------
|
||||
gl_FragColor = vec4(vec3(diffuseMaterial) * material_ambient, 0.0);
|
||||
colorOut = vec4(vec3(diffuseMaterial) * material_ambient, 0.0);
|
||||
#else
|
||||
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
colorOut = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
#endif
|
||||
|
||||
#if ENABLE_DIFFUSE == 1
|
||||
// -------------------- Add diffuse light --------------------
|
||||
gl_FragColor += diffuseMaterial * vec4(material_diffuse * lamberFactor, 1.0);
|
||||
colorOut += diffuseMaterial * vec4(material_diffuse * lamberFactor, 1.0);
|
||||
#endif
|
||||
|
||||
// -------------------- Apply material_alpha --------------------
|
||||
|
||||
#if ALPHA_BLEND == 1
|
||||
gl_FragColor.a = diffuseMaterial.a;
|
||||
gl_FragColor *= material_alpha;
|
||||
colorOut.a = diffuseMaterial.a;
|
||||
colorOut *= material_alpha;
|
||||
#endif
|
||||
|
||||
// -------------------- Add specular light --------------------
|
||||
// Additive, not masked against diffuse alpha
|
||||
#if ENABLE_SPECULAR == 1
|
||||
#if HAS_SPEC_MAP == 1 && ENABLE_PER_PIXEL == 1
|
||||
gl_FragColor.rgb += material_specular * vec3(texture2D(specularTexture, spec_uv)) * specularFactor;
|
||||
colorOut.rgb += material_specular * vec3(texture(specularTexture, spec_uv)) * specularFactor;
|
||||
#else
|
||||
gl_FragColor.rgb += material_specular * specularFactor;
|
||||
colorOut.rgb += material_specular * specularFactor;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// -------------------- Multiply light map --------------------
|
||||
#if HAS_LIGHT_MAP == 1
|
||||
mediump vec3 lightMapColor = vec3(texture2D(lightmapTexture, lightmap_uv));
|
||||
//gl_FragColor = vec4(gl_FragColor.r * lightMapColor.r, gl_FragColor.g * lightMapColor.g, gl_FragColor.b * lightMapColor.b, gl_FragColor.a);
|
||||
gl_FragColor.rgb *= lightMapColor;
|
||||
mediump vec3 lightMapColor = vec3(texture(lightmapTexture, lightmap_uv));
|
||||
//colorOut = vec4(colorOut.r * lightMapColor.r, colorOut.g * lightMapColor.g, colorOut.b * lightMapColor.b, colorOut.a);
|
||||
colorOut.rgb *= lightMapColor;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -375,9 +377,9 @@ void main()
|
||||
mediump vec3 reflectionVec = mat3(model_matrix) * (incidenceVec - 2.0 * dot(world_space_normal, incidenceVec) * world_space_normal);
|
||||
#endif
|
||||
#if HAS_REFLECTION_MAP == 1
|
||||
gl_FragColor += vec4(material_reflection, 0.0) * texture2D(reflectionTexture, reflection_uv) * vec4(textureCube(reflectionCubeTexture, reflectionVec).rgb, 1.0);
|
||||
colorOut += vec4(material_reflection, 0.0) * texture(reflectionTexture, reflection_uv) * vec4(texture(reflectionCubeTexture, reflectionVec).rgb, 1.0);
|
||||
#else
|
||||
gl_FragColor += vec4(material_reflection, 0.0) * vec4(textureCube(reflectionCubeTexture, reflectionVec).rgb, 1.0);
|
||||
colorOut += vec4(material_reflection, 0.0) * vec4(texture(reflectionCubeTexture, reflectionVec).rgb, 1.0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -402,9 +404,9 @@ void main()
|
||||
#endif
|
||||
|
||||
#if ALPHA_BLEND == 1
|
||||
gl_FragColor.rgb = mix(fog_color.rgb * gl_FragColor.a, gl_FragColor.rgb, fog_alpha);
|
||||
colorOut.rgb = mix(fog_color.rgb * colorOut.a, colorOut.rgb, fog_alpha);
|
||||
#else
|
||||
gl_FragColor.rgb = mix(fog_color.rgb, gl_FragColor.rgb, fog_alpha);
|
||||
colorOut.rgb = mix(fog_color.rgb, colorOut.rgb, fog_alpha);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -414,10 +416,10 @@ void main()
|
||||
#if ENABLE_RIM_COLOR == 1
|
||||
lowp float rim = 1.0 - clamp(dot(normalize(eyeVec), normal), 0.0, 1.0);
|
||||
|
||||
gl_FragColor += vec4(rim_color, 1.0) * pow(rim, rim_power);
|
||||
colorOut += vec4(rim_color, 1.0) * pow(rim, rim_power);
|
||||
#endif
|
||||
|
||||
#if BONE_COUNT > 0
|
||||
gl_FragColor.b = 1.0;
|
||||
colorOut.b = 1.0;
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user