Shaders and camera work
This commit is contained in:
parent
3eae0de6e1
commit
aeb3ec5a22
165
LICENSE
Normal file
165
LICENSE
Normal file
|
@ -0,0 +1,165 @@
|
||||||
|
GNU LESSER GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
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.
|
|
@ -39,6 +39,7 @@ float shadowSimple(vec4 lPos) {
|
||||||
|
|
||||||
float distanceFromLight = packedZValue.z;
|
float distanceFromLight = packedZValue.z;
|
||||||
|
|
||||||
|
//float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01);
|
||||||
float bias = 0.0;//0.0005;
|
float bias = 0.0;//0.0005;
|
||||||
|
|
||||||
// 1.0 = not in shadow, 0.0 = in shadow
|
// 1.0 = not in shadow, 0.0 = in shadow
|
||||||
|
@ -115,7 +116,7 @@ void kore() {
|
||||||
|
|
||||||
float dotNL = 0.0;
|
float dotNL = 0.0;
|
||||||
#ifdef _NormalMapping
|
#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);
|
dotNL = clamp(dot(tn, l), 0.0, 1.0);
|
||||||
#else
|
#else
|
||||||
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
||||||
|
@ -127,13 +128,16 @@ void kore() {
|
||||||
outColor = vec4(vec3(rgb * visibility), 1.0);
|
outColor = vec4(vec3(rgb * visibility), 1.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
outColor = vec4(t, 1.0);
|
outColor = vec4(vec3(t * visibility), 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _Texturing
|
#ifdef _Texturing
|
||||||
vec4 texel = texture2D(stex, texCoord);
|
vec4 texel = texture2D(stex, texCoord);
|
||||||
//if(texel.a < 0.4)
|
|
||||||
// discard;
|
#ifdef _AlphaTest
|
||||||
|
if(texel.a < 0.4)
|
||||||
|
discard;
|
||||||
|
#endif
|
||||||
|
|
||||||
outColor = vec4(texel * outColor);
|
outColor = vec4(texel * outColor);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -72,10 +72,12 @@ void kore() {
|
||||||
eyeDir = normalize(eye - position);
|
eyeDir = normalize(eye - position);
|
||||||
|
|
||||||
#ifdef _NormalMapping
|
#ifdef _NormalMapping
|
||||||
vec3 vTangent = tan;
|
vec3 vTangent = (tan);
|
||||||
vec3 vBitangent = bitan;
|
vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w;
|
||||||
|
//vec3 vBitangent = (bitan);
|
||||||
|
|
||||||
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
||||||
|
//mat3 TBN = (mat3(vTangent, vBitangent, normal));
|
||||||
lightDir = normalize(TBN * lightDir);
|
lightDir = normalize(TBN * lightDir);
|
||||||
eyeDir = normalize(TBN * eyeDir);
|
eyeDir = normalize(TBN * eyeDir);
|
||||||
#endif
|
#endif
|
||||||
|
|
153
Sources/Shaders/blender_AlphaTest.frag.glsl
Normal file
153
Sources/Shaders/blender_AlphaTest.frag.glsl
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------
|
||||||
|
//--------------------------------------------------------
|
87
Sources/Shaders/blender_AlphaTest.vert.glsl
Normal file
87
Sources/Shaders/blender_AlphaTest.vert.glsl
Normal file
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
154
Sources/Shaders/blender_AlphaTest_Instancing.frag.glsl
Normal file
154
Sources/Shaders/blender_AlphaTest_Instancing.frag.glsl
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------
|
||||||
|
//--------------------------------------------------------
|
88
Sources/Shaders/blender_AlphaTest_Instancing.vert.glsl
Normal file
88
Sources/Shaders/blender_AlphaTest_Instancing.vert.glsl
Normal file
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------
|
||||||
|
//--------------------------------------------------------
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------
|
||||||
|
//--------------------------------------------------------
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------
|
||||||
|
//--------------------------------------------------------
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------
|
||||||
|
//--------------------------------------------------------
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
155
Sources/Shaders/blender_AlphaTest_Instancing_Texturing.frag.glsl
Normal file
155
Sources/Shaders/blender_AlphaTest_Instancing_Texturing.frag.glsl
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------
|
||||||
|
//--------------------------------------------------------
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------
|
||||||
|
//--------------------------------------------------------
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
155
Sources/Shaders/blender_AlphaTest_Instancing_VCols.frag.glsl
Normal file
155
Sources/Shaders/blender_AlphaTest_Instancing_VCols.frag.glsl
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------
|
||||||
|
//--------------------------------------------------------
|
89
Sources/Shaders/blender_AlphaTest_Instancing_VCols.vert.glsl
Normal file
89
Sources/Shaders/blender_AlphaTest_Instancing_VCols.vert.glsl
Normal file
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
154
Sources/Shaders/blender_AlphaTest_NormalMapping.frag.glsl
Normal file
154
Sources/Shaders/blender_AlphaTest_NormalMapping.frag.glsl
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------
|
||||||
|
//--------------------------------------------------------
|
88
Sources/Shaders/blender_AlphaTest_NormalMapping.vert.glsl
Normal file
88
Sources/Shaders/blender_AlphaTest_NormalMapping.vert.glsl
Normal file
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------
|
||||||
|
//--------------------------------------------------------
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------
|
||||||
|
//--------------------------------------------------------
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
155
Sources/Shaders/blender_AlphaTest_NormalMapping_VCols.frag.glsl
Normal file
155
Sources/Shaders/blender_AlphaTest_NormalMapping_VCols.frag.glsl
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------
|
||||||
|
//--------------------------------------------------------
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
154
Sources/Shaders/blender_AlphaTest_Texturing.frag.glsl
Normal file
154
Sources/Shaders/blender_AlphaTest_Texturing.frag.glsl
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------
|
||||||
|
//--------------------------------------------------------
|
88
Sources/Shaders/blender_AlphaTest_Texturing.vert.glsl
Normal file
88
Sources/Shaders/blender_AlphaTest_Texturing.vert.glsl
Normal file
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
155
Sources/Shaders/blender_AlphaTest_Texturing_VCols.frag.glsl
Normal file
155
Sources/Shaders/blender_AlphaTest_Texturing_VCols.frag.glsl
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------
|
||||||
|
//--------------------------------------------------------
|
89
Sources/Shaders/blender_AlphaTest_Texturing_VCols.vert.glsl
Normal file
89
Sources/Shaders/blender_AlphaTest_Texturing_VCols.vert.glsl
Normal file
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
154
Sources/Shaders/blender_AlphaTest_VCols.frag.glsl
Normal file
154
Sources/Shaders/blender_AlphaTest_VCols.frag.glsl
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------
|
||||||
|
//--------------------------------------------------------
|
88
Sources/Shaders/blender_AlphaTest_VCols.vert.glsl
Normal file
88
Sources/Shaders/blender_AlphaTest_VCols.vert.glsl
Normal file
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ float shadowSimple(vec4 lPos) {
|
||||||
|
|
||||||
float distanceFromLight = packedZValue.z;
|
float distanceFromLight = packedZValue.z;
|
||||||
|
|
||||||
|
//float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01);
|
||||||
float bias = 0.0;//0.0005;
|
float bias = 0.0;//0.0005;
|
||||||
|
|
||||||
// 1.0 = not in shadow, 0.0 = in shadow
|
// 1.0 = not in shadow, 0.0 = in shadow
|
||||||
|
@ -116,7 +117,7 @@ void kore() {
|
||||||
|
|
||||||
float dotNL = 0.0;
|
float dotNL = 0.0;
|
||||||
#ifdef _NormalMapping
|
#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);
|
dotNL = clamp(dot(tn, l), 0.0, 1.0);
|
||||||
#else
|
#else
|
||||||
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
||||||
|
@ -128,13 +129,16 @@ void kore() {
|
||||||
outColor = vec4(vec3(rgb * visibility), 1.0);
|
outColor = vec4(vec3(rgb * visibility), 1.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
outColor = vec4(t, 1.0);
|
outColor = vec4(t * visibility, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _Texturing
|
#ifdef _Texturing
|
||||||
vec4 texel = texture2D(stex, texCoord);
|
vec4 texel = texture2D(stex, texCoord);
|
||||||
//if(texel.a < 0.4)
|
|
||||||
// discard;
|
#ifdef _AlphaTest
|
||||||
|
if(texel.a < 0.4)
|
||||||
|
discard;
|
||||||
|
#endif
|
||||||
|
|
||||||
outColor = vec4(texel * outColor);
|
outColor = vec4(texel * outColor);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -73,10 +73,12 @@ void kore() {
|
||||||
eyeDir = normalize(eye - position);
|
eyeDir = normalize(eye - position);
|
||||||
|
|
||||||
#ifdef _NormalMapping
|
#ifdef _NormalMapping
|
||||||
vec3 vTangent = tan;
|
vec3 vTangent = (tan);
|
||||||
vec3 vBitangent = bitan;
|
vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w;
|
||||||
|
//vec3 vBitangent = (bitan);
|
||||||
|
|
||||||
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
||||||
|
//mat3 TBN = (mat3(vTangent, vBitangent, normal));
|
||||||
lightDir = normalize(TBN * lightDir);
|
lightDir = normalize(TBN * lightDir);
|
||||||
eyeDir = normalize(TBN * eyeDir);
|
eyeDir = normalize(TBN * eyeDir);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -41,6 +41,7 @@ float shadowSimple(vec4 lPos) {
|
||||||
|
|
||||||
float distanceFromLight = packedZValue.z;
|
float distanceFromLight = packedZValue.z;
|
||||||
|
|
||||||
|
//float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01);
|
||||||
float bias = 0.0;//0.0005;
|
float bias = 0.0;//0.0005;
|
||||||
|
|
||||||
// 1.0 = not in shadow, 0.0 = in shadow
|
// 1.0 = not in shadow, 0.0 = in shadow
|
||||||
|
@ -117,7 +118,7 @@ void kore() {
|
||||||
|
|
||||||
float dotNL = 0.0;
|
float dotNL = 0.0;
|
||||||
#ifdef _NormalMapping
|
#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);
|
dotNL = clamp(dot(tn, l), 0.0, 1.0);
|
||||||
#else
|
#else
|
||||||
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
||||||
|
@ -129,13 +130,16 @@ void kore() {
|
||||||
outColor = vec4(vec3(rgb * visibility), 1.0);
|
outColor = vec4(vec3(rgb * visibility), 1.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
outColor = vec4(t, 1.0);
|
outColor = vec4(t * visibility, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _Texturing
|
#ifdef _Texturing
|
||||||
vec4 texel = texture2D(stex, texCoord);
|
vec4 texel = texture2D(stex, texCoord);
|
||||||
//if(texel.a < 0.4)
|
|
||||||
// discard;
|
#ifdef _AlphaTest
|
||||||
|
if(texel.a < 0.4)
|
||||||
|
discard;
|
||||||
|
#endif
|
||||||
|
|
||||||
outColor = vec4(texel * outColor);
|
outColor = vec4(texel * outColor);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -74,10 +74,12 @@ void kore() {
|
||||||
eyeDir = normalize(eye - position);
|
eyeDir = normalize(eye - position);
|
||||||
|
|
||||||
#ifdef _NormalMapping
|
#ifdef _NormalMapping
|
||||||
vec3 vTangent = tan;
|
vec3 vTangent = (tan);
|
||||||
vec3 vBitangent = bitan;
|
vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w;
|
||||||
|
//vec3 vBitangent = (bitan);
|
||||||
|
|
||||||
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
||||||
|
//mat3 TBN = (mat3(vTangent, vBitangent, normal));
|
||||||
lightDir = normalize(TBN * lightDir);
|
lightDir = normalize(TBN * lightDir);
|
||||||
eyeDir = normalize(TBN * eyeDir);
|
eyeDir = normalize(TBN * eyeDir);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -42,6 +42,7 @@ float shadowSimple(vec4 lPos) {
|
||||||
|
|
||||||
float distanceFromLight = packedZValue.z;
|
float distanceFromLight = packedZValue.z;
|
||||||
|
|
||||||
|
//float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01);
|
||||||
float bias = 0.0;//0.0005;
|
float bias = 0.0;//0.0005;
|
||||||
|
|
||||||
// 1.0 = not in shadow, 0.0 = in shadow
|
// 1.0 = not in shadow, 0.0 = in shadow
|
||||||
|
@ -118,7 +119,7 @@ void kore() {
|
||||||
|
|
||||||
float dotNL = 0.0;
|
float dotNL = 0.0;
|
||||||
#ifdef _NormalMapping
|
#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);
|
dotNL = clamp(dot(tn, l), 0.0, 1.0);
|
||||||
#else
|
#else
|
||||||
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
||||||
|
@ -130,13 +131,16 @@ void kore() {
|
||||||
outColor = vec4(vec3(rgb * visibility), 1.0);
|
outColor = vec4(vec3(rgb * visibility), 1.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
outColor = vec4(t, 1.0);
|
outColor = vec4(t * visibility, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _Texturing
|
#ifdef _Texturing
|
||||||
vec4 texel = texture2D(stex, texCoord);
|
vec4 texel = texture2D(stex, texCoord);
|
||||||
//if(texel.a < 0.4)
|
|
||||||
// discard;
|
#ifdef _AlphaTest
|
||||||
|
if(texel.a < 0.4)
|
||||||
|
discard;
|
||||||
|
#endif
|
||||||
|
|
||||||
outColor = vec4(texel * outColor);
|
outColor = vec4(texel * outColor);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -75,10 +75,12 @@ void kore() {
|
||||||
eyeDir = normalize(eye - position);
|
eyeDir = normalize(eye - position);
|
||||||
|
|
||||||
#ifdef _NormalMapping
|
#ifdef _NormalMapping
|
||||||
vec3 vTangent = tan;
|
vec3 vTangent = (tan);
|
||||||
vec3 vBitangent = bitan;
|
vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w;
|
||||||
|
//vec3 vBitangent = (bitan);
|
||||||
|
|
||||||
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
||||||
|
//mat3 TBN = (mat3(vTangent, vBitangent, normal));
|
||||||
lightDir = normalize(TBN * lightDir);
|
lightDir = normalize(TBN * lightDir);
|
||||||
eyeDir = normalize(TBN * eyeDir);
|
eyeDir = normalize(TBN * eyeDir);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -43,6 +43,7 @@ float shadowSimple(vec4 lPos) {
|
||||||
|
|
||||||
float distanceFromLight = packedZValue.z;
|
float distanceFromLight = packedZValue.z;
|
||||||
|
|
||||||
|
//float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01);
|
||||||
float bias = 0.0;//0.0005;
|
float bias = 0.0;//0.0005;
|
||||||
|
|
||||||
// 1.0 = not in shadow, 0.0 = in shadow
|
// 1.0 = not in shadow, 0.0 = in shadow
|
||||||
|
@ -119,7 +120,7 @@ void kore() {
|
||||||
|
|
||||||
float dotNL = 0.0;
|
float dotNL = 0.0;
|
||||||
#ifdef _NormalMapping
|
#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);
|
dotNL = clamp(dot(tn, l), 0.0, 1.0);
|
||||||
#else
|
#else
|
||||||
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
||||||
|
@ -131,13 +132,16 @@ void kore() {
|
||||||
outColor = vec4(vec3(rgb * visibility), 1.0);
|
outColor = vec4(vec3(rgb * visibility), 1.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
outColor = vec4(t, 1.0);
|
outColor = vec4(t * visibility, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _Texturing
|
#ifdef _Texturing
|
||||||
vec4 texel = texture2D(stex, texCoord);
|
vec4 texel = texture2D(stex, texCoord);
|
||||||
//if(texel.a < 0.4)
|
|
||||||
// discard;
|
#ifdef _AlphaTest
|
||||||
|
if(texel.a < 0.4)
|
||||||
|
discard;
|
||||||
|
#endif
|
||||||
|
|
||||||
outColor = vec4(texel * outColor);
|
outColor = vec4(texel * outColor);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -76,10 +76,12 @@ void kore() {
|
||||||
eyeDir = normalize(eye - position);
|
eyeDir = normalize(eye - position);
|
||||||
|
|
||||||
#ifdef _NormalMapping
|
#ifdef _NormalMapping
|
||||||
vec3 vTangent = tan;
|
vec3 vTangent = (tan);
|
||||||
vec3 vBitangent = bitan;
|
vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w;
|
||||||
|
//vec3 vBitangent = (bitan);
|
||||||
|
|
||||||
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
||||||
|
//mat3 TBN = (mat3(vTangent, vBitangent, normal));
|
||||||
lightDir = normalize(TBN * lightDir);
|
lightDir = normalize(TBN * lightDir);
|
||||||
eyeDir = normalize(TBN * eyeDir);
|
eyeDir = normalize(TBN * eyeDir);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -42,6 +42,7 @@ float shadowSimple(vec4 lPos) {
|
||||||
|
|
||||||
float distanceFromLight = packedZValue.z;
|
float distanceFromLight = packedZValue.z;
|
||||||
|
|
||||||
|
//float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01);
|
||||||
float bias = 0.0;//0.0005;
|
float bias = 0.0;//0.0005;
|
||||||
|
|
||||||
// 1.0 = not in shadow, 0.0 = in shadow
|
// 1.0 = not in shadow, 0.0 = in shadow
|
||||||
|
@ -118,7 +119,7 @@ void kore() {
|
||||||
|
|
||||||
float dotNL = 0.0;
|
float dotNL = 0.0;
|
||||||
#ifdef _NormalMapping
|
#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);
|
dotNL = clamp(dot(tn, l), 0.0, 1.0);
|
||||||
#else
|
#else
|
||||||
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
||||||
|
@ -130,13 +131,16 @@ void kore() {
|
||||||
outColor = vec4(vec3(rgb * visibility), 1.0);
|
outColor = vec4(vec3(rgb * visibility), 1.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
outColor = vec4(t, 1.0);
|
outColor = vec4(t * visibility, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _Texturing
|
#ifdef _Texturing
|
||||||
vec4 texel = texture2D(stex, texCoord);
|
vec4 texel = texture2D(stex, texCoord);
|
||||||
//if(texel.a < 0.4)
|
|
||||||
// discard;
|
#ifdef _AlphaTest
|
||||||
|
if(texel.a < 0.4)
|
||||||
|
discard;
|
||||||
|
#endif
|
||||||
|
|
||||||
outColor = vec4(texel * outColor);
|
outColor = vec4(texel * outColor);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -75,10 +75,12 @@ void kore() {
|
||||||
eyeDir = normalize(eye - position);
|
eyeDir = normalize(eye - position);
|
||||||
|
|
||||||
#ifdef _NormalMapping
|
#ifdef _NormalMapping
|
||||||
vec3 vTangent = tan;
|
vec3 vTangent = (tan);
|
||||||
vec3 vBitangent = bitan;
|
vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w;
|
||||||
|
//vec3 vBitangent = (bitan);
|
||||||
|
|
||||||
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
||||||
|
//mat3 TBN = (mat3(vTangent, vBitangent, normal));
|
||||||
lightDir = normalize(TBN * lightDir);
|
lightDir = normalize(TBN * lightDir);
|
||||||
eyeDir = normalize(TBN * eyeDir);
|
eyeDir = normalize(TBN * eyeDir);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -41,6 +41,7 @@ float shadowSimple(vec4 lPos) {
|
||||||
|
|
||||||
float distanceFromLight = packedZValue.z;
|
float distanceFromLight = packedZValue.z;
|
||||||
|
|
||||||
|
//float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01);
|
||||||
float bias = 0.0;//0.0005;
|
float bias = 0.0;//0.0005;
|
||||||
|
|
||||||
// 1.0 = not in shadow, 0.0 = in shadow
|
// 1.0 = not in shadow, 0.0 = in shadow
|
||||||
|
@ -117,7 +118,7 @@ void kore() {
|
||||||
|
|
||||||
float dotNL = 0.0;
|
float dotNL = 0.0;
|
||||||
#ifdef _NormalMapping
|
#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);
|
dotNL = clamp(dot(tn, l), 0.0, 1.0);
|
||||||
#else
|
#else
|
||||||
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
||||||
|
@ -129,13 +130,16 @@ void kore() {
|
||||||
outColor = vec4(vec3(rgb * visibility), 1.0);
|
outColor = vec4(vec3(rgb * visibility), 1.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
outColor = vec4(t, 1.0);
|
outColor = vec4(t * visibility, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _Texturing
|
#ifdef _Texturing
|
||||||
vec4 texel = texture2D(stex, texCoord);
|
vec4 texel = texture2D(stex, texCoord);
|
||||||
//if(texel.a < 0.4)
|
|
||||||
// discard;
|
#ifdef _AlphaTest
|
||||||
|
if(texel.a < 0.4)
|
||||||
|
discard;
|
||||||
|
#endif
|
||||||
|
|
||||||
outColor = vec4(texel * outColor);
|
outColor = vec4(texel * outColor);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -74,10 +74,12 @@ void kore() {
|
||||||
eyeDir = normalize(eye - position);
|
eyeDir = normalize(eye - position);
|
||||||
|
|
||||||
#ifdef _NormalMapping
|
#ifdef _NormalMapping
|
||||||
vec3 vTangent = tan;
|
vec3 vTangent = (tan);
|
||||||
vec3 vBitangent = bitan;
|
vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w;
|
||||||
|
//vec3 vBitangent = (bitan);
|
||||||
|
|
||||||
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
||||||
|
//mat3 TBN = (mat3(vTangent, vBitangent, normal));
|
||||||
lightDir = normalize(TBN * lightDir);
|
lightDir = normalize(TBN * lightDir);
|
||||||
eyeDir = normalize(TBN * eyeDir);
|
eyeDir = normalize(TBN * eyeDir);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -42,6 +42,7 @@ float shadowSimple(vec4 lPos) {
|
||||||
|
|
||||||
float distanceFromLight = packedZValue.z;
|
float distanceFromLight = packedZValue.z;
|
||||||
|
|
||||||
|
//float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01);
|
||||||
float bias = 0.0;//0.0005;
|
float bias = 0.0;//0.0005;
|
||||||
|
|
||||||
// 1.0 = not in shadow, 0.0 = in shadow
|
// 1.0 = not in shadow, 0.0 = in shadow
|
||||||
|
@ -118,7 +119,7 @@ void kore() {
|
||||||
|
|
||||||
float dotNL = 0.0;
|
float dotNL = 0.0;
|
||||||
#ifdef _NormalMapping
|
#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);
|
dotNL = clamp(dot(tn, l), 0.0, 1.0);
|
||||||
#else
|
#else
|
||||||
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
||||||
|
@ -130,13 +131,16 @@ void kore() {
|
||||||
outColor = vec4(vec3(rgb * visibility), 1.0);
|
outColor = vec4(vec3(rgb * visibility), 1.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
outColor = vec4(t, 1.0);
|
outColor = vec4(t * visibility, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _Texturing
|
#ifdef _Texturing
|
||||||
vec4 texel = texture2D(stex, texCoord);
|
vec4 texel = texture2D(stex, texCoord);
|
||||||
//if(texel.a < 0.4)
|
|
||||||
// discard;
|
#ifdef _AlphaTest
|
||||||
|
if(texel.a < 0.4)
|
||||||
|
discard;
|
||||||
|
#endif
|
||||||
|
|
||||||
outColor = vec4(texel * outColor);
|
outColor = vec4(texel * outColor);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -75,10 +75,12 @@ void kore() {
|
||||||
eyeDir = normalize(eye - position);
|
eyeDir = normalize(eye - position);
|
||||||
|
|
||||||
#ifdef _NormalMapping
|
#ifdef _NormalMapping
|
||||||
vec3 vTangent = tan;
|
vec3 vTangent = (tan);
|
||||||
vec3 vBitangent = bitan;
|
vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w;
|
||||||
|
//vec3 vBitangent = (bitan);
|
||||||
|
|
||||||
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
||||||
|
//mat3 TBN = (mat3(vTangent, vBitangent, normal));
|
||||||
lightDir = normalize(TBN * lightDir);
|
lightDir = normalize(TBN * lightDir);
|
||||||
eyeDir = normalize(TBN * eyeDir);
|
eyeDir = normalize(TBN * eyeDir);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -41,6 +41,7 @@ float shadowSimple(vec4 lPos) {
|
||||||
|
|
||||||
float distanceFromLight = packedZValue.z;
|
float distanceFromLight = packedZValue.z;
|
||||||
|
|
||||||
|
//float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01);
|
||||||
float bias = 0.0;//0.0005;
|
float bias = 0.0;//0.0005;
|
||||||
|
|
||||||
// 1.0 = not in shadow, 0.0 = in shadow
|
// 1.0 = not in shadow, 0.0 = in shadow
|
||||||
|
@ -117,7 +118,7 @@ void kore() {
|
||||||
|
|
||||||
float dotNL = 0.0;
|
float dotNL = 0.0;
|
||||||
#ifdef _NormalMapping
|
#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);
|
dotNL = clamp(dot(tn, l), 0.0, 1.0);
|
||||||
#else
|
#else
|
||||||
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
||||||
|
@ -129,13 +130,16 @@ void kore() {
|
||||||
outColor = vec4(vec3(rgb * visibility), 1.0);
|
outColor = vec4(vec3(rgb * visibility), 1.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
outColor = vec4(t, 1.0);
|
outColor = vec4(t * visibility, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _Texturing
|
#ifdef _Texturing
|
||||||
vec4 texel = texture2D(stex, texCoord);
|
vec4 texel = texture2D(stex, texCoord);
|
||||||
//if(texel.a < 0.4)
|
|
||||||
// discard;
|
#ifdef _AlphaTest
|
||||||
|
if(texel.a < 0.4)
|
||||||
|
discard;
|
||||||
|
#endif
|
||||||
|
|
||||||
outColor = vec4(texel * outColor);
|
outColor = vec4(texel * outColor);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -74,10 +74,12 @@ void kore() {
|
||||||
eyeDir = normalize(eye - position);
|
eyeDir = normalize(eye - position);
|
||||||
|
|
||||||
#ifdef _NormalMapping
|
#ifdef _NormalMapping
|
||||||
vec3 vTangent = tan;
|
vec3 vTangent = (tan);
|
||||||
vec3 vBitangent = bitan;
|
vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w;
|
||||||
|
//vec3 vBitangent = (bitan);
|
||||||
|
|
||||||
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
||||||
|
//mat3 TBN = (mat3(vTangent, vBitangent, normal));
|
||||||
lightDir = normalize(TBN * lightDir);
|
lightDir = normalize(TBN * lightDir);
|
||||||
eyeDir = normalize(TBN * eyeDir);
|
eyeDir = normalize(TBN * eyeDir);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,6 +40,7 @@ float shadowSimple(vec4 lPos) {
|
||||||
|
|
||||||
float distanceFromLight = packedZValue.z;
|
float distanceFromLight = packedZValue.z;
|
||||||
|
|
||||||
|
//float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01);
|
||||||
float bias = 0.0;//0.0005;
|
float bias = 0.0;//0.0005;
|
||||||
|
|
||||||
// 1.0 = not in shadow, 0.0 = in shadow
|
// 1.0 = not in shadow, 0.0 = in shadow
|
||||||
|
@ -116,7 +117,7 @@ void kore() {
|
||||||
|
|
||||||
float dotNL = 0.0;
|
float dotNL = 0.0;
|
||||||
#ifdef _NormalMapping
|
#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);
|
dotNL = clamp(dot(tn, l), 0.0, 1.0);
|
||||||
#else
|
#else
|
||||||
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
||||||
|
@ -128,13 +129,16 @@ void kore() {
|
||||||
outColor = vec4(vec3(rgb * visibility), 1.0);
|
outColor = vec4(vec3(rgb * visibility), 1.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
outColor = vec4(t, 1.0);
|
outColor = vec4(t * visibility, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _Texturing
|
#ifdef _Texturing
|
||||||
vec4 texel = texture2D(stex, texCoord);
|
vec4 texel = texture2D(stex, texCoord);
|
||||||
//if(texel.a < 0.4)
|
|
||||||
// discard;
|
#ifdef _AlphaTest
|
||||||
|
if(texel.a < 0.4)
|
||||||
|
discard;
|
||||||
|
#endif
|
||||||
|
|
||||||
outColor = vec4(texel * outColor);
|
outColor = vec4(texel * outColor);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -73,10 +73,12 @@ void kore() {
|
||||||
eyeDir = normalize(eye - position);
|
eyeDir = normalize(eye - position);
|
||||||
|
|
||||||
#ifdef _NormalMapping
|
#ifdef _NormalMapping
|
||||||
vec3 vTangent = tan;
|
vec3 vTangent = (tan);
|
||||||
vec3 vBitangent = bitan;
|
vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w;
|
||||||
|
//vec3 vBitangent = (bitan);
|
||||||
|
|
||||||
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
||||||
|
//mat3 TBN = (mat3(vTangent, vBitangent, normal));
|
||||||
lightDir = normalize(TBN * lightDir);
|
lightDir = normalize(TBN * lightDir);
|
||||||
eyeDir = normalize(TBN * eyeDir);
|
eyeDir = normalize(TBN * eyeDir);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -41,6 +41,7 @@ float shadowSimple(vec4 lPos) {
|
||||||
|
|
||||||
float distanceFromLight = packedZValue.z;
|
float distanceFromLight = packedZValue.z;
|
||||||
|
|
||||||
|
//float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01);
|
||||||
float bias = 0.0;//0.0005;
|
float bias = 0.0;//0.0005;
|
||||||
|
|
||||||
// 1.0 = not in shadow, 0.0 = in shadow
|
// 1.0 = not in shadow, 0.0 = in shadow
|
||||||
|
@ -117,7 +118,7 @@ void kore() {
|
||||||
|
|
||||||
float dotNL = 0.0;
|
float dotNL = 0.0;
|
||||||
#ifdef _NormalMapping
|
#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);
|
dotNL = clamp(dot(tn, l), 0.0, 1.0);
|
||||||
#else
|
#else
|
||||||
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
||||||
|
@ -129,13 +130,16 @@ void kore() {
|
||||||
outColor = vec4(vec3(rgb * visibility), 1.0);
|
outColor = vec4(vec3(rgb * visibility), 1.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
outColor = vec4(t, 1.0);
|
outColor = vec4(t * visibility, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _Texturing
|
#ifdef _Texturing
|
||||||
vec4 texel = texture2D(stex, texCoord);
|
vec4 texel = texture2D(stex, texCoord);
|
||||||
//if(texel.a < 0.4)
|
|
||||||
// discard;
|
#ifdef _AlphaTest
|
||||||
|
if(texel.a < 0.4)
|
||||||
|
discard;
|
||||||
|
#endif
|
||||||
|
|
||||||
outColor = vec4(texel * outColor);
|
outColor = vec4(texel * outColor);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -74,10 +74,12 @@ void kore() {
|
||||||
eyeDir = normalize(eye - position);
|
eyeDir = normalize(eye - position);
|
||||||
|
|
||||||
#ifdef _NormalMapping
|
#ifdef _NormalMapping
|
||||||
vec3 vTangent = tan;
|
vec3 vTangent = (tan);
|
||||||
vec3 vBitangent = bitan;
|
vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w;
|
||||||
|
//vec3 vBitangent = (bitan);
|
||||||
|
|
||||||
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
||||||
|
//mat3 TBN = (mat3(vTangent, vBitangent, normal));
|
||||||
lightDir = normalize(TBN * lightDir);
|
lightDir = normalize(TBN * lightDir);
|
||||||
eyeDir = normalize(TBN * eyeDir);
|
eyeDir = normalize(TBN * eyeDir);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -42,6 +42,7 @@ float shadowSimple(vec4 lPos) {
|
||||||
|
|
||||||
float distanceFromLight = packedZValue.z;
|
float distanceFromLight = packedZValue.z;
|
||||||
|
|
||||||
|
//float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01);
|
||||||
float bias = 0.0;//0.0005;
|
float bias = 0.0;//0.0005;
|
||||||
|
|
||||||
// 1.0 = not in shadow, 0.0 = in shadow
|
// 1.0 = not in shadow, 0.0 = in shadow
|
||||||
|
@ -118,7 +119,7 @@ void kore() {
|
||||||
|
|
||||||
float dotNL = 0.0;
|
float dotNL = 0.0;
|
||||||
#ifdef _NormalMapping
|
#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);
|
dotNL = clamp(dot(tn, l), 0.0, 1.0);
|
||||||
#else
|
#else
|
||||||
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
||||||
|
@ -130,13 +131,16 @@ void kore() {
|
||||||
outColor = vec4(vec3(rgb * visibility), 1.0);
|
outColor = vec4(vec3(rgb * visibility), 1.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
outColor = vec4(t, 1.0);
|
outColor = vec4(t * visibility, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _Texturing
|
#ifdef _Texturing
|
||||||
vec4 texel = texture2D(stex, texCoord);
|
vec4 texel = texture2D(stex, texCoord);
|
||||||
//if(texel.a < 0.4)
|
|
||||||
// discard;
|
#ifdef _AlphaTest
|
||||||
|
if(texel.a < 0.4)
|
||||||
|
discard;
|
||||||
|
#endif
|
||||||
|
|
||||||
outColor = vec4(texel * outColor);
|
outColor = vec4(texel * outColor);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -75,10 +75,12 @@ void kore() {
|
||||||
eyeDir = normalize(eye - position);
|
eyeDir = normalize(eye - position);
|
||||||
|
|
||||||
#ifdef _NormalMapping
|
#ifdef _NormalMapping
|
||||||
vec3 vTangent = tan;
|
vec3 vTangent = (tan);
|
||||||
vec3 vBitangent = bitan;
|
vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w;
|
||||||
|
//vec3 vBitangent = (bitan);
|
||||||
|
|
||||||
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
||||||
|
//mat3 TBN = (mat3(vTangent, vBitangent, normal));
|
||||||
lightDir = normalize(TBN * lightDir);
|
lightDir = normalize(TBN * lightDir);
|
||||||
eyeDir = normalize(TBN * eyeDir);
|
eyeDir = normalize(TBN * eyeDir);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -41,6 +41,7 @@ float shadowSimple(vec4 lPos) {
|
||||||
|
|
||||||
float distanceFromLight = packedZValue.z;
|
float distanceFromLight = packedZValue.z;
|
||||||
|
|
||||||
|
//float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01);
|
||||||
float bias = 0.0;//0.0005;
|
float bias = 0.0;//0.0005;
|
||||||
|
|
||||||
// 1.0 = not in shadow, 0.0 = in shadow
|
// 1.0 = not in shadow, 0.0 = in shadow
|
||||||
|
@ -117,7 +118,7 @@ void kore() {
|
||||||
|
|
||||||
float dotNL = 0.0;
|
float dotNL = 0.0;
|
||||||
#ifdef _NormalMapping
|
#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);
|
dotNL = clamp(dot(tn, l), 0.0, 1.0);
|
||||||
#else
|
#else
|
||||||
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
||||||
|
@ -129,13 +130,16 @@ void kore() {
|
||||||
outColor = vec4(vec3(rgb * visibility), 1.0);
|
outColor = vec4(vec3(rgb * visibility), 1.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
outColor = vec4(t, 1.0);
|
outColor = vec4(t * visibility, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _Texturing
|
#ifdef _Texturing
|
||||||
vec4 texel = texture2D(stex, texCoord);
|
vec4 texel = texture2D(stex, texCoord);
|
||||||
//if(texel.a < 0.4)
|
|
||||||
// discard;
|
#ifdef _AlphaTest
|
||||||
|
if(texel.a < 0.4)
|
||||||
|
discard;
|
||||||
|
#endif
|
||||||
|
|
||||||
outColor = vec4(texel * outColor);
|
outColor = vec4(texel * outColor);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -74,10 +74,12 @@ void kore() {
|
||||||
eyeDir = normalize(eye - position);
|
eyeDir = normalize(eye - position);
|
||||||
|
|
||||||
#ifdef _NormalMapping
|
#ifdef _NormalMapping
|
||||||
vec3 vTangent = tan;
|
vec3 vTangent = (tan);
|
||||||
vec3 vBitangent = bitan;
|
vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w;
|
||||||
|
//vec3 vBitangent = (bitan);
|
||||||
|
|
||||||
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
||||||
|
//mat3 TBN = (mat3(vTangent, vBitangent, normal));
|
||||||
lightDir = normalize(TBN * lightDir);
|
lightDir = normalize(TBN * lightDir);
|
||||||
eyeDir = normalize(TBN * eyeDir);
|
eyeDir = normalize(TBN * eyeDir);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,6 +40,7 @@ float shadowSimple(vec4 lPos) {
|
||||||
|
|
||||||
float distanceFromLight = packedZValue.z;
|
float distanceFromLight = packedZValue.z;
|
||||||
|
|
||||||
|
//float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01);
|
||||||
float bias = 0.0;//0.0005;
|
float bias = 0.0;//0.0005;
|
||||||
|
|
||||||
// 1.0 = not in shadow, 0.0 = in shadow
|
// 1.0 = not in shadow, 0.0 = in shadow
|
||||||
|
@ -116,7 +117,7 @@ void kore() {
|
||||||
|
|
||||||
float dotNL = 0.0;
|
float dotNL = 0.0;
|
||||||
#ifdef _NormalMapping
|
#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);
|
dotNL = clamp(dot(tn, l), 0.0, 1.0);
|
||||||
#else
|
#else
|
||||||
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
||||||
|
@ -128,13 +129,16 @@ void kore() {
|
||||||
outColor = vec4(vec3(rgb * visibility), 1.0);
|
outColor = vec4(vec3(rgb * visibility), 1.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
outColor = vec4(t, 1.0);
|
outColor = vec4(t * visibility, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _Texturing
|
#ifdef _Texturing
|
||||||
vec4 texel = texture2D(stex, texCoord);
|
vec4 texel = texture2D(stex, texCoord);
|
||||||
//if(texel.a < 0.4)
|
|
||||||
// discard;
|
#ifdef _AlphaTest
|
||||||
|
if(texel.a < 0.4)
|
||||||
|
discard;
|
||||||
|
#endif
|
||||||
|
|
||||||
outColor = vec4(texel * outColor);
|
outColor = vec4(texel * outColor);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -73,10 +73,12 @@ void kore() {
|
||||||
eyeDir = normalize(eye - position);
|
eyeDir = normalize(eye - position);
|
||||||
|
|
||||||
#ifdef _NormalMapping
|
#ifdef _NormalMapping
|
||||||
vec3 vTangent = tan;
|
vec3 vTangent = (tan);
|
||||||
vec3 vBitangent = bitan;
|
vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w;
|
||||||
|
//vec3 vBitangent = (bitan);
|
||||||
|
|
||||||
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
||||||
|
//mat3 TBN = (mat3(vTangent, vBitangent, normal));
|
||||||
lightDir = normalize(TBN * lightDir);
|
lightDir = normalize(TBN * lightDir);
|
||||||
eyeDir = normalize(TBN * eyeDir);
|
eyeDir = normalize(TBN * eyeDir);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -41,6 +41,7 @@ float shadowSimple(vec4 lPos) {
|
||||||
|
|
||||||
float distanceFromLight = packedZValue.z;
|
float distanceFromLight = packedZValue.z;
|
||||||
|
|
||||||
|
//float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01);
|
||||||
float bias = 0.0;//0.0005;
|
float bias = 0.0;//0.0005;
|
||||||
|
|
||||||
// 1.0 = not in shadow, 0.0 = in shadow
|
// 1.0 = not in shadow, 0.0 = in shadow
|
||||||
|
@ -117,7 +118,7 @@ void kore() {
|
||||||
|
|
||||||
float dotNL = 0.0;
|
float dotNL = 0.0;
|
||||||
#ifdef _NormalMapping
|
#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);
|
dotNL = clamp(dot(tn, l), 0.0, 1.0);
|
||||||
#else
|
#else
|
||||||
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
||||||
|
@ -129,13 +130,16 @@ void kore() {
|
||||||
outColor = vec4(vec3(rgb * visibility), 1.0);
|
outColor = vec4(vec3(rgb * visibility), 1.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
outColor = vec4(t, 1.0);
|
outColor = vec4(t * visibility, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _Texturing
|
#ifdef _Texturing
|
||||||
vec4 texel = texture2D(stex, texCoord);
|
vec4 texel = texture2D(stex, texCoord);
|
||||||
//if(texel.a < 0.4)
|
|
||||||
// discard;
|
#ifdef _AlphaTest
|
||||||
|
if(texel.a < 0.4)
|
||||||
|
discard;
|
||||||
|
#endif
|
||||||
|
|
||||||
outColor = vec4(texel * outColor);
|
outColor = vec4(texel * outColor);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -74,10 +74,12 @@ void kore() {
|
||||||
eyeDir = normalize(eye - position);
|
eyeDir = normalize(eye - position);
|
||||||
|
|
||||||
#ifdef _NormalMapping
|
#ifdef _NormalMapping
|
||||||
vec3 vTangent = tan;
|
vec3 vTangent = (tan);
|
||||||
vec3 vBitangent = bitan;
|
vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w;
|
||||||
|
//vec3 vBitangent = (bitan);
|
||||||
|
|
||||||
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
||||||
|
//mat3 TBN = (mat3(vTangent, vBitangent, normal));
|
||||||
lightDir = normalize(TBN * lightDir);
|
lightDir = normalize(TBN * lightDir);
|
||||||
eyeDir = normalize(TBN * eyeDir);
|
eyeDir = normalize(TBN * eyeDir);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,6 +40,7 @@ float shadowSimple(vec4 lPos) {
|
||||||
|
|
||||||
float distanceFromLight = packedZValue.z;
|
float distanceFromLight = packedZValue.z;
|
||||||
|
|
||||||
|
//float bias = clamp(0.005*tan(acos(dotNL)), 0, 0.01);
|
||||||
float bias = 0.0;//0.0005;
|
float bias = 0.0;//0.0005;
|
||||||
|
|
||||||
// 1.0 = not in shadow, 0.0 = in shadow
|
// 1.0 = not in shadow, 0.0 = in shadow
|
||||||
|
@ -116,7 +117,7 @@ void kore() {
|
||||||
|
|
||||||
float dotNL = 0.0;
|
float dotNL = 0.0;
|
||||||
#ifdef _NormalMapping
|
#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);
|
dotNL = clamp(dot(tn, l), 0.0, 1.0);
|
||||||
#else
|
#else
|
||||||
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
dotNL = clamp(dot(n, l), 0.0, 1.0);
|
||||||
|
@ -128,13 +129,16 @@ void kore() {
|
||||||
outColor = vec4(vec3(rgb * visibility), 1.0);
|
outColor = vec4(vec3(rgb * visibility), 1.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
outColor = vec4(t, 1.0);
|
outColor = vec4(t * visibility, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _Texturing
|
#ifdef _Texturing
|
||||||
vec4 texel = texture2D(stex, texCoord);
|
vec4 texel = texture2D(stex, texCoord);
|
||||||
//if(texel.a < 0.4)
|
|
||||||
// discard;
|
#ifdef _AlphaTest
|
||||||
|
if(texel.a < 0.4)
|
||||||
|
discard;
|
||||||
|
#endif
|
||||||
|
|
||||||
outColor = vec4(texel * outColor);
|
outColor = vec4(texel * outColor);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -73,10 +73,12 @@ void kore() {
|
||||||
eyeDir = normalize(eye - position);
|
eyeDir = normalize(eye - position);
|
||||||
|
|
||||||
#ifdef _NormalMapping
|
#ifdef _NormalMapping
|
||||||
vec3 vTangent = tan;
|
vec3 vTangent = (tan);
|
||||||
vec3 vBitangent = bitan;
|
vec3 vBitangent = cross( normal, vTangent ) * 1.0;//tangent.w;
|
||||||
|
//vec3 vBitangent = (bitan);
|
||||||
|
|
||||||
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
mat3 TBN = transpose(mat3(vTangent, vBitangent, normal));
|
||||||
|
//mat3 TBN = (mat3(vTangent, vBitangent, normal));
|
||||||
lightDir = normalize(TBN * lightDir);
|
lightDir = normalize(TBN * lightDir);
|
||||||
eyeDir = normalize(TBN * eyeDir);
|
eyeDir = normalize(TBN * eyeDir);
|
||||||
#endif
|
#endif
|
||||||
|
|
19
Sources/Shaders/shadow_map_AlphaTest.frag.glsl
Normal file
19
Sources/Shaders/shadow_map_AlphaTest.frag.glsl
Normal file
|
@ -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);
|
||||||
|
}
|
40
Sources/Shaders/shadow_map_AlphaTest.vert.glsl
Normal file
40
Sources/Shaders/shadow_map_AlphaTest.vert.glsl
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
20
Sources/Shaders/shadow_map_AlphaTest_Instancing.frag.glsl
Normal file
20
Sources/Shaders/shadow_map_AlphaTest_Instancing.frag.glsl
Normal file
|
@ -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);
|
||||||
|
}
|
41
Sources/Shaders/shadow_map_AlphaTest_Instancing.vert.glsl
Normal file
41
Sources/Shaders/shadow_map_AlphaTest_Instancing.vert.glsl
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
20
Sources/Shaders/shadow_map_AlphaTest_NormalMapping.frag.glsl
Normal file
20
Sources/Shaders/shadow_map_AlphaTest_NormalMapping.frag.glsl
Normal file
|
@ -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);
|
||||||
|
}
|
41
Sources/Shaders/shadow_map_AlphaTest_NormalMapping.vert.glsl
Normal file
41
Sources/Shaders/shadow_map_AlphaTest_NormalMapping.vert.glsl
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
20
Sources/Shaders/shadow_map_AlphaTest_Texturing.frag.glsl
Normal file
20
Sources/Shaders/shadow_map_AlphaTest_Texturing.frag.glsl
Normal file
|
@ -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);
|
||||||
|
}
|
41
Sources/Shaders/shadow_map_AlphaTest_Texturing.vert.glsl
Normal file
41
Sources/Shaders/shadow_map_AlphaTest_Texturing.vert.glsl
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
20
Sources/Shaders/shadow_map_AlphaTest_VCols.frag.glsl
Normal file
20
Sources/Shaders/shadow_map_AlphaTest_VCols.frag.glsl
Normal file
|
@ -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);
|
||||||
|
}
|
41
Sources/Shaders/shadow_map_AlphaTest_VCols.vert.glsl
Normal file
41
Sources/Shaders/shadow_map_AlphaTest_VCols.vert.glsl
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,8 @@ def build():
|
||||||
kha_path = output
|
kha_path = output
|
||||||
node_path = output + "/Tools/nodejs/node-osx"
|
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())
|
#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))
|
#print(subprocess.check_output([node_path + " " + kha_path + "/make -t html5 --haxe " + haxePath()], shell=True))
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ def initObjectProperties():
|
||||||
bpy.types.Object.geometry_cached = bpy.props.BoolProperty(name="Geometry cached", default=False)
|
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.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.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.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.append(cb_scene_update)
|
||||||
#bpy.app.handlers.scene_update_post.remove(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
|
mat = bpy.context.material
|
||||||
|
|
||||||
layout.prop(mat, 'receive_shadow')
|
layout.prop(mat, 'receive_shadow')
|
||||||
|
layout.prop(mat, 'alpha_test')
|
||||||
|
|
||||||
# Registration
|
# Registration
|
||||||
bpy.utils.register_module(__name__)
|
bpy.utils.register_module(__name__)
|
||||||
|
|
|
@ -1983,7 +1983,7 @@ class LueExporter(bpy.types.Operator, ExportHelper):
|
||||||
tree = material.node_tree
|
tree = material.node_tree
|
||||||
surface_node = self.findNodeByLink(tree, out_node, out_node.inputs[0])
|
surface_node = self.findNodeByLink(tree, out_node, out_node.inputs[0])
|
||||||
if surface_node.type == 'BSDF_DIFFUSE':
|
if surface_node.type == 'BSDF_DIFFUSE':
|
||||||
const3.bool = False # Enable lighting
|
const3.bool = True # Enable lighting
|
||||||
# Color
|
# Color
|
||||||
if surface_node.inputs[0].is_linked:
|
if surface_node.inputs[0].is_linked:
|
||||||
color_node = self.findNodeByLink(tree, surface_node, surface_node.inputs[0])
|
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)
|
o.contexts.append(c)
|
||||||
|
|
||||||
|
if material.alpha_test == True:
|
||||||
|
defs.append('_AlphaTest')
|
||||||
|
|
||||||
# Material users
|
# Material users
|
||||||
mat_users = []
|
mat_users = []
|
||||||
for ob in bpy.data.objects:
|
for ob in bpy.data.objects:
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue