Merge remote-tracking branch 'upstream/master' into new_login

This commit is contained in:
hiker 2014-02-16 15:11:50 +11:00
commit c2b4f42c93
118 changed files with 580 additions and 552 deletions

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
in vec2 uv; in vec2 uv;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform mat4 ModelViewMatrix; uniform mat4 ModelViewMatrix;
uniform mat4 ProjectionMatrix; uniform mat4 ProjectionMatrix;
uniform vec3 Position; uniform vec3 Position;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
uniform float low; uniform float low;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
in vec2 uv; in vec2 uv;

View File

@ -1,4 +1,4 @@
#version 130 #version 330 compatibility
uniform float power; uniform float power;
uniform sampler2D tex; uniform sampler2D tex;

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
uniform float transparency; uniform float transparency;
in vec2 uv; in vec2 uv;

View File

@ -17,7 +17,7 @@
// Creates a bubble (wave) effect by distorting the texture depending on time // Creates a bubble (wave) effect by distorting the texture depending on time
#version 130 #version 330
uniform mat4 ModelViewProjectionMatrix; uniform mat4 ModelViewProjectionMatrix;
uniform float time; uniform float time;

View File

@ -1,4 +1,4 @@
#version 130 #version 330 compatibility
uniform sampler2D tex; uniform sampler2D tex;
uniform sampler2D caustictex; uniform sampler2D caustictex;
uniform vec2 dir; uniform vec2 dir;

View File

@ -1,4 +1,4 @@
#version 130 #version 330 compatibility
uniform sampler2D tex; uniform sampler2D tex;
uniform sampler2D oldtex; uniform sampler2D oldtex;
uniform vec2 pixel; uniform vec2 pixel;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
uniform vec3 inlevel; uniform vec3 inlevel;
uniform vec2 outlevel; uniform vec2 outlevel;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform ivec4 color; uniform ivec4 color;
out vec4 FragColor; out vec4 FragColor;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform vec2 center; uniform vec2 center;
uniform vec2 size; uniform vec2 size;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform vec3 col; uniform vec3 col;
out vec4 FragColor; out vec4 FragColor;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
in vec2 uv; in vec2 uv;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform vec2 center; uniform vec2 center;
uniform vec2 size; uniform vec2 size;
uniform vec2 texcenter; uniform vec2 texcenter;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D Albedo; uniform sampler2D Albedo;
uniform sampler2D Detail; uniform sampler2D Detail;
uniform sampler2D DiffuseMap; uniform sampler2D DiffuseMap;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
uniform vec2 dir; uniform vec2 dir;
uniform vec2 dir2; uniform vec2 dir2;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform mat4 ModelViewProjectionMatrix; uniform mat4 ModelViewProjectionMatrix;
uniform mat4 ModelViewMatrix; uniform mat4 ModelViewMatrix;

View File

@ -1,4 +1,4 @@
#version 130 #version 330 compatibility
uniform mat4 ModelViewProjectionMatrix; uniform mat4 ModelViewProjectionMatrix;
void main() { void main() {

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform mat4 ProjectionMatrix; uniform mat4 ProjectionMatrix;
uniform mat4 ViewMatrix; uniform mat4 ViewMatrix;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
uniform float fogmax; uniform float fogmax;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
uniform vec2 pixel; uniform vec2 pixel;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
uniform vec2 pixel; uniform vec2 pixel;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
uniform vec2 pixel; uniform vec2 pixel;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
uniform vec2 pixel; uniform vec2 pixel;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
in vec2 uv; in vec2 uv;

View File

@ -1,4 +1,4 @@
#version 130 #version 330 compatibility
uniform sampler2D tex; uniform sampler2D tex;
uniform vec3 col; uniform vec3 col;
out vec4 FragColor; out vec4 FragColor;

View File

@ -1,4 +1,4 @@
#version 130 #version 330 compatibility
uniform sampler2D tex; uniform sampler2D tex;
uniform vec2 sunpos; uniform vec2 sunpos;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform vec3 windDir; uniform vec3 windDir;
uniform mat4 ModelViewProjectionMatrix; uniform mat4 ModelViewProjectionMatrix;
uniform mat4 TransposeInverseModelView; uniform mat4 TransposeInverseModelView;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform vec3 windDir; uniform vec3 windDir;
uniform mat4 ModelViewProjectionMatrix; uniform mat4 ModelViewProjectionMatrix;

View File

@ -1,4 +1,4 @@
#version 130 #version 330 compatibility
uniform sampler2D tex; uniform sampler2D tex;
uniform vec2 texsize; uniform vec2 texsize;

View File

@ -1,4 +1,4 @@
#version 130 #version 330 compatibility
#define MAX_SEARCH_STEPS 8.0 #define MAX_SEARCH_STEPS 8.0
#define MAX_DISTANCE 33.0 #define MAX_DISTANCE 33.0

View File

@ -1,4 +1,4 @@
#version 130 #version 330 compatibility
in vec4 offset[2]; in vec4 offset[2];
in vec2 uv; in vec2 uv;

View File

@ -1,4 +1,4 @@
#version 130 #version 330 compatibility
in vec4 offset[2]; in vec4 offset[2];
in vec2 uv; in vec2 uv;
out vec4 FragColor; out vec4 FragColor;

View File

@ -1,4 +1,4 @@
#version 130 #version 330 compatibility
uniform vec2 PIXEL_SIZE; uniform vec2 PIXEL_SIZE;
uniform mat4 ModelViewProjectionMatrix; uniform mat4 ModelViewProjectionMatrix;

View File

@ -21,7 +21,7 @@
// The actual boost amount (which linearly scales the blur to be shown). // The actual boost amount (which linearly scales the blur to be shown).
// should be in the range [0.0, 1.0], though a larger value might make // should be in the range [0.0, 1.0], though a larger value might make
// the blurring too string. Atm we are using [0, 0.5]. // the blurring too string. Atm we are using [0, 0.5].
#version 130 #version 330 compatibility
uniform float boost_amount; uniform float boost_amount;
// The color buffer to use. // The color buffer to use.

View File

@ -17,7 +17,7 @@
// motion_blur.vert // motion_blur.vert
#version 130 #version 330 compatibility
void main() void main()
{ {

View File

@ -1,4 +1,4 @@
#version 130 #version 330 compatibility
uniform sampler2D tex1; uniform sampler2D tex1;
uniform sampler2D tex2; uniform sampler2D tex2;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D normalMap; uniform sampler2D normalMap;
noperspective in vec3 tangent; noperspective in vec3 tangent;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform mat4 ModelViewProjectionMatrix; uniform mat4 ModelViewProjectionMatrix;
uniform mat4 TransposeInverseModelView; uniform mat4 TransposeInverseModelView;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
noperspective in vec3 nor; noperspective in vec3 nor;
out vec2 EncodedNormal; out vec2 EncodedNormal;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform mat4 ModelViewProjectionMatrix; uniform mat4 ModelViewProjectionMatrix;
uniform mat4 TransposeInverseModelView; uniform mat4 TransposeInverseModelView;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D Albedo; uniform sampler2D Albedo;
uniform sampler2D DiffuseMap; uniform sampler2D DiffuseMap;
uniform sampler2D SpecularMap; uniform sampler2D SpecularMap;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform mat4 ModelViewProjectionMatrix; uniform mat4 ModelViewProjectionMatrix;
in vec3 Position; in vec3 Position;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
in vec2 uv; in vec2 uv;
out vec4 FragColor; out vec4 FragColor;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
uniform sampler2D lighttex; uniform sampler2D lighttex;
uniform int hastex; uniform int hastex;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform mat4 ModelViewProjectionMatrix; uniform mat4 ModelViewProjectionMatrix;
uniform mat4 TransposeInverseModelView; uniform mat4 TransposeInverseModelView;
uniform mat4 TextureMatrix0; uniform mat4 TextureMatrix0;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
uniform int hastex; uniform int hastex;
uniform float objectid; uniform float objectid;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D Albedo; uniform sampler2D Albedo;
uniform sampler2D DiffuseMap; uniform sampler2D DiffuseMap;
uniform sampler2D SpecularMap; uniform sampler2D SpecularMap;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform mat4 ModelViewProjectionMatrix; uniform mat4 ModelViewProjectionMatrix;
uniform mat4 TransposeInverseModelView; uniform mat4 TransposeInverseModelView;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
noperspective in vec3 nor; noperspective in vec3 nor;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
noperspective in vec3 nor; noperspective in vec3 nor;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform mat4 ModelViewProjectionMatrix; uniform mat4 ModelViewProjectionMatrix;
uniform mat4 TransposeInverseModelView; uniform mat4 TransposeInverseModelView;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D Albedo; uniform sampler2D Albedo;
uniform sampler2D DiffuseMap; uniform sampler2D DiffuseMap;
uniform sampler2D SpecularMap; uniform sampler2D SpecularMap;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
uniform sampler2D dtex; uniform sampler2D dtex;
uniform mat4 invproj; uniform mat4 invproj;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform mat4 ProjectionMatrix; uniform mat4 ProjectionMatrix;
uniform mat4 ViewMatrix; uniform mat4 ViewMatrix;

View File

@ -1,4 +1,4 @@
#version 140 #version 330
uniform int dt; uniform int dt;
uniform mat4 sourcematrix; uniform mat4 sourcematrix;
uniform int level; uniform int level;

View File

@ -1,4 +1,4 @@
#version 130 #version 330 compatibility
uniform sampler2D tex; uniform sampler2D tex;
out vec4 FragColor; out vec4 FragColor;

View File

@ -1,5 +1,5 @@
// Passthrough shader for drawQuad() // Passthrough shader for drawQuad()
#version 130 #version 330 compatibility
out vec2 uv; out vec2 uv;

View File

@ -1,7 +1,8 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
uniform vec2 pixel; uniform vec2 pixel;
in vec2 uv;
out vec4 FragColor; out vec4 FragColor;
// Separated penumbra, horizontal // Separated penumbra, horizontal
@ -9,8 +10,8 @@ void main()
{ {
float sum = 0.0; float sum = 0.0;
vec4 tmp; vec4 tmp;
float X = gl_TexCoord[0].x; float X = uv.x;
float Y = gl_TexCoord[0].y; float Y = uv.y;
float width = 0.0; float width = 0.0;
float zsum = 0.00001; float zsum = 0.00001;

View File

@ -1,7 +1,8 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
uniform vec2 pixel; uniform vec2 pixel;
in vec2 uv;
out vec4 FragColor; out vec4 FragColor;
// Separated penumbra, vertical // Separated penumbra, vertical
@ -10,8 +11,8 @@ void main()
{ {
float sum = 0.0; float sum = 0.0;
vec4 tmp; vec4 tmp;
float X = gl_TexCoord[0].x; float X = uv.x;
float Y = gl_TexCoord[0].y; float Y = uv.y;
float width = 0.0; float width = 0.0;
float zsum = 0.00001; float zsum = 0.00001;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform int dt; uniform int dt;
uniform mat4 sourcematrix; uniform mat4 sourcematrix;
uniform int level; uniform int level;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D ntex; uniform sampler2D ntex;
uniform sampler2D dtex; uniform sampler2D dtex;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
uniform sampler2D dtex; uniform sampler2D dtex;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
uniform sampler2D normals_and_depth; uniform sampler2D normals_and_depth;
uniform mat4 invproj; uniform mat4 invproj;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform float screenw; uniform float screenw;
void main() void main()

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform float time; uniform float time;
uniform vec3 campos; uniform vec3 campos;
uniform mat4 viewm; uniform mat4 viewm;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
in vec2 Position; in vec2 Position;
in vec2 Texcoord; in vec2 Texcoord;

24
data/shaders/shadow.geom Normal file
View File

@ -0,0 +1,24 @@
#version 330
uniform mat4 ModelViewProjectionMatrix[4];
layout(triangles) in;
layout(triangle_strip, max_vertices=12) out;
in vec2 tc[3];
out vec2 uv;
void main(void)
{
for (int j = 0; j<4; j++)
{
gl_Layer = j;
for(int i=0; i<3; i++)
{
uv = tc[i];
gl_Position = ModelViewProjectionMatrix[j] * gl_in[i].gl_Position;
EmitVertex();
}
EndPrimitive();
}
}

14
data/shaders/shadow.vert Normal file
View File

@ -0,0 +1,14 @@
#version 330
in vec3 Position;
in vec2 Texcoord;
out vec2 tc;
void main(void)
{
tc = Texcoord;
gl_Position = vec4(Position, 1.);
}

View File

@ -1,15 +1,17 @@
#version 130 #version 330
uniform sampler2D halft; // half is a reserved word uniform sampler2D halft; // half is a reserved word
uniform sampler2D quarter; uniform sampler2D quarter;
uniform sampler2D eighth; uniform sampler2D eighth;
in vec2 uv;
out vec4 FragColor; out vec4 FragColor;
void main() void main()
{ {
vec3 val[3]; vec3 val[3];
val[0] = texture(halft, gl_TexCoord[0].xy).xyz; val[0] = texture(halft, uv).xyz;
val[1] = texture(quarter, gl_TexCoord[0].xy).xyz; val[1] = texture(quarter, uv).xyz;
val[2] = texture(eighth, gl_TexCoord[0].xy).xyz; val[2] = texture(eighth, uv).xyz;
// Find the first level with a penumbra value // Find the first level with a penumbra value
int i; int i;

View File

@ -1,4 +1,4 @@
#version 130 #version 330 compatibility
uniform sampler2D ntex; uniform sampler2D ntex;
uniform sampler2D ctex; uniform sampler2D ctex;
uniform vec3 campos; uniform vec3 campos;

View File

@ -1,4 +1,4 @@
#version 130 #version 330 compatibility
uniform sampler2D dtex; uniform sampler2D dtex;
uniform mat4 ipvmat; uniform mat4 ipvmat;
uniform mat4 shadowmat; uniform mat4 shadowmat;

View File

@ -1,4 +1,4 @@
#version 130 #version 330 compatibility
uniform sampler2D tex; uniform sampler2D tex;
uniform int hastex; uniform int hastex;
uniform int viz; uniform int viz;

View File

@ -1,4 +1,4 @@
#version 130 #version 330 compatibility
uniform sampler2D warpx; uniform sampler2D warpx;
uniform sampler2D warpy; uniform sampler2D warpy;

View File

@ -1,4 +1,4 @@
#version 130 #version 330 compatibility
uniform sampler2D tex; uniform sampler2D tex;
uniform int size; uniform int size;
uniform vec2 pixel; uniform vec2 pixel;

View File

@ -1,4 +1,4 @@
#version 130 #version 330 compatibility
uniform sampler2D tex; uniform sampler2D tex;
uniform int size; uniform int size;
uniform vec2 pixel; uniform vec2 pixel;

View File

@ -16,7 +16,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// skinning.vert // skinning.vert
#version 130 #version 330 compatibility
#define MAX_JOINT_NUM 36 #define MAX_JOINT_NUM 36
#define MAX_LIGHT_NUM 8 #define MAX_LIGHT_NUM 8

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#version 130 #version 330 compatibility
uniform sampler2D tex; uniform sampler2D tex;
uniform sampler2D glow_tex; uniform sampler2D glow_tex;
uniform float transparency; uniform float transparency;

View File

@ -17,7 +17,7 @@
// Creates a bubble (wave) effect by distorting the texture depending on time // Creates a bubble (wave) effect by distorting the texture depending on time
#version 130 #version 330 compatibility
uniform mat4 ModelViewProjectionMatrix; uniform mat4 ModelViewProjectionMatrix;
uniform float time; uniform float time;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex_layout; uniform sampler2D tex_layout;
uniform sampler2D tex_detail0; uniform sampler2D tex_detail0;
uniform sampler2D tex_detail1; uniform sampler2D tex_detail1;

View File

@ -15,7 +15,7 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#version 130 #version 330
uniform mat4 ModelViewProjectionMatrix; uniform mat4 ModelViewProjectionMatrix;
uniform mat4 TransposeInverseModelView; uniform mat4 TransposeInverseModelView;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D ntex; uniform sampler2D ntex;
uniform sampler2D dtex; uniform sampler2D dtex;
uniform sampler2D noise_texture; uniform sampler2D noise_texture;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D ntex; uniform sampler2D ntex;
uniform sampler2D dtex; uniform sampler2D dtex;
//uniform sampler2D cloudtex; //uniform sampler2D cloudtex;

View File

@ -1,18 +1,14 @@
#version 130 #version 330
uniform sampler2D ntex; uniform sampler2D ntex;
uniform sampler2D dtex; uniform sampler2D dtex;
uniform sampler2DShadow shadowtex0; uniform sampler2DArrayShadow shadowtex;
uniform sampler2DShadow shadowtex1;
uniform sampler2DShadow shadowtex2;
//uniform sampler2D warpx; //uniform sampler2D warpx;
///uniform sampler2D warpy; ///uniform sampler2D warpy;
uniform vec3 direction; uniform vec3 direction;
uniform vec3 col; uniform vec3 col;
uniform mat4 invproj; uniform mat4 invproj;
uniform mat4 shadowmat0; uniform mat4 shadowmat[4];
uniform mat4 shadowmat1;
uniform mat4 shadowmat2;
//uniform int hasclouds; //uniform int hasclouds;
//uniform vec2 wind; //uniform vec2 wind;
//uniform float shadowoffset; //uniform float shadowoffset;
@ -28,11 +24,16 @@ vec3 DecodeNormal(vec2 n)
return vec3(xy,z); return vec3(xy,z);
} }
float getShadowFactor(vec3 pos, float bias) float getShadowFactor(vec3 pos, float bias, int index)
{ {
if (pos.z < 10.) const vec2 shadowoffset[] = {
{ vec2(-1., -1.),
vec4 shadowcoord = (shadowmat0 * vec4(pos, 1.0)); vec2(-1., 1.),
vec2(1., -1.),
vec2(1., 1.)
};
vec4 shadowcoord = (shadowmat[index] * vec4(pos, 1.0));
shadowcoord /= shadowcoord.w; shadowcoord /= shadowcoord.w;
vec2 shadowtexcoord = shadowcoord.xy * 0.5 + 0.5; vec2 shadowtexcoord = shadowcoord.xy * 0.5 + 0.5;
// shadowcoord = (shadowcoord * 0.5) + vec3(0.5); // shadowcoord = (shadowcoord * 0.5) + vec3(0.5);
@ -45,22 +46,12 @@ float getShadowFactor(vec3 pos, float bias)
//float shadowmapz = 2. * texture(shadowtex, vec3(shadowtexcoord, shadowcoord.z).x - 1.; //float shadowmapz = 2. * texture(shadowtex, vec3(shadowtexcoord, shadowcoord.z).x - 1.;
// bias += smoothstep(0.001, 0.1, moved) * 0.014; // According to the warping // bias += smoothstep(0.001, 0.1, moved) * 0.014; // According to the warping
return texture(shadowtex0, vec3(shadowtexcoord, 0.5 * (shadowcoord.z + bias * 0.001) + 0.5)); float sum = 0.;
} for (int i = 0; i < 4; i++)
else if (pos.z < 60)
{ {
vec4 shadowcoord = (shadowmat1 * vec4(pos, 1.0)); sum += texture(shadowtex, vec4(shadowtexcoord + 0.0005 * shadowoffset[i], float(index), 0.5 * (shadowcoord.z + bias * 0.001) + 0.5));
shadowcoord /= shadowcoord.w;
vec2 shadowtexcoord = shadowcoord.xy * 0.5 + 0.5;
return texture(shadowtex1, vec3(shadowtexcoord, 0.5 * (shadowcoord.z + bias * 0.001) + 0.5));
}
else
{
vec4 shadowcoord = (shadowmat2 * vec4(pos, 1.0));
shadowcoord /= shadowcoord.w;
vec2 shadowtexcoord = shadowcoord.xy * 0.5 + 0.5;
return texture(shadowtex2, vec3(shadowtexcoord, 0.5 * (shadowcoord.z + bias) + 0.5));
} }
return sum / 4.;
} }
void main() { void main() {
@ -93,7 +84,30 @@ void main() {
// Shadows // Shadows
float bias = 0.002 * tan(acos(NdotL)); // According to the slope float bias = 0.002 * tan(acos(NdotL)); // According to the slope
bias = clamp(bias, 0.001, 0.014); bias = clamp(bias, 0.001, 0.014);
float factor = getShadowFactor(xpos.xyz, bias); float factor;
if (xpos.z < 20.)
factor = getShadowFactor(xpos.xyz, bias, 0);
else if (xpos.z < 25.)
{
float a = getShadowFactor(xpos.xyz, bias, 0), b = getShadowFactor(xpos.xyz, bias, 1);
factor = mix(a, b, (xpos.z - 20.) / 5.);
}
else if (xpos.z < 50.)
factor = getShadowFactor(xpos.xyz, bias, 1);
else if (xpos.z < 60.)
{
float a = getShadowFactor(xpos.xyz, bias, 1), b = getShadowFactor(xpos.xyz, bias, 2);
factor = mix(a, b, (xpos.z - 50.) / 10.);
}
else if (xpos.z < 100.)
factor = getShadowFactor(xpos.xyz, bias, 2);
else if (xpos.z < 120.)
{
float a = getShadowFactor(xpos.xyz, bias, 2), b = getShadowFactor(xpos.xyz, bias, 3);
factor = mix(a, b, (xpos.z - 100.) / 20.);
}
else
factor = getShadowFactor(xpos.xyz, bias, 3);
Diff = vec4(factor * NdotL * col, 1.); Diff = vec4(factor * NdotL * col, 1.);
Spec = vec4(factor * Specular * col, 1.); Spec = vec4(factor * Specular * col, 1.);
return; return;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
in vec2 uv; in vec2 uv;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform vec2 center; uniform vec2 center;
uniform vec2 size; uniform vec2 size;
uniform vec2 texcenter; uniform vec2 texcenter;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
in vec2 uv; in vec2 uv;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform mat4 ModelViewProjectionMatrix; uniform mat4 ModelViewProjectionMatrix;
in vec3 Position; in vec3 Position;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D tex; uniform sampler2D tex;
uniform float fogmax; uniform float fogmax;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform sampler2D DiffuseMap; uniform sampler2D DiffuseMap;
uniform sampler2D SpecularMap; uniform sampler2D SpecularMap;
uniform sampler2D SSAO; uniform sampler2D SSAO;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
uniform mat4 ModelViewProjectionMatrix; uniform mat4 ModelViewProjectionMatrix;
in vec3 Position; in vec3 Position;

View File

@ -1,6 +1,6 @@
// Shader based on work by Fabien Sanglard // Shader based on work by Fabien Sanglard
// Released under the terms of CC-BY 3.0 // Released under the terms of CC-BY 3.0
#version 130 #version 330 compatibility
uniform sampler2D BumpTex1; // Normal map 1 uniform sampler2D BumpTex1; // Normal map 1
uniform sampler2D BumpTex2; // Normal map 2 uniform sampler2D BumpTex2; // Normal map 2
uniform sampler2D DecalTex; //The texture uniform sampler2D DecalTex; //The texture

View File

@ -1,6 +1,6 @@
// Shader based on work by Fabien Sanglard // Shader based on work by Fabien Sanglard
// Released under the terms of CC-BY 3.0 // Released under the terms of CC-BY 3.0
#version 130 #version 330 compatibility
uniform float speed; uniform float speed;
uniform float height; uniform float height;
uniform float waveLength; uniform float waveLength;

View File

@ -1,4 +1,4 @@
#version 130 #version 330
out vec4 FragColor; out vec4 FragColor;
void main() void main()
{ {

View File

@ -744,9 +744,8 @@ bool CIrrDeviceLinux::createWindow()
int context_attribs[] = int context_attribs[] =
{ {
GLX_CONTEXT_MAJOR_VERSION_ARB, 3, GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
GLX_CONTEXT_MINOR_VERSION_ARB, 0, GLX_CONTEXT_MINOR_VERSION_ARB, 3,
// Uncomment to discard deprecated features GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, //GLX_CONTEXT_CORE_PROFILE_BIT_ARB
//GLX_CONTEXT_FLAGS_ARB , GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB, GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB,
None None
}; };

View File

@ -412,9 +412,9 @@ bool COpenGLDriver::initDriver(CIrrDeviceWin32* device)
int iAttribs[] = int iAttribs[] =
{ {
WGL_CONTEXT_MAJOR_VERSION_ARB, 3, WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
WGL_CONTEXT_MINOR_VERSION_ARB, 1, WGL_CONTEXT_MINOR_VERSION_ARB, 3,
//WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB, WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB,
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, //WGL_CONTEXT_CORE_PROFILE_BIT_ARB
0 0
}; };
hrc=wglCreateContextAttribs_ARB(HDc, 0, iAttribs); hrc=wglCreateContextAttribs_ARB(HDc, 0, iAttribs);

View File

@ -255,6 +255,35 @@ GLuint LoadProgram(const char * vertex_file_path, const char * fragment_file_pat
return ProgramID; return ProgramID;
} }
GLuint LoadProgram(const char * vertex_file_path, const char * geometry_file_path, const char * fragment_file_path) {
GLuint VertexShaderID = LoadShader(vertex_file_path, GL_VERTEX_SHADER);
GLuint FragmentShaderID = LoadShader(fragment_file_path, GL_FRAGMENT_SHADER);
GLuint GeometryShaderID = LoadShader(geometry_file_path, GL_GEOMETRY_SHADER);
GLuint ProgramID = glCreateProgram();
glAttachShader(ProgramID, VertexShaderID);
glAttachShader(ProgramID, GeometryShaderID);
glAttachShader(ProgramID, FragmentShaderID);
glLinkProgram(ProgramID);
GLint Result = GL_FALSE;
int InfoLogLength;
glGetProgramiv(ProgramID, GL_LINK_STATUS, &Result);
if (Result == GL_FALSE) {
glGetProgramiv(ProgramID, GL_INFO_LOG_LENGTH, &InfoLogLength);
char *ErrorMessage = new char[InfoLogLength];
glGetProgramInfoLog(ProgramID, InfoLogLength, NULL, ErrorMessage);
printf(ErrorMessage);
delete[] ErrorMessage;
}
glDeleteShader(VertexShaderID);
glDeleteShader(GeometryShaderID);
glDeleteShader(FragmentShaderID);
return ProgramID;
}
GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsigned varyingscount) { GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsigned varyingscount) {
GLuint Shader = LoadShader(vertex_file_path, GL_VERTEX_SHADER); GLuint Shader = LoadShader(vertex_file_path, GL_VERTEX_SHADER);
GLuint Program = glCreateProgram(); GLuint Program = glCreateProgram();
@ -276,12 +305,13 @@ GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsi
return Program; return Program;
} }
GLuint getTextureGLuint(irr::video::ITexture *tex) {
return static_cast<irr::video::COpenGLTexture*>(tex)->getOpenGLTextureName();
}
GLuint getDepthTexture(irr::video::ITexture *tex) {
void bindUniformToTextureUnit(GLuint location, GLuint texid, unsigned textureUnit) { assert(tex->isRenderTarget());
glActiveTexture(GL_TEXTURE0 + textureUnit); return static_cast<irr::video::COpenGLFBOTexture*>(tex)->DepthBufferTexture;
glBindTexture(GL_TEXTURE_2D, texid);
glUniform1i(location, textureUnit);
} }
void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum MinFilter, bool allowAF) void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum MinFilter, bool allowAF)

View File

@ -20,8 +20,8 @@
void initGL(); void initGL();
GLuint LoadProgram(const char * vertex_file_path, const char * fragment_file_path); GLuint LoadProgram(const char * vertex_file_path, const char * fragment_file_path);
GLuint LoadProgram(const char * vertex_file_path, const char * geometry_file_path, const char * fragment_file_path);
GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsigned varyingscount); GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsigned varyingscount);
void bindUniformToTextureUnit(GLuint location, GLuint texid, unsigned textureUnit);
void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum MinFilter, bool allowAF = false); void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum MinFilter, bool allowAF = false);
// already includes glext.h, which defines useful GL constants. // already includes glext.h, which defines useful GL constants.
@ -90,6 +90,9 @@ extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB;
#include <rect.h> #include <rect.h>
#include "utils/vec3.hpp" #include "utils/vec3.hpp"
GLuint getTextureGLuint(irr::video::ITexture *tex);
GLuint getDepthTexture(irr::video::ITexture *tex);
void draw2DImage(const irr::video::ITexture* texture, const irr::core::rect<s32>& destRect, void draw2DImage(const irr::video::ITexture* texture, const irr::core::rect<s32>& destRect,
const irr::core::rect<s32>& sourceRect, const irr::core::rect<s32>* clipRect, const irr::core::rect<s32>& sourceRect, const irr::core::rect<s32>* clipRect,
const irr::video::SColor* const colors, bool useAlphaChannelOfTexture); const irr::video::SColor* const colors, bool useAlphaChannelOfTexture);

View File

@ -6,41 +6,8 @@
#include <IParticleSystemSceneNode.h> #include <IParticleSystemSceneNode.h>
#include "guiengine/engine.hpp" #include "guiengine/engine.hpp"
GLuint getTextureGLuint(irr::video::ITexture *tex) {
return static_cast<irr::video::COpenGLTexture*>(tex)->getOpenGLTextureName();
}
#define COMPONENTCOUNT 8 #define COMPONENTCOUNT 8
GPUParticle::GPUParticle(scene::ISceneNode *parent, scene::ISceneManager* mgr, ITexture *tex)
: scene::ISceneNode(parent, mgr, -1) {
fakemat.Lighting = false;
fakemat.ZWriteEnable = false;
fakemat.MaterialType = irr_driver->getShader(ES_RAIN);
fakemat.Thickness = 200;
fakemat.setTexture(0, tex);
fakemat.BlendOperation = video::EBO_NONE;
setAutomaticCulling(0);
}
void GPUParticle::render() {
simulate();
draw();
// We need to force irrlicht to update its internal states
irr::video::IVideoDriver * const drv = irr_driver->getVideoDriver();
drv->setMaterial(fakemat);
static_cast<irr::video::COpenGLDriver*>(drv)->setRenderStates3DMode();
}
void GPUParticle::OnRegisterSceneNode() {
if (
(irr_driver->getRenderPass() & irr::scene::ESNRP_TRANSPARENT) == irr::scene::ESNRP_TRANSPARENT)
{
SceneManager->registerNodeForRendering(this, irr::scene::ESNRP_TRANSPARENT);
}
ISceneNode::OnRegisterSceneNode();
}
scene::IParticleSystemSceneNode *ParticleSystemProxy::addParticleNode( scene::IParticleSystemSceneNode *ParticleSystemProxy::addParticleNode(
bool withDefaultEmitter, ISceneNode* parent, s32 id, bool withDefaultEmitter, ISceneNode* parent, s32 id,
const core::vector3df& position, const core::vector3df& position,
@ -65,13 +32,6 @@ ParticleSystemProxy::ParticleSystemProxy(bool createDefaultEmitter,
const core::vector3df& position, const core::vector3df& position,
const core::vector3df& rotation, const core::vector3df& rotation,
const core::vector3df& scale) : CParticleSystemSceneNode(createDefaultEmitter, parent, mgr, id, position, rotation, scale), m_alpha_additive(false) { const core::vector3df& scale) : CParticleSystemSceneNode(createDefaultEmitter, parent, mgr, id, position, rotation, scale), m_alpha_additive(false) {
fakemat.Lighting = false;
fakemat.ZWriteEnable = false;
fakemat.MaterialType = irr_driver->getShader(ES_RAIN);
fakemat.setTexture(0, getMaterial(0).getTexture(0));
fakemat.BlendOperation = video::EBO_NONE;
fakemat.FrontfaceCulling = false;
fakemat.BackfaceCulling = false;
glGenBuffers(1, &initial_values_buffer); glGenBuffers(1, &initial_values_buffer);
glGenBuffers(2, tfb_buffers); glGenBuffers(2, tfb_buffers);
glGenBuffers(1, &quaternionsbuffer); glGenBuffers(1, &quaternionsbuffer);
@ -608,102 +568,3 @@ void ParticleSystemProxy::OnRegisterSceneNode()
ISceneNode::OnRegisterSceneNode(); ISceneNode::OnRegisterSceneNode();
} }
} }
RainNode::RainNode(scene::ISceneManager* mgr, ITexture *tex)
: GPUParticle(0, mgr, tex)
{
RenderProgram = LoadProgram(file_manager->getAsset("shaders/rain.vert").c_str(), file_manager->getAsset("shaders/rain.frag").c_str());
loc_screenw = glGetUniformLocation(RenderProgram, "screenw");
loc_screen = glGetUniformLocation(RenderProgram, "screen");
loc_invproj = glGetUniformLocation(RenderProgram, "invproj");
texloc_tex = glGetUniformLocation(RenderProgram, "tex");
texloc_normal_and_depths = glGetUniformLocation(RenderProgram, "normals_and_depth");
const char *varyings[] = { "currentPosition" };
SimulationProgram = LoadTFBProgram(file_manager->getAsset("shaders/rainsim.vert").c_str(), varyings, 1);
loc_campos = glGetUniformLocation(SimulationProgram, "campos");
loc_viewm = glGetUniformLocation(SimulationProgram, "viewm");
loc_time = glGetUniformLocation(SimulationProgram, "time");
count = 2500;
area = 3500;
u32 i;
float x, y, z, vertices[7500];
for (i = 0; i < count; i++)
{
x = ((rand() % area) - area / 2) / 100.0f;
y = ((rand() % 2400)) / 100.0f;
z = ((rand() % area) - area / 2) / 100.0f;
vertices[3 * i] = x;
vertices[3 * i + 1] = y;
vertices[3 * i + 2] = z;
}
texture = getTextureGLuint(tex);
normal_and_depth = getTextureGLuint(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH));
glGenBuffers(2, tfb_vertex_buffer);
glBindBuffer(GL_ARRAY_BUFFER, tfb_vertex_buffer[0]);
glBufferData(GL_ARRAY_BUFFER, 3 * count * sizeof(float), vertices, GL_STREAM_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, tfb_vertex_buffer[1]);
glBufferData(GL_ARRAY_BUFFER, 3 * count * sizeof(float), 0, GL_STREAM_DRAW);
box.addInternalPoint(vector3df((float)(-area / 2)));
box.addInternalPoint(vector3df((float)(area / 2)));
}
void RainNode::simulate() {
glUseProgram(SimulationProgram);
const float time = irr_driver->getDevice()->getTimer()->getTime() / 90.0f;
const irr::core::matrix4 viewm = irr_driver->getVideoDriver()->getTransform(irr::video::ETS_VIEW);
const irr::core::vector3df campos = irr_driver->getSceneManager()->getActiveCamera()->getPosition();
glEnable(GL_RASTERIZER_DISCARD);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, tfb_vertex_buffer[0]);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, tfb_vertex_buffer[1]);
glUniformMatrix4fv(loc_viewm, 1, GL_FALSE, viewm.pointer());
glUniform1f(loc_time, time);
glUniform3f(loc_campos, campos.X, campos.Y, campos.Z);
glBeginTransformFeedback(GL_POINTS);
glDrawArrays(GL_POINTS, 0, count);
glEndTransformFeedback();
glDisable(GL_RASTERIZER_DISCARD);
}
void RainNode::draw() {
const float screenw = (float)UserConfigParams::m_width;
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
glEnable(GL_POINT_SPRITE);
glUseProgram(RenderProgram);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, tfb_vertex_buffer[1]);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
float screen[2] = {
(float)UserConfigParams::m_width,
(float)UserConfigParams::m_height
};
irr::core::matrix4 invproj = irr_driver->getVideoDriver()->getTransform(irr::video::ETS_PROJECTION);
invproj.makeInverse();
bindUniformToTextureUnit(texloc_tex, texture, 0);
bindUniformToTextureUnit(texloc_normal_and_depths, normal_and_depth, 1);
glUniformMatrix4fv(loc_invproj, 1, GL_FALSE, invproj.pointer());
glUniform2f(loc_screen, screen[0], screen[1]);
glUniform1f(loc_screenw, screenw);
glDrawArrays(GL_POINTS, 0, count);
glDisableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glActiveTexture(GL_TEXTURE0);
glDisable(GL_VERTEX_PROGRAM_POINT_SIZE);
}
const core::aabbox3d<f32>& RainNode::getBoundingBox() const
{
return box;
}

Some files were not shown because too many files have changed in this diff Show More