diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..65c5ca88 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/Sources/Shaders/blender.frag.glsl b/Sources/Shaders/blender.frag.glsl index 33a542e8..d86a0a44 100644 --- a/Sources/Shaders/blender.frag.glsl +++ b/Sources/Shaders/blender.frag.glsl @@ -39,6 +39,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -115,7 +116,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -127,13 +128,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(vec3(t * visibility), 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/Sources/Shaders/blender.vert.glsl b/Sources/Shaders/blender.vert.glsl index 53d63938..ea243def 100644 --- a/Sources/Shaders/blender.vert.glsl +++ b/Sources/Shaders/blender.vert.glsl @@ -72,10 +72,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/Sources/Shaders/blender_AlphaTest.frag.glsl b/Sources/Shaders/blender_AlphaTest.frag.glsl new file mode 100644 index 00000000..e66e5d71 --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest.frag.glsl @@ -0,0 +1,153 @@ +#define _AlphaTest +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/Sources/Shaders/blender_AlphaTest.vert.glsl b/Sources/Shaders/blender_AlphaTest.vert.glsl new file mode 100644 index 00000000..49bb32f5 --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest.vert.glsl @@ -0,0 +1,87 @@ +#define _AlphaTest +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/Sources/Shaders/blender_AlphaTest_Instancing.frag.glsl b/Sources/Shaders/blender_AlphaTest_Instancing.frag.glsl new file mode 100644 index 00000000..9023c5fe --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_Instancing.frag.glsl @@ -0,0 +1,154 @@ +#define _AlphaTest +#define _Instancing +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/Sources/Shaders/blender_AlphaTest_Instancing.vert.glsl b/Sources/Shaders/blender_AlphaTest_Instancing.vert.glsl new file mode 100644 index 00000000..9551be7d --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_Instancing.vert.glsl @@ -0,0 +1,88 @@ +#define _AlphaTest +#define _Instancing +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping.frag.glsl b/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping.frag.glsl new file mode 100644 index 00000000..81ae0dbc --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping.frag.glsl @@ -0,0 +1,155 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping.vert.glsl b/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping.vert.glsl new file mode 100644 index 00000000..506d7abe --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping.vert.glsl @@ -0,0 +1,89 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping_Texturing.frag.glsl b/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping_Texturing.frag.glsl new file mode 100644 index 00000000..82f9f8a8 --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping_Texturing.frag.glsl @@ -0,0 +1,156 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping_Texturing.vert.glsl b/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping_Texturing.vert.glsl new file mode 100644 index 00000000..09f5caea --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping_Texturing.vert.glsl @@ -0,0 +1,90 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping_Texturing_VCols.frag.glsl b/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping_Texturing_VCols.frag.glsl new file mode 100644 index 00000000..493b939d --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping_Texturing_VCols.frag.glsl @@ -0,0 +1,157 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping_Texturing_VCols.vert.glsl b/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping_Texturing_VCols.vert.glsl new file mode 100644 index 00000000..dfaaef1b --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping_Texturing_VCols.vert.glsl @@ -0,0 +1,91 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping_VCols.frag.glsl b/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping_VCols.frag.glsl new file mode 100644 index 00000000..8e669461 --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping_VCols.frag.glsl @@ -0,0 +1,156 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping_VCols.vert.glsl b/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping_VCols.vert.glsl new file mode 100644 index 00000000..d3d7c2e1 --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_Instancing_NormalMapping_VCols.vert.glsl @@ -0,0 +1,90 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/Sources/Shaders/blender_AlphaTest_Instancing_Texturing.frag.glsl b/Sources/Shaders/blender_AlphaTest_Instancing_Texturing.frag.glsl new file mode 100644 index 00000000..e28da941 --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_Instancing_Texturing.frag.glsl @@ -0,0 +1,155 @@ +#define _AlphaTest +#define _Instancing +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/Sources/Shaders/blender_AlphaTest_Instancing_Texturing.vert.glsl b/Sources/Shaders/blender_AlphaTest_Instancing_Texturing.vert.glsl new file mode 100644 index 00000000..f54899a4 --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_Instancing_Texturing.vert.glsl @@ -0,0 +1,89 @@ +#define _AlphaTest +#define _Instancing +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/Sources/Shaders/blender_AlphaTest_Instancing_Texturing_VCols.frag.glsl b/Sources/Shaders/blender_AlphaTest_Instancing_Texturing_VCols.frag.glsl new file mode 100644 index 00000000..70cc301e --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_Instancing_Texturing_VCols.frag.glsl @@ -0,0 +1,156 @@ +#define _AlphaTest +#define _Instancing +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/Sources/Shaders/blender_AlphaTest_Instancing_Texturing_VCols.vert.glsl b/Sources/Shaders/blender_AlphaTest_Instancing_Texturing_VCols.vert.glsl new file mode 100644 index 00000000..e02df96e --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_Instancing_Texturing_VCols.vert.glsl @@ -0,0 +1,90 @@ +#define _AlphaTest +#define _Instancing +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/Sources/Shaders/blender_AlphaTest_Instancing_VCols.frag.glsl b/Sources/Shaders/blender_AlphaTest_Instancing_VCols.frag.glsl new file mode 100644 index 00000000..359c1167 --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_Instancing_VCols.frag.glsl @@ -0,0 +1,155 @@ +#define _AlphaTest +#define _Instancing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/Sources/Shaders/blender_AlphaTest_Instancing_VCols.vert.glsl b/Sources/Shaders/blender_AlphaTest_Instancing_VCols.vert.glsl new file mode 100644 index 00000000..de497ffa --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_Instancing_VCols.vert.glsl @@ -0,0 +1,89 @@ +#define _AlphaTest +#define _Instancing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/Sources/Shaders/blender_AlphaTest_NormalMapping.frag.glsl b/Sources/Shaders/blender_AlphaTest_NormalMapping.frag.glsl new file mode 100644 index 00000000..aea1448f --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_NormalMapping.frag.glsl @@ -0,0 +1,154 @@ +#define _AlphaTest +#define _NormalMapping +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/Sources/Shaders/blender_AlphaTest_NormalMapping.vert.glsl b/Sources/Shaders/blender_AlphaTest_NormalMapping.vert.glsl new file mode 100644 index 00000000..0ee660fe --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_NormalMapping.vert.glsl @@ -0,0 +1,88 @@ +#define _AlphaTest +#define _NormalMapping +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/Sources/Shaders/blender_AlphaTest_NormalMapping_Texturing.frag.glsl b/Sources/Shaders/blender_AlphaTest_NormalMapping_Texturing.frag.glsl new file mode 100644 index 00000000..832d25fd --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_NormalMapping_Texturing.frag.glsl @@ -0,0 +1,155 @@ +#define _AlphaTest +#define _NormalMapping +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/Sources/Shaders/blender_AlphaTest_NormalMapping_Texturing.vert.glsl b/Sources/Shaders/blender_AlphaTest_NormalMapping_Texturing.vert.glsl new file mode 100644 index 00000000..64d3c129 --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_NormalMapping_Texturing.vert.glsl @@ -0,0 +1,89 @@ +#define _AlphaTest +#define _NormalMapping +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/Sources/Shaders/blender_AlphaTest_NormalMapping_Texturing_VCols.frag.glsl b/Sources/Shaders/blender_AlphaTest_NormalMapping_Texturing_VCols.frag.glsl new file mode 100644 index 00000000..47470140 --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_NormalMapping_Texturing_VCols.frag.glsl @@ -0,0 +1,156 @@ +#define _AlphaTest +#define _NormalMapping +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/Sources/Shaders/blender_AlphaTest_NormalMapping_Texturing_VCols.vert.glsl b/Sources/Shaders/blender_AlphaTest_NormalMapping_Texturing_VCols.vert.glsl new file mode 100644 index 00000000..a786b07c --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_NormalMapping_Texturing_VCols.vert.glsl @@ -0,0 +1,90 @@ +#define _AlphaTest +#define _NormalMapping +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/Sources/Shaders/blender_AlphaTest_NormalMapping_VCols.frag.glsl b/Sources/Shaders/blender_AlphaTest_NormalMapping_VCols.frag.glsl new file mode 100644 index 00000000..ea3bcb18 --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_NormalMapping_VCols.frag.glsl @@ -0,0 +1,155 @@ +#define _AlphaTest +#define _NormalMapping +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/Sources/Shaders/blender_AlphaTest_NormalMapping_VCols.vert.glsl b/Sources/Shaders/blender_AlphaTest_NormalMapping_VCols.vert.glsl new file mode 100644 index 00000000..5bbcf8a6 --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_NormalMapping_VCols.vert.glsl @@ -0,0 +1,89 @@ +#define _AlphaTest +#define _NormalMapping +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/Sources/Shaders/blender_AlphaTest_Texturing.frag.glsl b/Sources/Shaders/blender_AlphaTest_Texturing.frag.glsl new file mode 100644 index 00000000..c5cc685d --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_Texturing.frag.glsl @@ -0,0 +1,154 @@ +#define _AlphaTest +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/Sources/Shaders/blender_AlphaTest_Texturing.vert.glsl b/Sources/Shaders/blender_AlphaTest_Texturing.vert.glsl new file mode 100644 index 00000000..5f9b067f --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_Texturing.vert.glsl @@ -0,0 +1,88 @@ +#define _AlphaTest +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/Sources/Shaders/blender_AlphaTest_Texturing_VCols.frag.glsl b/Sources/Shaders/blender_AlphaTest_Texturing_VCols.frag.glsl new file mode 100644 index 00000000..1944c152 --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_Texturing_VCols.frag.glsl @@ -0,0 +1,155 @@ +#define _AlphaTest +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/Sources/Shaders/blender_AlphaTest_Texturing_VCols.vert.glsl b/Sources/Shaders/blender_AlphaTest_Texturing_VCols.vert.glsl new file mode 100644 index 00000000..963b1729 --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_Texturing_VCols.vert.glsl @@ -0,0 +1,89 @@ +#define _AlphaTest +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/Sources/Shaders/blender_AlphaTest_VCols.frag.glsl b/Sources/Shaders/blender_AlphaTest_VCols.frag.glsl new file mode 100644 index 00000000..24219a2c --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_VCols.frag.glsl @@ -0,0 +1,154 @@ +#define _AlphaTest +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/Sources/Shaders/blender_AlphaTest_VCols.vert.glsl b/Sources/Shaders/blender_AlphaTest_VCols.vert.glsl new file mode 100644 index 00000000..8d7c0c12 --- /dev/null +++ b/Sources/Shaders/blender_AlphaTest_VCols.vert.glsl @@ -0,0 +1,88 @@ +#define _AlphaTest +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/Sources/Shaders/blender_Instancing.frag.glsl b/Sources/Shaders/blender_Instancing.frag.glsl index 5e1913ef..17c00bf7 100644 --- a/Sources/Shaders/blender_Instancing.frag.glsl +++ b/Sources/Shaders/blender_Instancing.frag.glsl @@ -40,6 +40,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -116,7 +117,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -128,13 +129,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/Sources/Shaders/blender_Instancing.vert.glsl b/Sources/Shaders/blender_Instancing.vert.glsl index d7e85d5d..a59be006 100644 --- a/Sources/Shaders/blender_Instancing.vert.glsl +++ b/Sources/Shaders/blender_Instancing.vert.glsl @@ -73,10 +73,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/Sources/Shaders/blender_Instancing_NormalMapping.frag.glsl b/Sources/Shaders/blender_Instancing_NormalMapping.frag.glsl index fda9e796..f98108e1 100644 --- a/Sources/Shaders/blender_Instancing_NormalMapping.frag.glsl +++ b/Sources/Shaders/blender_Instancing_NormalMapping.frag.glsl @@ -41,6 +41,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -117,7 +118,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -129,13 +130,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/Sources/Shaders/blender_Instancing_NormalMapping.vert.glsl b/Sources/Shaders/blender_Instancing_NormalMapping.vert.glsl index 138b05ca..47b08b64 100644 --- a/Sources/Shaders/blender_Instancing_NormalMapping.vert.glsl +++ b/Sources/Shaders/blender_Instancing_NormalMapping.vert.glsl @@ -74,10 +74,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/Sources/Shaders/blender_Instancing_NormalMapping_Texturing.frag.glsl b/Sources/Shaders/blender_Instancing_NormalMapping_Texturing.frag.glsl index 4b0c92d2..56154d31 100644 --- a/Sources/Shaders/blender_Instancing_NormalMapping_Texturing.frag.glsl +++ b/Sources/Shaders/blender_Instancing_NormalMapping_Texturing.frag.glsl @@ -42,6 +42,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -118,7 +119,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -130,13 +131,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/Sources/Shaders/blender_Instancing_NormalMapping_Texturing.vert.glsl b/Sources/Shaders/blender_Instancing_NormalMapping_Texturing.vert.glsl index 3ab9c30d..c6130ec5 100644 --- a/Sources/Shaders/blender_Instancing_NormalMapping_Texturing.vert.glsl +++ b/Sources/Shaders/blender_Instancing_NormalMapping_Texturing.vert.glsl @@ -75,10 +75,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/Sources/Shaders/blender_Instancing_NormalMapping_Texturing_VCols.frag.glsl b/Sources/Shaders/blender_Instancing_NormalMapping_Texturing_VCols.frag.glsl index 26f89b24..2c9da22d 100644 --- a/Sources/Shaders/blender_Instancing_NormalMapping_Texturing_VCols.frag.glsl +++ b/Sources/Shaders/blender_Instancing_NormalMapping_Texturing_VCols.frag.glsl @@ -43,6 +43,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -119,7 +120,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -131,13 +132,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/Sources/Shaders/blender_Instancing_NormalMapping_Texturing_VCols.vert.glsl b/Sources/Shaders/blender_Instancing_NormalMapping_Texturing_VCols.vert.glsl index 3270aa60..763d8812 100644 --- a/Sources/Shaders/blender_Instancing_NormalMapping_Texturing_VCols.vert.glsl +++ b/Sources/Shaders/blender_Instancing_NormalMapping_Texturing_VCols.vert.glsl @@ -76,10 +76,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/Sources/Shaders/blender_Instancing_NormalMapping_VCols.frag.glsl b/Sources/Shaders/blender_Instancing_NormalMapping_VCols.frag.glsl index 8743b3f4..7354cca9 100644 --- a/Sources/Shaders/blender_Instancing_NormalMapping_VCols.frag.glsl +++ b/Sources/Shaders/blender_Instancing_NormalMapping_VCols.frag.glsl @@ -42,6 +42,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -118,7 +119,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -130,13 +131,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/Sources/Shaders/blender_Instancing_NormalMapping_VCols.vert.glsl b/Sources/Shaders/blender_Instancing_NormalMapping_VCols.vert.glsl index 81db2be2..6299f12b 100644 --- a/Sources/Shaders/blender_Instancing_NormalMapping_VCols.vert.glsl +++ b/Sources/Shaders/blender_Instancing_NormalMapping_VCols.vert.glsl @@ -75,10 +75,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/Sources/Shaders/blender_Instancing_Texturing.frag.glsl b/Sources/Shaders/blender_Instancing_Texturing.frag.glsl index e579f8ac..78b5725b 100644 --- a/Sources/Shaders/blender_Instancing_Texturing.frag.glsl +++ b/Sources/Shaders/blender_Instancing_Texturing.frag.glsl @@ -41,6 +41,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -117,7 +118,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -129,13 +130,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/Sources/Shaders/blender_Instancing_Texturing.vert.glsl b/Sources/Shaders/blender_Instancing_Texturing.vert.glsl index 40b1a190..6dd479f5 100644 --- a/Sources/Shaders/blender_Instancing_Texturing.vert.glsl +++ b/Sources/Shaders/blender_Instancing_Texturing.vert.glsl @@ -74,10 +74,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/Sources/Shaders/blender_Instancing_Texturing_VCols.frag.glsl b/Sources/Shaders/blender_Instancing_Texturing_VCols.frag.glsl index 2be1aaed..d6d75a0e 100644 --- a/Sources/Shaders/blender_Instancing_Texturing_VCols.frag.glsl +++ b/Sources/Shaders/blender_Instancing_Texturing_VCols.frag.glsl @@ -42,6 +42,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -118,7 +119,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -130,13 +131,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/Sources/Shaders/blender_Instancing_Texturing_VCols.vert.glsl b/Sources/Shaders/blender_Instancing_Texturing_VCols.vert.glsl index 1d5f791c..8f24a1a8 100644 --- a/Sources/Shaders/blender_Instancing_Texturing_VCols.vert.glsl +++ b/Sources/Shaders/blender_Instancing_Texturing_VCols.vert.glsl @@ -75,10 +75,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/Sources/Shaders/blender_Instancing_VCols.frag.glsl b/Sources/Shaders/blender_Instancing_VCols.frag.glsl index a9ce97ad..0acaeb62 100644 --- a/Sources/Shaders/blender_Instancing_VCols.frag.glsl +++ b/Sources/Shaders/blender_Instancing_VCols.frag.glsl @@ -41,6 +41,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -117,7 +118,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -129,13 +130,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/Sources/Shaders/blender_Instancing_VCols.vert.glsl b/Sources/Shaders/blender_Instancing_VCols.vert.glsl index 1c5c6abf..49ed8f2e 100644 --- a/Sources/Shaders/blender_Instancing_VCols.vert.glsl +++ b/Sources/Shaders/blender_Instancing_VCols.vert.glsl @@ -74,10 +74,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/Sources/Shaders/blender_NormalMapping.frag.glsl b/Sources/Shaders/blender_NormalMapping.frag.glsl index 668ee223..59b61575 100644 --- a/Sources/Shaders/blender_NormalMapping.frag.glsl +++ b/Sources/Shaders/blender_NormalMapping.frag.glsl @@ -40,6 +40,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -116,7 +117,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -128,13 +129,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/Sources/Shaders/blender_NormalMapping.vert.glsl b/Sources/Shaders/blender_NormalMapping.vert.glsl index 78c24c16..26ca27f9 100644 --- a/Sources/Shaders/blender_NormalMapping.vert.glsl +++ b/Sources/Shaders/blender_NormalMapping.vert.glsl @@ -73,10 +73,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/Sources/Shaders/blender_NormalMapping_Texturing.frag.glsl b/Sources/Shaders/blender_NormalMapping_Texturing.frag.glsl index 1a719e77..a4400833 100644 --- a/Sources/Shaders/blender_NormalMapping_Texturing.frag.glsl +++ b/Sources/Shaders/blender_NormalMapping_Texturing.frag.glsl @@ -41,6 +41,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -117,7 +118,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -129,13 +130,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/Sources/Shaders/blender_NormalMapping_Texturing.vert.glsl b/Sources/Shaders/blender_NormalMapping_Texturing.vert.glsl index 3f983bbe..706e31a8 100644 --- a/Sources/Shaders/blender_NormalMapping_Texturing.vert.glsl +++ b/Sources/Shaders/blender_NormalMapping_Texturing.vert.glsl @@ -74,10 +74,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/Sources/Shaders/blender_NormalMapping_Texturing_VCols.frag.glsl b/Sources/Shaders/blender_NormalMapping_Texturing_VCols.frag.glsl index b3c2e961..cebf78f5 100644 --- a/Sources/Shaders/blender_NormalMapping_Texturing_VCols.frag.glsl +++ b/Sources/Shaders/blender_NormalMapping_Texturing_VCols.frag.glsl @@ -42,6 +42,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -118,7 +119,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -130,13 +131,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/Sources/Shaders/blender_NormalMapping_Texturing_VCols.vert.glsl b/Sources/Shaders/blender_NormalMapping_Texturing_VCols.vert.glsl index 34a3785e..3149c83b 100644 --- a/Sources/Shaders/blender_NormalMapping_Texturing_VCols.vert.glsl +++ b/Sources/Shaders/blender_NormalMapping_Texturing_VCols.vert.glsl @@ -75,10 +75,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/Sources/Shaders/blender_NormalMapping_VCols.frag.glsl b/Sources/Shaders/blender_NormalMapping_VCols.frag.glsl index 34926c42..d4475d03 100644 --- a/Sources/Shaders/blender_NormalMapping_VCols.frag.glsl +++ b/Sources/Shaders/blender_NormalMapping_VCols.frag.glsl @@ -41,6 +41,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -117,7 +118,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -129,13 +130,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/Sources/Shaders/blender_NormalMapping_VCols.vert.glsl b/Sources/Shaders/blender_NormalMapping_VCols.vert.glsl index fd0c0201..f7aa689a 100644 --- a/Sources/Shaders/blender_NormalMapping_VCols.vert.glsl +++ b/Sources/Shaders/blender_NormalMapping_VCols.vert.glsl @@ -74,10 +74,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/Sources/Shaders/blender_Texturing.frag.glsl b/Sources/Shaders/blender_Texturing.frag.glsl index 37ed30b3..e7a84f5c 100644 --- a/Sources/Shaders/blender_Texturing.frag.glsl +++ b/Sources/Shaders/blender_Texturing.frag.glsl @@ -40,6 +40,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -116,7 +117,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -128,13 +129,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/Sources/Shaders/blender_Texturing.vert.glsl b/Sources/Shaders/blender_Texturing.vert.glsl index 69965bd9..a9f32481 100644 --- a/Sources/Shaders/blender_Texturing.vert.glsl +++ b/Sources/Shaders/blender_Texturing.vert.glsl @@ -73,10 +73,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/Sources/Shaders/blender_Texturing_VCols.frag.glsl b/Sources/Shaders/blender_Texturing_VCols.frag.glsl index f6f1d46e..e30687b2 100644 --- a/Sources/Shaders/blender_Texturing_VCols.frag.glsl +++ b/Sources/Shaders/blender_Texturing_VCols.frag.glsl @@ -41,6 +41,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -117,7 +118,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -129,13 +130,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/Sources/Shaders/blender_Texturing_VCols.vert.glsl b/Sources/Shaders/blender_Texturing_VCols.vert.glsl index 10d4033c..f0915eaa 100644 --- a/Sources/Shaders/blender_Texturing_VCols.vert.glsl +++ b/Sources/Shaders/blender_Texturing_VCols.vert.glsl @@ -74,10 +74,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/Sources/Shaders/blender_VCols.frag.glsl b/Sources/Shaders/blender_VCols.frag.glsl index 04b691f7..bdc47182 100644 --- a/Sources/Shaders/blender_VCols.frag.glsl +++ b/Sources/Shaders/blender_VCols.frag.glsl @@ -40,6 +40,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -116,7 +117,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -128,13 +129,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/Sources/Shaders/blender_VCols.vert.glsl b/Sources/Shaders/blender_VCols.vert.glsl index e5832f93..30e38b91 100644 --- a/Sources/Shaders/blender_VCols.vert.glsl +++ b/Sources/Shaders/blender_VCols.vert.glsl @@ -73,10 +73,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/Sources/Shaders/shadow_map_AlphaTest.frag.glsl b/Sources/Shaders/shadow_map_AlphaTest.frag.glsl new file mode 100644 index 00000000..497fc30c --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest.frag.glsl @@ -0,0 +1,19 @@ +#define _AlphaTest +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/Sources/Shaders/shadow_map_AlphaTest.vert.glsl b/Sources/Shaders/shadow_map_AlphaTest.vert.glsl new file mode 100644 index 00000000..36d9ddda --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest.vert.glsl @@ -0,0 +1,40 @@ +#define _AlphaTest +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/Sources/Shaders/shadow_map_AlphaTest_Instancing.frag.glsl b/Sources/Shaders/shadow_map_AlphaTest_Instancing.frag.glsl new file mode 100644 index 00000000..c4537a2c --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_Instancing.frag.glsl @@ -0,0 +1,20 @@ +#define _AlphaTest +#define _Instancing +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/Sources/Shaders/shadow_map_AlphaTest_Instancing.vert.glsl b/Sources/Shaders/shadow_map_AlphaTest_Instancing.vert.glsl new file mode 100644 index 00000000..8837d795 --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_Instancing.vert.glsl @@ -0,0 +1,41 @@ +#define _AlphaTest +#define _Instancing +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping.frag.glsl b/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping.frag.glsl new file mode 100644 index 00000000..9b34f588 --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping.frag.glsl @@ -0,0 +1,21 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping.vert.glsl b/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping.vert.glsl new file mode 100644 index 00000000..6f27f188 --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping.vert.glsl @@ -0,0 +1,42 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing.frag.glsl b/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing.frag.glsl new file mode 100644 index 00000000..64733934 --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing.frag.glsl @@ -0,0 +1,22 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing.vert.glsl b/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing.vert.glsl new file mode 100644 index 00000000..5e67e9c3 --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing.vert.glsl @@ -0,0 +1,43 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing_VCols.frag.glsl b/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing_VCols.frag.glsl new file mode 100644 index 00000000..18875b0f --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing_VCols.frag.glsl @@ -0,0 +1,23 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing_VCols.vert.glsl b/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing_VCols.vert.glsl new file mode 100644 index 00000000..30aa81d7 --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing_VCols.vert.glsl @@ -0,0 +1,44 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping_VCols.frag.glsl b/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping_VCols.frag.glsl new file mode 100644 index 00000000..3187004b --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping_VCols.frag.glsl @@ -0,0 +1,22 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping_VCols.vert.glsl b/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping_VCols.vert.glsl new file mode 100644 index 00000000..bf44023b --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_Instancing_NormalMapping_VCols.vert.glsl @@ -0,0 +1,43 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/Sources/Shaders/shadow_map_AlphaTest_Instancing_Texturing.frag.glsl b/Sources/Shaders/shadow_map_AlphaTest_Instancing_Texturing.frag.glsl new file mode 100644 index 00000000..b6b36ed1 --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_Instancing_Texturing.frag.glsl @@ -0,0 +1,21 @@ +#define _AlphaTest +#define _Instancing +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/Sources/Shaders/shadow_map_AlphaTest_Instancing_Texturing.vert.glsl b/Sources/Shaders/shadow_map_AlphaTest_Instancing_Texturing.vert.glsl new file mode 100644 index 00000000..ba8e6f2c --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_Instancing_Texturing.vert.glsl @@ -0,0 +1,42 @@ +#define _AlphaTest +#define _Instancing +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/Sources/Shaders/shadow_map_AlphaTest_Instancing_Texturing_VCols.frag.glsl b/Sources/Shaders/shadow_map_AlphaTest_Instancing_Texturing_VCols.frag.glsl new file mode 100644 index 00000000..ceb205f3 --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_Instancing_Texturing_VCols.frag.glsl @@ -0,0 +1,22 @@ +#define _AlphaTest +#define _Instancing +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/Sources/Shaders/shadow_map_AlphaTest_Instancing_Texturing_VCols.vert.glsl b/Sources/Shaders/shadow_map_AlphaTest_Instancing_Texturing_VCols.vert.glsl new file mode 100644 index 00000000..122a6607 --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_Instancing_Texturing_VCols.vert.glsl @@ -0,0 +1,43 @@ +#define _AlphaTest +#define _Instancing +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/Sources/Shaders/shadow_map_AlphaTest_Instancing_VCols.frag.glsl b/Sources/Shaders/shadow_map_AlphaTest_Instancing_VCols.frag.glsl new file mode 100644 index 00000000..d9107a03 --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_Instancing_VCols.frag.glsl @@ -0,0 +1,21 @@ +#define _AlphaTest +#define _Instancing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/Sources/Shaders/shadow_map_AlphaTest_Instancing_VCols.vert.glsl b/Sources/Shaders/shadow_map_AlphaTest_Instancing_VCols.vert.glsl new file mode 100644 index 00000000..0a1f9008 --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_Instancing_VCols.vert.glsl @@ -0,0 +1,42 @@ +#define _AlphaTest +#define _Instancing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/Sources/Shaders/shadow_map_AlphaTest_NormalMapping.frag.glsl b/Sources/Shaders/shadow_map_AlphaTest_NormalMapping.frag.glsl new file mode 100644 index 00000000..d834bd6e --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_NormalMapping.frag.glsl @@ -0,0 +1,20 @@ +#define _AlphaTest +#define _NormalMapping +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/Sources/Shaders/shadow_map_AlphaTest_NormalMapping.vert.glsl b/Sources/Shaders/shadow_map_AlphaTest_NormalMapping.vert.glsl new file mode 100644 index 00000000..d22421c4 --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_NormalMapping.vert.glsl @@ -0,0 +1,41 @@ +#define _AlphaTest +#define _NormalMapping +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/Sources/Shaders/shadow_map_AlphaTest_NormalMapping_Texturing.frag.glsl b/Sources/Shaders/shadow_map_AlphaTest_NormalMapping_Texturing.frag.glsl new file mode 100644 index 00000000..b998b159 --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_NormalMapping_Texturing.frag.glsl @@ -0,0 +1,21 @@ +#define _AlphaTest +#define _NormalMapping +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/Sources/Shaders/shadow_map_AlphaTest_NormalMapping_Texturing.vert.glsl b/Sources/Shaders/shadow_map_AlphaTest_NormalMapping_Texturing.vert.glsl new file mode 100644 index 00000000..4df175fb --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_NormalMapping_Texturing.vert.glsl @@ -0,0 +1,42 @@ +#define _AlphaTest +#define _NormalMapping +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/Sources/Shaders/shadow_map_AlphaTest_NormalMapping_Texturing_VCols.frag.glsl b/Sources/Shaders/shadow_map_AlphaTest_NormalMapping_Texturing_VCols.frag.glsl new file mode 100644 index 00000000..dfa04a4a --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_NormalMapping_Texturing_VCols.frag.glsl @@ -0,0 +1,22 @@ +#define _AlphaTest +#define _NormalMapping +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/Sources/Shaders/shadow_map_AlphaTest_NormalMapping_Texturing_VCols.vert.glsl b/Sources/Shaders/shadow_map_AlphaTest_NormalMapping_Texturing_VCols.vert.glsl new file mode 100644 index 00000000..6b6ef0de --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_NormalMapping_Texturing_VCols.vert.glsl @@ -0,0 +1,43 @@ +#define _AlphaTest +#define _NormalMapping +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/Sources/Shaders/shadow_map_AlphaTest_NormalMapping_VCols.frag.glsl b/Sources/Shaders/shadow_map_AlphaTest_NormalMapping_VCols.frag.glsl new file mode 100644 index 00000000..3646af2a --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_NormalMapping_VCols.frag.glsl @@ -0,0 +1,21 @@ +#define _AlphaTest +#define _NormalMapping +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/Sources/Shaders/shadow_map_AlphaTest_NormalMapping_VCols.vert.glsl b/Sources/Shaders/shadow_map_AlphaTest_NormalMapping_VCols.vert.glsl new file mode 100644 index 00000000..c994d8ad --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_NormalMapping_VCols.vert.glsl @@ -0,0 +1,42 @@ +#define _AlphaTest +#define _NormalMapping +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/Sources/Shaders/shadow_map_AlphaTest_Texturing.frag.glsl b/Sources/Shaders/shadow_map_AlphaTest_Texturing.frag.glsl new file mode 100644 index 00000000..07d06ab8 --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_Texturing.frag.glsl @@ -0,0 +1,20 @@ +#define _AlphaTest +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/Sources/Shaders/shadow_map_AlphaTest_Texturing.vert.glsl b/Sources/Shaders/shadow_map_AlphaTest_Texturing.vert.glsl new file mode 100644 index 00000000..b2788bbe --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_Texturing.vert.glsl @@ -0,0 +1,41 @@ +#define _AlphaTest +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/Sources/Shaders/shadow_map_AlphaTest_Texturing_VCols.frag.glsl b/Sources/Shaders/shadow_map_AlphaTest_Texturing_VCols.frag.glsl new file mode 100644 index 00000000..163f5b8d --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_Texturing_VCols.frag.glsl @@ -0,0 +1,21 @@ +#define _AlphaTest +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/Sources/Shaders/shadow_map_AlphaTest_Texturing_VCols.vert.glsl b/Sources/Shaders/shadow_map_AlphaTest_Texturing_VCols.vert.glsl new file mode 100644 index 00000000..08d42ebd --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_Texturing_VCols.vert.glsl @@ -0,0 +1,42 @@ +#define _AlphaTest +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/Sources/Shaders/shadow_map_AlphaTest_VCols.frag.glsl b/Sources/Shaders/shadow_map_AlphaTest_VCols.frag.glsl new file mode 100644 index 00000000..69d94f20 --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_VCols.frag.glsl @@ -0,0 +1,20 @@ +#define _AlphaTest +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/Sources/Shaders/shadow_map_AlphaTest_VCols.vert.glsl b/Sources/Shaders/shadow_map_AlphaTest_VCols.vert.glsl new file mode 100644 index 00000000..169c4e8f --- /dev/null +++ b/Sources/Shaders/shadow_map_AlphaTest_VCols.vert.glsl @@ -0,0 +1,41 @@ +#define _AlphaTest +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/blender/build.py b/blender/build.py index 3dcbf86b..088b14cb 100755 --- a/blender/build.py +++ b/blender/build.py @@ -42,7 +42,8 @@ def build(): kha_path = output node_path = output + "/Tools/nodejs/node-osx" - os.system(bashCommand + " --nokrafix") + os.system('node Kha/make -t html5 ' + " --nokrafix") + #os.system(bashCommand + " --nokrafix") #os.system(node_path + " " + kha_path + "/make -t html5 --haxe " + haxePath()) #print(subprocess.check_output([node_path + " " + kha_path + "/make -t html5 --haxe " + haxePath()], shell=True)) diff --git a/blender/props.py b/blender/props.py index 7edb32e8..d4f42075 100755 --- a/blender/props.py +++ b/blender/props.py @@ -14,6 +14,7 @@ def initObjectProperties(): bpy.types.Object.geometry_cached = bpy.props.BoolProperty(name="Geometry cached", default=False) bpy.types.Object.instanced_children = bpy.props.BoolProperty(name="Instanced children", default=False) bpy.types.Material.receive_shadow = bpy.props.BoolProperty(name="Receive shadow", default=True) + bpy.types.Material.alpha_test = bpy.props.BoolProperty(name="Alpha test", default=False) bpy.types.Material.export_tangents = bpy.props.BoolProperty(name="Export tangents", default=False) bpy.app.handlers.scene_update_post.append(cb_scene_update) #bpy.app.handlers.scene_update_post.remove(cb_scene_update) @@ -47,6 +48,7 @@ class MatsPropsPanel(bpy.types.Panel): mat = bpy.context.material layout.prop(mat, 'receive_shadow') + layout.prop(mat, 'alpha_test') # Registration bpy.utils.register_module(__name__) diff --git a/blender/scene.py b/blender/scene.py index 261dfeab..9f2d08d1 100644 --- a/blender/scene.py +++ b/blender/scene.py @@ -1983,7 +1983,7 @@ class LueExporter(bpy.types.Operator, ExportHelper): tree = material.node_tree surface_node = self.findNodeByLink(tree, out_node, out_node.inputs[0]) if surface_node.type == 'BSDF_DIFFUSE': - const3.bool = False # Enable lighting + const3.bool = True # Enable lighting # Color if surface_node.inputs[0].is_linked: color_node = self.findNodeByLink(tree, surface_node, surface_node.inputs[0]) @@ -2012,6 +2012,9 @@ class LueExporter(bpy.types.Operator, ExportHelper): o.contexts.append(c) + if material.alpha_test == True: + defs.append('_AlphaTest') + # Material users mat_users = [] for ob in bpy.data.objects: diff --git a/data/blender.shader.glsl b/data/blender.shader.glsl index 0439fd87..52c0eda0 100755 --- a/data/blender.shader.glsl +++ b/data/blender.shader.glsl @@ -86,10 +86,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif @@ -138,6 +140,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -214,7 +217,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -226,13 +229,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else @@ -249,7 +255,7 @@ void kore() { -set depth_write = true -set compare_mode = less --set cull_mode = clockwise +-set cull_mode = counter_clockwise -link lightMVP = _lightMVP diff --git a/data/out/blender.frag.glsl b/data/out/blender.frag.glsl index 33a542e8..9a1f7e63 100644 --- a/data/out/blender.frag.glsl +++ b/data/out/blender.frag.glsl @@ -39,6 +39,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -115,7 +116,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -127,13 +128,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/data/out/blender.vert.glsl b/data/out/blender.vert.glsl index 53d63938..ea243def 100644 --- a/data/out/blender.vert.glsl +++ b/data/out/blender.vert.glsl @@ -72,10 +72,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/data/out/blender_AlphaTest.frag.glsl b/data/out/blender_AlphaTest.frag.glsl new file mode 100644 index 00000000..e66e5d71 --- /dev/null +++ b/data/out/blender_AlphaTest.frag.glsl @@ -0,0 +1,153 @@ +#define _AlphaTest +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/data/out/blender_AlphaTest.vert.glsl b/data/out/blender_AlphaTest.vert.glsl new file mode 100644 index 00000000..49bb32f5 --- /dev/null +++ b/data/out/blender_AlphaTest.vert.glsl @@ -0,0 +1,87 @@ +#define _AlphaTest +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/data/out/blender_AlphaTest_Instancing.frag.glsl b/data/out/blender_AlphaTest_Instancing.frag.glsl new file mode 100644 index 00000000..9023c5fe --- /dev/null +++ b/data/out/blender_AlphaTest_Instancing.frag.glsl @@ -0,0 +1,154 @@ +#define _AlphaTest +#define _Instancing +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/data/out/blender_AlphaTest_Instancing.vert.glsl b/data/out/blender_AlphaTest_Instancing.vert.glsl new file mode 100644 index 00000000..9551be7d --- /dev/null +++ b/data/out/blender_AlphaTest_Instancing.vert.glsl @@ -0,0 +1,88 @@ +#define _AlphaTest +#define _Instancing +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/data/out/blender_AlphaTest_Instancing_NormalMapping.frag.glsl b/data/out/blender_AlphaTest_Instancing_NormalMapping.frag.glsl new file mode 100644 index 00000000..81ae0dbc --- /dev/null +++ b/data/out/blender_AlphaTest_Instancing_NormalMapping.frag.glsl @@ -0,0 +1,155 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/data/out/blender_AlphaTest_Instancing_NormalMapping.vert.glsl b/data/out/blender_AlphaTest_Instancing_NormalMapping.vert.glsl new file mode 100644 index 00000000..506d7abe --- /dev/null +++ b/data/out/blender_AlphaTest_Instancing_NormalMapping.vert.glsl @@ -0,0 +1,89 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/data/out/blender_AlphaTest_Instancing_NormalMapping_Texturing.frag.glsl b/data/out/blender_AlphaTest_Instancing_NormalMapping_Texturing.frag.glsl new file mode 100644 index 00000000..82f9f8a8 --- /dev/null +++ b/data/out/blender_AlphaTest_Instancing_NormalMapping_Texturing.frag.glsl @@ -0,0 +1,156 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/data/out/blender_AlphaTest_Instancing_NormalMapping_Texturing.vert.glsl b/data/out/blender_AlphaTest_Instancing_NormalMapping_Texturing.vert.glsl new file mode 100644 index 00000000..09f5caea --- /dev/null +++ b/data/out/blender_AlphaTest_Instancing_NormalMapping_Texturing.vert.glsl @@ -0,0 +1,90 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/data/out/blender_AlphaTest_Instancing_NormalMapping_Texturing_VCols.frag.glsl b/data/out/blender_AlphaTest_Instancing_NormalMapping_Texturing_VCols.frag.glsl new file mode 100644 index 00000000..493b939d --- /dev/null +++ b/data/out/blender_AlphaTest_Instancing_NormalMapping_Texturing_VCols.frag.glsl @@ -0,0 +1,157 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/data/out/blender_AlphaTest_Instancing_NormalMapping_Texturing_VCols.vert.glsl b/data/out/blender_AlphaTest_Instancing_NormalMapping_Texturing_VCols.vert.glsl new file mode 100644 index 00000000..dfaaef1b --- /dev/null +++ b/data/out/blender_AlphaTest_Instancing_NormalMapping_Texturing_VCols.vert.glsl @@ -0,0 +1,91 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/data/out/blender_AlphaTest_Instancing_NormalMapping_VCols.frag.glsl b/data/out/blender_AlphaTest_Instancing_NormalMapping_VCols.frag.glsl new file mode 100644 index 00000000..8e669461 --- /dev/null +++ b/data/out/blender_AlphaTest_Instancing_NormalMapping_VCols.frag.glsl @@ -0,0 +1,156 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/data/out/blender_AlphaTest_Instancing_NormalMapping_VCols.vert.glsl b/data/out/blender_AlphaTest_Instancing_NormalMapping_VCols.vert.glsl new file mode 100644 index 00000000..d3d7c2e1 --- /dev/null +++ b/data/out/blender_AlphaTest_Instancing_NormalMapping_VCols.vert.glsl @@ -0,0 +1,90 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/data/out/blender_AlphaTest_Instancing_Texturing.frag.glsl b/data/out/blender_AlphaTest_Instancing_Texturing.frag.glsl new file mode 100644 index 00000000..e28da941 --- /dev/null +++ b/data/out/blender_AlphaTest_Instancing_Texturing.frag.glsl @@ -0,0 +1,155 @@ +#define _AlphaTest +#define _Instancing +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/data/out/blender_AlphaTest_Instancing_Texturing.vert.glsl b/data/out/blender_AlphaTest_Instancing_Texturing.vert.glsl new file mode 100644 index 00000000..f54899a4 --- /dev/null +++ b/data/out/blender_AlphaTest_Instancing_Texturing.vert.glsl @@ -0,0 +1,89 @@ +#define _AlphaTest +#define _Instancing +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/data/out/blender_AlphaTest_Instancing_Texturing_VCols.frag.glsl b/data/out/blender_AlphaTest_Instancing_Texturing_VCols.frag.glsl new file mode 100644 index 00000000..70cc301e --- /dev/null +++ b/data/out/blender_AlphaTest_Instancing_Texturing_VCols.frag.glsl @@ -0,0 +1,156 @@ +#define _AlphaTest +#define _Instancing +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/data/out/blender_AlphaTest_Instancing_Texturing_VCols.vert.glsl b/data/out/blender_AlphaTest_Instancing_Texturing_VCols.vert.glsl new file mode 100644 index 00000000..e02df96e --- /dev/null +++ b/data/out/blender_AlphaTest_Instancing_Texturing_VCols.vert.glsl @@ -0,0 +1,90 @@ +#define _AlphaTest +#define _Instancing +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/data/out/blender_AlphaTest_Instancing_VCols.frag.glsl b/data/out/blender_AlphaTest_Instancing_VCols.frag.glsl new file mode 100644 index 00000000..359c1167 --- /dev/null +++ b/data/out/blender_AlphaTest_Instancing_VCols.frag.glsl @@ -0,0 +1,155 @@ +#define _AlphaTest +#define _Instancing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/data/out/blender_AlphaTest_Instancing_VCols.vert.glsl b/data/out/blender_AlphaTest_Instancing_VCols.vert.glsl new file mode 100644 index 00000000..de497ffa --- /dev/null +++ b/data/out/blender_AlphaTest_Instancing_VCols.vert.glsl @@ -0,0 +1,89 @@ +#define _AlphaTest +#define _Instancing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/data/out/blender_AlphaTest_NormalMapping.frag.glsl b/data/out/blender_AlphaTest_NormalMapping.frag.glsl new file mode 100644 index 00000000..aea1448f --- /dev/null +++ b/data/out/blender_AlphaTest_NormalMapping.frag.glsl @@ -0,0 +1,154 @@ +#define _AlphaTest +#define _NormalMapping +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/data/out/blender_AlphaTest_NormalMapping.vert.glsl b/data/out/blender_AlphaTest_NormalMapping.vert.glsl new file mode 100644 index 00000000..0ee660fe --- /dev/null +++ b/data/out/blender_AlphaTest_NormalMapping.vert.glsl @@ -0,0 +1,88 @@ +#define _AlphaTest +#define _NormalMapping +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/data/out/blender_AlphaTest_NormalMapping_Texturing.frag.glsl b/data/out/blender_AlphaTest_NormalMapping_Texturing.frag.glsl new file mode 100644 index 00000000..832d25fd --- /dev/null +++ b/data/out/blender_AlphaTest_NormalMapping_Texturing.frag.glsl @@ -0,0 +1,155 @@ +#define _AlphaTest +#define _NormalMapping +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/data/out/blender_AlphaTest_NormalMapping_Texturing.vert.glsl b/data/out/blender_AlphaTest_NormalMapping_Texturing.vert.glsl new file mode 100644 index 00000000..64d3c129 --- /dev/null +++ b/data/out/blender_AlphaTest_NormalMapping_Texturing.vert.glsl @@ -0,0 +1,89 @@ +#define _AlphaTest +#define _NormalMapping +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/data/out/blender_AlphaTest_NormalMapping_Texturing_VCols.frag.glsl b/data/out/blender_AlphaTest_NormalMapping_Texturing_VCols.frag.glsl new file mode 100644 index 00000000..47470140 --- /dev/null +++ b/data/out/blender_AlphaTest_NormalMapping_Texturing_VCols.frag.glsl @@ -0,0 +1,156 @@ +#define _AlphaTest +#define _NormalMapping +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/data/out/blender_AlphaTest_NormalMapping_Texturing_VCols.vert.glsl b/data/out/blender_AlphaTest_NormalMapping_Texturing_VCols.vert.glsl new file mode 100644 index 00000000..a786b07c --- /dev/null +++ b/data/out/blender_AlphaTest_NormalMapping_Texturing_VCols.vert.glsl @@ -0,0 +1,90 @@ +#define _AlphaTest +#define _NormalMapping +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/data/out/blender_AlphaTest_NormalMapping_VCols.frag.glsl b/data/out/blender_AlphaTest_NormalMapping_VCols.frag.glsl new file mode 100644 index 00000000..ea3bcb18 --- /dev/null +++ b/data/out/blender_AlphaTest_NormalMapping_VCols.frag.glsl @@ -0,0 +1,155 @@ +#define _AlphaTest +#define _NormalMapping +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/data/out/blender_AlphaTest_NormalMapping_VCols.vert.glsl b/data/out/blender_AlphaTest_NormalMapping_VCols.vert.glsl new file mode 100644 index 00000000..5bbcf8a6 --- /dev/null +++ b/data/out/blender_AlphaTest_NormalMapping_VCols.vert.glsl @@ -0,0 +1,89 @@ +#define _AlphaTest +#define _NormalMapping +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/data/out/blender_AlphaTest_Texturing.frag.glsl b/data/out/blender_AlphaTest_Texturing.frag.glsl new file mode 100644 index 00000000..c5cc685d --- /dev/null +++ b/data/out/blender_AlphaTest_Texturing.frag.glsl @@ -0,0 +1,154 @@ +#define _AlphaTest +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/data/out/blender_AlphaTest_Texturing.vert.glsl b/data/out/blender_AlphaTest_Texturing.vert.glsl new file mode 100644 index 00000000..5f9b067f --- /dev/null +++ b/data/out/blender_AlphaTest_Texturing.vert.glsl @@ -0,0 +1,88 @@ +#define _AlphaTest +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/data/out/blender_AlphaTest_Texturing_VCols.frag.glsl b/data/out/blender_AlphaTest_Texturing_VCols.frag.glsl new file mode 100644 index 00000000..1944c152 --- /dev/null +++ b/data/out/blender_AlphaTest_Texturing_VCols.frag.glsl @@ -0,0 +1,155 @@ +#define _AlphaTest +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/data/out/blender_AlphaTest_Texturing_VCols.vert.glsl b/data/out/blender_AlphaTest_Texturing_VCols.vert.glsl new file mode 100644 index 00000000..963b1729 --- /dev/null +++ b/data/out/blender_AlphaTest_Texturing_VCols.vert.glsl @@ -0,0 +1,89 @@ +#define _AlphaTest +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/data/out/blender_AlphaTest_VCols.frag.glsl b/data/out/blender_AlphaTest_VCols.frag.glsl new file mode 100644 index 00000000..24219a2c --- /dev/null +++ b/data/out/blender_AlphaTest_VCols.frag.glsl @@ -0,0 +1,154 @@ +#define _AlphaTest +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +#ifdef _Texturing +uniform sampler2D stex; +#endif +uniform sampler2D shadowMap; +#ifdef _NormalMapping +uniform sampler2D normalMap; +#endif +uniform bool lighting; +uniform bool receiveShadow; +uniform float roughness; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +float shadowSimple(vec4 lPos) { + + vec4 lPosH = lPos / lPos.w; + + lPosH.x = (lPosH.x + 1.0) / 2.0; + lPosH.y = 1.0 - ((-lPosH.y + 1.0) / (2.0)); + + vec4 packedZValue = texture2D(shadowMap, lPosH.st); + + float distanceFromLight = packedZValue.z; + + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); + float bias = 0.0;//0.0005; + + // 1.0 = not in shadow, 0.0 = in shadow + return float(distanceFromLight > lPosH.z - bias); +} + +vec2 LightingFuncGGX_FV(float dotLH, float roughness) { + + float alpha = roughness*roughness; + + // F + float F_a, F_b; + float dotLH5 = pow(1.0 - dotLH, 5.0); + F_a = 1.0; + F_b = dotLH5; + + // V + float vis; + float k = alpha / 2.0; + float k2 = k * k; + float invK2 = 1.0 - k2; + //vis = rcp(dotLH * dotLH * invK2 + k2); + vis = inversesqrt(dotLH * dotLH * invK2 + k2); + + return vec2(F_a * vis, F_b * vis); +} + +float LightingFuncGGX_D(float dotNH, float roughness) { + + float alpha = roughness * roughness; + float alphaSqr = alpha * alpha; + float pi = 3.14159; + float denom = dotNH * dotNH * (alphaSqr - 1.0) + 1.0; + + float D = alphaSqr / (pi * denom * denom); + return D; +} + +// John Hable - Optimizing GGX Shaders +// http://www.filmicworlds.com/2014/04/21/optimizing-ggx-shaders-with-dotlh/ +float LightingFuncGGX_OPT3(vec3 N, vec3 V, vec3 L, float roughness, float F0) { + + vec3 H = normalize(V + L); + + float dotNL = clamp(dot(N, L), 0.0, 1.0); + float dotLH = clamp(dot(L, H), 0.0, 1.0); + float dotNH = clamp(dot(N, H), 0.0, 1.0); + + float D = LightingFuncGGX_D(dotNH, roughness); + vec2 FV_helper = LightingFuncGGX_FV(dotLH, roughness); + float FV = F0 * FV_helper.x + (1.0 - F0) * FV_helper.y; + float specular = dotNL * D * FV; + + return specular; +} + +void kore() { + + float visibility = 1.0; + if (receiveShadow && lPos.w > 0.0) { + visibility = shadowSimple(lPos); + visibility = (visibility * 0.8) + 0.2; + } + + vec4 outColor; + vec3 t = pow(matColor.rgb, vec3(2.2)); + + if (lighting) { + float specular = 0.1; + + vec3 n = normalize(normal); + vec3 l = lightDir; + vec3 v = eyeDir; + + float dotNL = 0.0; +#ifdef _NormalMapping + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); + dotNL = clamp(dot(tn, l), 0.0, 1.0); +#else + dotNL = clamp(dot(n, l), 0.0, 1.0); +#endif + + float spec = LightingFuncGGX_OPT3(n, v, l, roughness, specular); + vec3 rgb = spec + t * dotNL; + + outColor = vec4(vec3(rgb * visibility), 1.0); + } + else { + outColor = vec4(t * visibility, 1.0); + } + +#ifdef _Texturing + vec4 texel = texture2D(stex, texCoord); + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif + + outColor = vec4(texel * outColor); +#else + outColor = vec4(outColor.rgb, 1.0); +#endif + + gl_FragColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a); +} + + +//-------------------------------------------------------- +//-------------------------------------------------------- diff --git a/data/out/blender_AlphaTest_VCols.vert.glsl b/data/out/blender_AlphaTest_VCols.vert.glsl new file mode 100644 index 00000000..8d7c0c12 --- /dev/null +++ b/data/out/blender_AlphaTest_VCols.vert.glsl @@ -0,0 +1,88 @@ +#define _AlphaTest +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform mat4 lightMVP; +uniform vec4 diffuseColor; +uniform vec3 light; +uniform vec3 eye; + +varying vec3 position; +#ifdef _Texturing +varying vec2 texCoord; +#endif +varying vec3 normal; +varying vec4 lPos; +varying vec4 matColor; +varying vec3 lightDir; +varying vec3 eyeDir; + +mat3 transpose(mat3 m) { + return mat3(m[0][0], m[1][0], m[2][0], + m[0][1], m[1][1], m[2][1], + m[0][2], m[1][2], m[2][2]); +} + +void kore() { + +#ifdef _Instancing + vec4 mPos = M * vec4(pos + off, 1.0); + lPos = lightMVP * vec4(pos + off, 1.0); +#else + vec4 mPos = M * vec4(pos, 1.0); + lPos = lightMVP * vec4(pos, 1.0); +#endif + gl_Position = P * V * mPos; + position = mPos.xyz / mPos.w; +#ifdef _Texturing + texCoord = tex; +#endif + normal = normalize((M * vec4(nor, 0.0)).xyz); + + matColor = diffuseColor; +#ifdef _VCols + matColor *= col; +#endif + + lightDir = normalize(light - position); + eyeDir = normalize(eye - position); + +#ifdef _NormalMapping + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); + + mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); + lightDir = normalize(TBN * lightDir); + eyeDir = normalize(TBN * eyeDir); +#endif +} + + diff --git a/data/out/blender_Instancing.frag.glsl b/data/out/blender_Instancing.frag.glsl index 5e1913ef..17c00bf7 100644 --- a/data/out/blender_Instancing.frag.glsl +++ b/data/out/blender_Instancing.frag.glsl @@ -40,6 +40,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -116,7 +117,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -128,13 +129,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/data/out/blender_Instancing.vert.glsl b/data/out/blender_Instancing.vert.glsl index d7e85d5d..a59be006 100644 --- a/data/out/blender_Instancing.vert.glsl +++ b/data/out/blender_Instancing.vert.glsl @@ -73,10 +73,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/data/out/blender_Instancing_NormalMapping.frag.glsl b/data/out/blender_Instancing_NormalMapping.frag.glsl index fda9e796..f98108e1 100644 --- a/data/out/blender_Instancing_NormalMapping.frag.glsl +++ b/data/out/blender_Instancing_NormalMapping.frag.glsl @@ -41,6 +41,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -117,7 +118,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -129,13 +130,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/data/out/blender_Instancing_NormalMapping.vert.glsl b/data/out/blender_Instancing_NormalMapping.vert.glsl index 138b05ca..47b08b64 100644 --- a/data/out/blender_Instancing_NormalMapping.vert.glsl +++ b/data/out/blender_Instancing_NormalMapping.vert.glsl @@ -74,10 +74,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/data/out/blender_Instancing_NormalMapping_Texturing.frag.glsl b/data/out/blender_Instancing_NormalMapping_Texturing.frag.glsl index 4b0c92d2..56154d31 100644 --- a/data/out/blender_Instancing_NormalMapping_Texturing.frag.glsl +++ b/data/out/blender_Instancing_NormalMapping_Texturing.frag.glsl @@ -42,6 +42,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -118,7 +119,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -130,13 +131,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/data/out/blender_Instancing_NormalMapping_Texturing.vert.glsl b/data/out/blender_Instancing_NormalMapping_Texturing.vert.glsl index 3ab9c30d..c6130ec5 100644 --- a/data/out/blender_Instancing_NormalMapping_Texturing.vert.glsl +++ b/data/out/blender_Instancing_NormalMapping_Texturing.vert.glsl @@ -75,10 +75,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/data/out/blender_Instancing_NormalMapping_Texturing_VCols.frag.glsl b/data/out/blender_Instancing_NormalMapping_Texturing_VCols.frag.glsl index 26f89b24..2c9da22d 100644 --- a/data/out/blender_Instancing_NormalMapping_Texturing_VCols.frag.glsl +++ b/data/out/blender_Instancing_NormalMapping_Texturing_VCols.frag.glsl @@ -43,6 +43,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -119,7 +120,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -131,13 +132,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/data/out/blender_Instancing_NormalMapping_Texturing_VCols.vert.glsl b/data/out/blender_Instancing_NormalMapping_Texturing_VCols.vert.glsl index 3270aa60..763d8812 100644 --- a/data/out/blender_Instancing_NormalMapping_Texturing_VCols.vert.glsl +++ b/data/out/blender_Instancing_NormalMapping_Texturing_VCols.vert.glsl @@ -76,10 +76,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/data/out/blender_Instancing_NormalMapping_VCols.frag.glsl b/data/out/blender_Instancing_NormalMapping_VCols.frag.glsl index 8743b3f4..7354cca9 100644 --- a/data/out/blender_Instancing_NormalMapping_VCols.frag.glsl +++ b/data/out/blender_Instancing_NormalMapping_VCols.frag.glsl @@ -42,6 +42,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -118,7 +119,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -130,13 +131,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/data/out/blender_Instancing_NormalMapping_VCols.vert.glsl b/data/out/blender_Instancing_NormalMapping_VCols.vert.glsl index 81db2be2..6299f12b 100644 --- a/data/out/blender_Instancing_NormalMapping_VCols.vert.glsl +++ b/data/out/blender_Instancing_NormalMapping_VCols.vert.glsl @@ -75,10 +75,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/data/out/blender_Instancing_Texturing.frag.glsl b/data/out/blender_Instancing_Texturing.frag.glsl index e579f8ac..78b5725b 100644 --- a/data/out/blender_Instancing_Texturing.frag.glsl +++ b/data/out/blender_Instancing_Texturing.frag.glsl @@ -41,6 +41,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -117,7 +118,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -129,13 +130,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/data/out/blender_Instancing_Texturing.vert.glsl b/data/out/blender_Instancing_Texturing.vert.glsl index 40b1a190..6dd479f5 100644 --- a/data/out/blender_Instancing_Texturing.vert.glsl +++ b/data/out/blender_Instancing_Texturing.vert.glsl @@ -74,10 +74,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/data/out/blender_Instancing_Texturing_VCols.frag.glsl b/data/out/blender_Instancing_Texturing_VCols.frag.glsl index 2be1aaed..d6d75a0e 100644 --- a/data/out/blender_Instancing_Texturing_VCols.frag.glsl +++ b/data/out/blender_Instancing_Texturing_VCols.frag.glsl @@ -42,6 +42,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -118,7 +119,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -130,13 +131,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/data/out/blender_Instancing_Texturing_VCols.vert.glsl b/data/out/blender_Instancing_Texturing_VCols.vert.glsl index 1d5f791c..8f24a1a8 100644 --- a/data/out/blender_Instancing_Texturing_VCols.vert.glsl +++ b/data/out/blender_Instancing_Texturing_VCols.vert.glsl @@ -75,10 +75,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/data/out/blender_Instancing_VCols.frag.glsl b/data/out/blender_Instancing_VCols.frag.glsl index a9ce97ad..0acaeb62 100644 --- a/data/out/blender_Instancing_VCols.frag.glsl +++ b/data/out/blender_Instancing_VCols.frag.glsl @@ -41,6 +41,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -117,7 +118,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -129,13 +130,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/data/out/blender_Instancing_VCols.vert.glsl b/data/out/blender_Instancing_VCols.vert.glsl index 1c5c6abf..49ed8f2e 100644 --- a/data/out/blender_Instancing_VCols.vert.glsl +++ b/data/out/blender_Instancing_VCols.vert.glsl @@ -74,10 +74,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/data/out/blender_NormalMapping.frag.glsl b/data/out/blender_NormalMapping.frag.glsl index 668ee223..59b61575 100644 --- a/data/out/blender_NormalMapping.frag.glsl +++ b/data/out/blender_NormalMapping.frag.glsl @@ -40,6 +40,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -116,7 +117,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -128,13 +129,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/data/out/blender_NormalMapping.vert.glsl b/data/out/blender_NormalMapping.vert.glsl index 78c24c16..26ca27f9 100644 --- a/data/out/blender_NormalMapping.vert.glsl +++ b/data/out/blender_NormalMapping.vert.glsl @@ -73,10 +73,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/data/out/blender_NormalMapping_Texturing.frag.glsl b/data/out/blender_NormalMapping_Texturing.frag.glsl index 1a719e77..a4400833 100644 --- a/data/out/blender_NormalMapping_Texturing.frag.glsl +++ b/data/out/blender_NormalMapping_Texturing.frag.glsl @@ -41,6 +41,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -117,7 +118,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -129,13 +130,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/data/out/blender_NormalMapping_Texturing.vert.glsl b/data/out/blender_NormalMapping_Texturing.vert.glsl index 3f983bbe..706e31a8 100644 --- a/data/out/blender_NormalMapping_Texturing.vert.glsl +++ b/data/out/blender_NormalMapping_Texturing.vert.glsl @@ -74,10 +74,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/data/out/blender_NormalMapping_Texturing_VCols.frag.glsl b/data/out/blender_NormalMapping_Texturing_VCols.frag.glsl index b3c2e961..cebf78f5 100644 --- a/data/out/blender_NormalMapping_Texturing_VCols.frag.glsl +++ b/data/out/blender_NormalMapping_Texturing_VCols.frag.glsl @@ -42,6 +42,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -118,7 +119,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -130,13 +131,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/data/out/blender_NormalMapping_Texturing_VCols.vert.glsl b/data/out/blender_NormalMapping_Texturing_VCols.vert.glsl index 34a3785e..3149c83b 100644 --- a/data/out/blender_NormalMapping_Texturing_VCols.vert.glsl +++ b/data/out/blender_NormalMapping_Texturing_VCols.vert.glsl @@ -75,10 +75,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/data/out/blender_NormalMapping_VCols.frag.glsl b/data/out/blender_NormalMapping_VCols.frag.glsl index 34926c42..d4475d03 100644 --- a/data/out/blender_NormalMapping_VCols.frag.glsl +++ b/data/out/blender_NormalMapping_VCols.frag.glsl @@ -41,6 +41,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -117,7 +118,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -129,13 +130,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/data/out/blender_NormalMapping_VCols.vert.glsl b/data/out/blender_NormalMapping_VCols.vert.glsl index fd0c0201..f7aa689a 100644 --- a/data/out/blender_NormalMapping_VCols.vert.glsl +++ b/data/out/blender_NormalMapping_VCols.vert.glsl @@ -74,10 +74,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/data/out/blender_Texturing.frag.glsl b/data/out/blender_Texturing.frag.glsl index 37ed30b3..e7a84f5c 100644 --- a/data/out/blender_Texturing.frag.glsl +++ b/data/out/blender_Texturing.frag.glsl @@ -40,6 +40,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -116,7 +117,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -128,13 +129,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/data/out/blender_Texturing.vert.glsl b/data/out/blender_Texturing.vert.glsl index 69965bd9..a9f32481 100644 --- a/data/out/blender_Texturing.vert.glsl +++ b/data/out/blender_Texturing.vert.glsl @@ -73,10 +73,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/data/out/blender_Texturing_VCols.frag.glsl b/data/out/blender_Texturing_VCols.frag.glsl index f6f1d46e..e30687b2 100644 --- a/data/out/blender_Texturing_VCols.frag.glsl +++ b/data/out/blender_Texturing_VCols.frag.glsl @@ -41,6 +41,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -117,7 +118,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -129,13 +130,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/data/out/blender_Texturing_VCols.vert.glsl b/data/out/blender_Texturing_VCols.vert.glsl index 10d4033c..f0915eaa 100644 --- a/data/out/blender_Texturing_VCols.vert.glsl +++ b/data/out/blender_Texturing_VCols.vert.glsl @@ -74,10 +74,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/data/out/blender_VCols.frag.glsl b/data/out/blender_VCols.frag.glsl index 04b691f7..bdc47182 100644 --- a/data/out/blender_VCols.frag.glsl +++ b/data/out/blender_VCols.frag.glsl @@ -40,6 +40,7 @@ float shadowSimple(vec4 lPos) { float distanceFromLight = packedZValue.z; + //float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01); float bias = 0.0;//0.0005; // 1.0 = not in shadow, 0.0 = in shadow @@ -116,7 +117,7 @@ void kore() { float dotNL = 0.0; #ifdef _NormalMapping - vec3 tn = normalize(texture2D(normalMap, vec2(texCoord.x, 1.0 - texCoord.y)).rgb * 2.0 - 1.0); + vec3 tn = normalize(texture2D(normalMap, texCoord).rgb * 2.0 - 1.0); dotNL = clamp(dot(tn, l), 0.0, 1.0); #else dotNL = clamp(dot(n, l), 0.0, 1.0); @@ -128,13 +129,16 @@ void kore() { outColor = vec4(vec3(rgb * visibility), 1.0); } else { - outColor = vec4(t, 1.0); + outColor = vec4(t * visibility, 1.0); } #ifdef _Texturing vec4 texel = texture2D(stex, texCoord); - //if(texel.a < 0.4) - // discard; + +#ifdef _AlphaTest + if(texel.a < 0.4) + discard; +#endif outColor = vec4(texel * outColor); #else diff --git a/data/out/blender_VCols.vert.glsl b/data/out/blender_VCols.vert.glsl index e5832f93..30e38b91 100644 --- a/data/out/blender_VCols.vert.glsl +++ b/data/out/blender_VCols.vert.glsl @@ -73,10 +73,12 @@ void kore() { eyeDir = normalize(eye - position); #ifdef _NormalMapping - vec3 vTangent = tan; - vec3 vBitangent = bitan; + vec3 vTangent = (tan); + vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w; + //vec3 vBitangent = (bitan); mat3 TBN = transpose(mat3(vTangent, vBitangent, normal)); + //mat3 TBN = (mat3(vTangent, vBitangent, normal)); lightDir = normalize(TBN * lightDir); eyeDir = normalize(TBN * eyeDir); #endif diff --git a/data/out/shadow_map_AlphaTest.frag.glsl b/data/out/shadow_map_AlphaTest.frag.glsl new file mode 100644 index 00000000..497fc30c --- /dev/null +++ b/data/out/shadow_map_AlphaTest.frag.glsl @@ -0,0 +1,19 @@ +#define _AlphaTest +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/data/out/shadow_map_AlphaTest.vert.glsl b/data/out/shadow_map_AlphaTest.vert.glsl new file mode 100644 index 00000000..36d9ddda --- /dev/null +++ b/data/out/shadow_map_AlphaTest.vert.glsl @@ -0,0 +1,40 @@ +#define _AlphaTest +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/data/out/shadow_map_AlphaTest_Instancing.frag.glsl b/data/out/shadow_map_AlphaTest_Instancing.frag.glsl new file mode 100644 index 00000000..c4537a2c --- /dev/null +++ b/data/out/shadow_map_AlphaTest_Instancing.frag.glsl @@ -0,0 +1,20 @@ +#define _AlphaTest +#define _Instancing +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/data/out/shadow_map_AlphaTest_Instancing.vert.glsl b/data/out/shadow_map_AlphaTest_Instancing.vert.glsl new file mode 100644 index 00000000..8837d795 --- /dev/null +++ b/data/out/shadow_map_AlphaTest_Instancing.vert.glsl @@ -0,0 +1,41 @@ +#define _AlphaTest +#define _Instancing +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/data/out/shadow_map_AlphaTest_Instancing_NormalMapping.frag.glsl b/data/out/shadow_map_AlphaTest_Instancing_NormalMapping.frag.glsl new file mode 100644 index 00000000..9b34f588 --- /dev/null +++ b/data/out/shadow_map_AlphaTest_Instancing_NormalMapping.frag.glsl @@ -0,0 +1,21 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/data/out/shadow_map_AlphaTest_Instancing_NormalMapping.vert.glsl b/data/out/shadow_map_AlphaTest_Instancing_NormalMapping.vert.glsl new file mode 100644 index 00000000..6f27f188 --- /dev/null +++ b/data/out/shadow_map_AlphaTest_Instancing_NormalMapping.vert.glsl @@ -0,0 +1,42 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/data/out/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing.frag.glsl b/data/out/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing.frag.glsl new file mode 100644 index 00000000..64733934 --- /dev/null +++ b/data/out/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing.frag.glsl @@ -0,0 +1,22 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/data/out/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing.vert.glsl b/data/out/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing.vert.glsl new file mode 100644 index 00000000..5e67e9c3 --- /dev/null +++ b/data/out/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing.vert.glsl @@ -0,0 +1,43 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/data/out/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing_VCols.frag.glsl b/data/out/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing_VCols.frag.glsl new file mode 100644 index 00000000..18875b0f --- /dev/null +++ b/data/out/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing_VCols.frag.glsl @@ -0,0 +1,23 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/data/out/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing_VCols.vert.glsl b/data/out/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing_VCols.vert.glsl new file mode 100644 index 00000000..30aa81d7 --- /dev/null +++ b/data/out/shadow_map_AlphaTest_Instancing_NormalMapping_Texturing_VCols.vert.glsl @@ -0,0 +1,44 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/data/out/shadow_map_AlphaTest_Instancing_NormalMapping_VCols.frag.glsl b/data/out/shadow_map_AlphaTest_Instancing_NormalMapping_VCols.frag.glsl new file mode 100644 index 00000000..3187004b --- /dev/null +++ b/data/out/shadow_map_AlphaTest_Instancing_NormalMapping_VCols.frag.glsl @@ -0,0 +1,22 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/data/out/shadow_map_AlphaTest_Instancing_NormalMapping_VCols.vert.glsl b/data/out/shadow_map_AlphaTest_Instancing_NormalMapping_VCols.vert.glsl new file mode 100644 index 00000000..bf44023b --- /dev/null +++ b/data/out/shadow_map_AlphaTest_Instancing_NormalMapping_VCols.vert.glsl @@ -0,0 +1,43 @@ +#define _AlphaTest +#define _Instancing +#define _NormalMapping +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/data/out/shadow_map_AlphaTest_Instancing_Texturing.frag.glsl b/data/out/shadow_map_AlphaTest_Instancing_Texturing.frag.glsl new file mode 100644 index 00000000..b6b36ed1 --- /dev/null +++ b/data/out/shadow_map_AlphaTest_Instancing_Texturing.frag.glsl @@ -0,0 +1,21 @@ +#define _AlphaTest +#define _Instancing +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/data/out/shadow_map_AlphaTest_Instancing_Texturing.vert.glsl b/data/out/shadow_map_AlphaTest_Instancing_Texturing.vert.glsl new file mode 100644 index 00000000..ba8e6f2c --- /dev/null +++ b/data/out/shadow_map_AlphaTest_Instancing_Texturing.vert.glsl @@ -0,0 +1,42 @@ +#define _AlphaTest +#define _Instancing +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/data/out/shadow_map_AlphaTest_Instancing_Texturing_VCols.frag.glsl b/data/out/shadow_map_AlphaTest_Instancing_Texturing_VCols.frag.glsl new file mode 100644 index 00000000..ceb205f3 --- /dev/null +++ b/data/out/shadow_map_AlphaTest_Instancing_Texturing_VCols.frag.glsl @@ -0,0 +1,22 @@ +#define _AlphaTest +#define _Instancing +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/data/out/shadow_map_AlphaTest_Instancing_Texturing_VCols.vert.glsl b/data/out/shadow_map_AlphaTest_Instancing_Texturing_VCols.vert.glsl new file mode 100644 index 00000000..122a6607 --- /dev/null +++ b/data/out/shadow_map_AlphaTest_Instancing_Texturing_VCols.vert.glsl @@ -0,0 +1,43 @@ +#define _AlphaTest +#define _Instancing +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/data/out/shadow_map_AlphaTest_Instancing_VCols.frag.glsl b/data/out/shadow_map_AlphaTest_Instancing_VCols.frag.glsl new file mode 100644 index 00000000..d9107a03 --- /dev/null +++ b/data/out/shadow_map_AlphaTest_Instancing_VCols.frag.glsl @@ -0,0 +1,21 @@ +#define _AlphaTest +#define _Instancing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/data/out/shadow_map_AlphaTest_Instancing_VCols.vert.glsl b/data/out/shadow_map_AlphaTest_Instancing_VCols.vert.glsl new file mode 100644 index 00000000..0a1f9008 --- /dev/null +++ b/data/out/shadow_map_AlphaTest_Instancing_VCols.vert.glsl @@ -0,0 +1,42 @@ +#define _AlphaTest +#define _Instancing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/data/out/shadow_map_AlphaTest_NormalMapping.frag.glsl b/data/out/shadow_map_AlphaTest_NormalMapping.frag.glsl new file mode 100644 index 00000000..d834bd6e --- /dev/null +++ b/data/out/shadow_map_AlphaTest_NormalMapping.frag.glsl @@ -0,0 +1,20 @@ +#define _AlphaTest +#define _NormalMapping +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/data/out/shadow_map_AlphaTest_NormalMapping.vert.glsl b/data/out/shadow_map_AlphaTest_NormalMapping.vert.glsl new file mode 100644 index 00000000..d22421c4 --- /dev/null +++ b/data/out/shadow_map_AlphaTest_NormalMapping.vert.glsl @@ -0,0 +1,41 @@ +#define _AlphaTest +#define _NormalMapping +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/data/out/shadow_map_AlphaTest_NormalMapping_Texturing.frag.glsl b/data/out/shadow_map_AlphaTest_NormalMapping_Texturing.frag.glsl new file mode 100644 index 00000000..b998b159 --- /dev/null +++ b/data/out/shadow_map_AlphaTest_NormalMapping_Texturing.frag.glsl @@ -0,0 +1,21 @@ +#define _AlphaTest +#define _NormalMapping +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/data/out/shadow_map_AlphaTest_NormalMapping_Texturing.vert.glsl b/data/out/shadow_map_AlphaTest_NormalMapping_Texturing.vert.glsl new file mode 100644 index 00000000..4df175fb --- /dev/null +++ b/data/out/shadow_map_AlphaTest_NormalMapping_Texturing.vert.glsl @@ -0,0 +1,42 @@ +#define _AlphaTest +#define _NormalMapping +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/data/out/shadow_map_AlphaTest_NormalMapping_Texturing_VCols.frag.glsl b/data/out/shadow_map_AlphaTest_NormalMapping_Texturing_VCols.frag.glsl new file mode 100644 index 00000000..dfa04a4a --- /dev/null +++ b/data/out/shadow_map_AlphaTest_NormalMapping_Texturing_VCols.frag.glsl @@ -0,0 +1,22 @@ +#define _AlphaTest +#define _NormalMapping +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/data/out/shadow_map_AlphaTest_NormalMapping_Texturing_VCols.vert.glsl b/data/out/shadow_map_AlphaTest_NormalMapping_Texturing_VCols.vert.glsl new file mode 100644 index 00000000..6b6ef0de --- /dev/null +++ b/data/out/shadow_map_AlphaTest_NormalMapping_Texturing_VCols.vert.glsl @@ -0,0 +1,43 @@ +#define _AlphaTest +#define _NormalMapping +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/data/out/shadow_map_AlphaTest_NormalMapping_VCols.frag.glsl b/data/out/shadow_map_AlphaTest_NormalMapping_VCols.frag.glsl new file mode 100644 index 00000000..3646af2a --- /dev/null +++ b/data/out/shadow_map_AlphaTest_NormalMapping_VCols.frag.glsl @@ -0,0 +1,21 @@ +#define _AlphaTest +#define _NormalMapping +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/data/out/shadow_map_AlphaTest_NormalMapping_VCols.vert.glsl b/data/out/shadow_map_AlphaTest_NormalMapping_VCols.vert.glsl new file mode 100644 index 00000000..c994d8ad --- /dev/null +++ b/data/out/shadow_map_AlphaTest_NormalMapping_VCols.vert.glsl @@ -0,0 +1,42 @@ +#define _AlphaTest +#define _NormalMapping +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/data/out/shadow_map_AlphaTest_Texturing.frag.glsl b/data/out/shadow_map_AlphaTest_Texturing.frag.glsl new file mode 100644 index 00000000..07d06ab8 --- /dev/null +++ b/data/out/shadow_map_AlphaTest_Texturing.frag.glsl @@ -0,0 +1,20 @@ +#define _AlphaTest +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/data/out/shadow_map_AlphaTest_Texturing.vert.glsl b/data/out/shadow_map_AlphaTest_Texturing.vert.glsl new file mode 100644 index 00000000..b2788bbe --- /dev/null +++ b/data/out/shadow_map_AlphaTest_Texturing.vert.glsl @@ -0,0 +1,41 @@ +#define _AlphaTest +#define _Texturing +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/data/out/shadow_map_AlphaTest_Texturing_VCols.frag.glsl b/data/out/shadow_map_AlphaTest_Texturing_VCols.frag.glsl new file mode 100644 index 00000000..163f5b8d --- /dev/null +++ b/data/out/shadow_map_AlphaTest_Texturing_VCols.frag.glsl @@ -0,0 +1,21 @@ +#define _AlphaTest +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/data/out/shadow_map_AlphaTest_Texturing_VCols.vert.glsl b/data/out/shadow_map_AlphaTest_Texturing_VCols.vert.glsl new file mode 100644 index 00000000..08d42ebd --- /dev/null +++ b/data/out/shadow_map_AlphaTest_Texturing_VCols.vert.glsl @@ -0,0 +1,42 @@ +#define _AlphaTest +#define _Texturing +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/data/out/shadow_map_AlphaTest_VCols.frag.glsl b/data/out/shadow_map_AlphaTest_VCols.frag.glsl new file mode 100644 index 00000000..69d94f20 --- /dev/null +++ b/data/out/shadow_map_AlphaTest_VCols.frag.glsl @@ -0,0 +1,20 @@ +#define _AlphaTest +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision mediump float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +varying vec4 position; + +void kore() { + + float normalizedDistance = position.z / position.w; + normalizedDistance += 0.005; + + gl_FragColor = vec4(normalizedDistance, normalizedDistance, normalizedDistance, 1.0); +} diff --git a/data/out/shadow_map_AlphaTest_VCols.vert.glsl b/data/out/shadow_map_AlphaTest_VCols.vert.glsl new file mode 100644 index 00000000..169c4e8f --- /dev/null +++ b/data/out/shadow_map_AlphaTest_VCols.vert.glsl @@ -0,0 +1,41 @@ +#define _AlphaTest +#define _VCols +//-------------------------------------------------------- +#ifdef GL_ES +precision highp float; +#endif + +#ifdef _NormalMapping +#define _Texturing +#endif + +attribute vec3 pos; +#ifdef _Texturing +attribute vec2 tex; +#endif +attribute vec3 nor; +#ifdef _VCols +attribute vec4 col; +#endif +#ifdef _NormalMapping +attribute vec3 tan; +attribute vec3 bitan; +#endif +#ifdef _Instancing +attribute vec3 off; +#endif + +uniform mat4 lightMVP; + +varying vec4 position; + +void kore() { +#ifdef _Instancing + gl_Position = lightMVP * vec4(pos + off, 1.0); +#else + gl_Position = lightMVP * vec4(pos, 1.0); +#endif + position = gl_Position; +} + + diff --git a/haxelib.json b/haxelib.json index d14edb1d..ee82e457 100644 --- a/haxelib.json +++ b/haxelib.json @@ -1,7 +1,7 @@ { "name": "cyclesgame", "url" : "https://github.com/luboslenco/cyclesgame/", - "license": "MIT", + "license": "LGPL", "tags": ["kha", "3d"], "description": "Blender game engine", "version": "15.11.0",