Shader space cleanup
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12881 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
a45bf5092f
commit
2d50b47f56
@ -3,5 +3,5 @@
|
||||
pkgdatadir = $(datadir)/games/@PACKAGE@/data/shaders
|
||||
|
||||
dist_pkgdata_DATA = $(shell find $(srcdir) -name "*.frag") \
|
||||
$(shell find $(srcdir) -name "*.vert")
|
||||
$(shell find $(srcdir) -name "*.vert")
|
||||
|
||||
|
@ -7,7 +7,7 @@ void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_Position = ftransform();
|
||||
|
||||
|
||||
float delta_x = cos(time*3.0) * sin( 4.0 * gl_TexCoord[0].st.s * 6.28318531 );
|
||||
float delta_y = cos(time*2.0) * sin( 3.0 * gl_TexCoord[0].st.t * 6.28318531 );
|
||||
|
||||
|
@ -9,7 +9,7 @@ void main()
|
||||
{
|
||||
vec4 color = texture2D(tex, gl_TexCoord[0].st);
|
||||
vec4 solidColor = vec4(color.r, color.g, color.b, 1);
|
||||
|
||||
|
||||
if (fog == 1)
|
||||
{
|
||||
if (coord.z > fogTo)
|
||||
|
@ -15,7 +15,7 @@ uniform vec2 center;
|
||||
// The direction to which the blurring aims at
|
||||
uniform vec2 direction;
|
||||
|
||||
// Radius of mask around the character in which no blurring happens
|
||||
// Radius of mask around the character in which no blurring happens
|
||||
// so that the kart doesn't get blurred.
|
||||
uniform float mask_radius;
|
||||
|
||||
@ -28,10 +28,10 @@ uniform float max_tex_height;
|
||||
void main()
|
||||
{
|
||||
vec2 texcoords = gl_TexCoord[0].st;
|
||||
|
||||
|
||||
// Sample the color buffer
|
||||
vec3 color = texture2D(color_buffer, texcoords).rgb;
|
||||
|
||||
|
||||
// If no motion blur is needed, don't do any of the blur computation,
|
||||
// just return the color from the texture.
|
||||
if(boost_amount==0.0)
|
||||
@ -39,25 +39,25 @@ void main()
|
||||
gl_FragColor = vec4(color, 1.0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Compute the blur direction.
|
||||
// IMPORTANT: we don't normalize it so that it avoids a glitch around 'center',
|
||||
// plus it naturally scales the motion blur in a cool way :)
|
||||
vec2 blur_dir = direction - texcoords;
|
||||
|
||||
|
||||
// Compute the blurring factor:
|
||||
// - apply the mask, i.e. no blurring in a small circle around the kart
|
||||
float blur_factor = max(0.0, length(texcoords - center) - mask_radius);
|
||||
|
||||
|
||||
// - avoid blurring the top of the screen
|
||||
blur_factor *= (max_tex_height - texcoords.t);
|
||||
|
||||
|
||||
// - apply the boost amount
|
||||
blur_factor *= boost_amount;
|
||||
|
||||
|
||||
// Scale the blur direction
|
||||
blur_dir *= blur_factor;
|
||||
|
||||
|
||||
// Compute the blur
|
||||
vec2 inc_vec = blur_dir / vec2(NB_SAMPLES);
|
||||
vec2 blur_texcoords = texcoords + inc_vec;
|
||||
|
@ -1,11 +1,11 @@
|
||||
// Shader based on work by Fabien Sanglard
|
||||
// Released under the terms of CC-BY 3.0
|
||||
|
||||
uniform sampler2D BumpTex; //The bump-map
|
||||
uniform sampler2D BumpTex; //The bump-map
|
||||
uniform sampler2D DecalTex; //The texture
|
||||
uniform sampler2D LightMapTex;
|
||||
int HasLightMap;
|
||||
|
||||
|
||||
// New bumpmapping
|
||||
varying vec3 lightVec;
|
||||
varying vec3 halfVec;
|
||||
@ -17,11 +17,11 @@ void main()
|
||||
// lookup normal from normal map, move from [0,1] to [-1, 1] range, normalize
|
||||
vec3 normal = 2.0 * texture2D (BumpTex, gl_TexCoord[0].st).rgb - 1.0;
|
||||
normal = normalize (normal);
|
||||
|
||||
|
||||
// compute diffuse lighting
|
||||
float lamberFactor = max (dot (lightVec, normal), 0.0) ;
|
||||
vec4 diffuseMaterial;
|
||||
|
||||
|
||||
diffuseMaterial = texture2D (DecalTex, gl_TexCoord[0].st);
|
||||
|
||||
if (HasLightMap < 1)
|
||||
@ -33,4 +33,4 @@ void main()
|
||||
{
|
||||
gl_FragColor = diffuseMaterial * (0.5 + lamberFactor*0.5) * texture2D(LightMapTex, gl_TexCoord[0].st);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,34 +11,34 @@ void main()
|
||||
{
|
||||
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
|
||||
|
||||
// Building the matrix Eye Space -> Tangent Space
|
||||
vec3 n = normalize (gl_NormalMatrix * gl_Normal);
|
||||
vec3 t = normalize (gl_NormalMatrix * gl_MultiTexCoord1.xyz); // tangent
|
||||
vec3 b = cross (n, t);
|
||||
|
||||
|
||||
vec3 vertexPosition = vec3(gl_ModelViewMatrix * gl_Vertex);
|
||||
|
||||
|
||||
// transform light and half angle vectors by tangent basis
|
||||
vec3 v;
|
||||
v.x = dot (lightdir, t);
|
||||
v.y = dot (lightdir, b);
|
||||
v.z = dot (lightdir, n);
|
||||
lightVec = normalize (v);
|
||||
|
||||
|
||||
|
||||
|
||||
v.x = dot (vertexPosition, t);
|
||||
v.y = dot (vertexPosition, b);
|
||||
v.z = dot (vertexPosition, n);
|
||||
eyeVec = normalize (v);
|
||||
|
||||
|
||||
|
||||
|
||||
vertexPosition = normalize(vertexPosition);
|
||||
|
||||
|
||||
// Normalize the halfVector to pass it to the fragment shader
|
||||
|
||||
// No need to divide by two, the result is normalized anyway.
|
||||
// vec3 halfVector = normalize((vertexPosition + lightDir) / 2.0);
|
||||
// vec3 halfVector = normalize((vertexPosition + lightDir) / 2.0);
|
||||
vec3 halfVector = normalize(vertexPosition + lightdir);
|
||||
v.x = dot (halfVector, t);
|
||||
v.y = dot (halfVector, b);
|
||||
@ -46,9 +46,9 @@ void main()
|
||||
|
||||
// No need to normalize, t,b,n and halfVector are normal vectors.
|
||||
//normalize (v);
|
||||
halfVec = v ;
|
||||
|
||||
|
||||
halfVec = v ;
|
||||
|
||||
|
||||
gl_Position = ftransform();
|
||||
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
|
||||
uniform mat4 JointTransform[MAX_JOINT_NUM];
|
||||
|
||||
void main()
|
||||
void main()
|
||||
{
|
||||
int index;
|
||||
vec4 ecPos;
|
||||
@ -15,10 +15,10 @@ void main()
|
||||
float dist;
|
||||
|
||||
mat4 ModelTransform = gl_ModelViewProjectionMatrix;
|
||||
|
||||
|
||||
index = int(gl_Color.r * 255.99);
|
||||
mat4 vertTran = JointTransform[index - 1];
|
||||
|
||||
|
||||
index = int(gl_Color.g * 255.99);
|
||||
if(index > 0)
|
||||
vertTran += JointTransform[index - 1];
|
||||
@ -26,16 +26,16 @@ void main()
|
||||
index = int(gl_Color.b * 255.99);
|
||||
if(index > 0)
|
||||
vertTran += JointTransform[index - 1];
|
||||
|
||||
|
||||
index = int(gl_Color.a * 255.99);
|
||||
if(index > 0)
|
||||
vertTran += JointTransform[index - 1];
|
||||
|
||||
|
||||
ecPos = gl_ModelViewMatrix * vertTran * gl_Vertex;
|
||||
|
||||
normal = (vertTran * vec4(gl_Normal, 0.0)).xyz;
|
||||
normal = normalize(gl_NormalMatrix * normal);
|
||||
|
||||
|
||||
gl_FrontColor = vec4(0,0,0,0);
|
||||
for(int i = 0;i < MAX_LIGHT_NUM;i++)
|
||||
{
|
||||
@ -46,15 +46,15 @@ void main()
|
||||
gl_FrontColor += gl_LightSource[i].diffuse * n_dot_l;
|
||||
}
|
||||
gl_FrontColor = clamp(gl_FrontColor,0.3,1.0);
|
||||
|
||||
|
||||
|
||||
ModelTransform *= vertTran;
|
||||
|
||||
|
||||
gl_Position = ModelTransform * gl_Vertex;
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_TexCoord[1] = gl_MultiTexCoord1;
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
// Reflections.
|
||||
vec3 r = reflect( ecPos.xyz , normal );
|
||||
float m = 2.0 * sqrt( r.x*r.x + r.y*r.y + (r.z+1.0)*(r.z+1.0) );
|
||||
|
@ -10,26 +10,26 @@ varying vec3 lightVec;
|
||||
void main()
|
||||
{
|
||||
vec3 forward = vec3(0.0, 0.0, 1.0);
|
||||
|
||||
|
||||
// get the angle between the forward vector and the horizontal portion of the normal
|
||||
vec3 normal_x = normalize(vec3(normal.x, 0.0, normal.z));
|
||||
float sin_theta_x = length(cross( forward, normal_x )) * normal.x/abs(normal.x);
|
||||
|
||||
|
||||
// get the angle between the forward vector and the vertical portion of the normal
|
||||
vec3 normal_y = normalize(vec3(0.0, normal.y, normal.z));
|
||||
float sin_theta_y = length(cross( forward, normal_y ))* normal.y/abs(normal.y);
|
||||
|
||||
|
||||
vec4 detail0 = texture2D(texture, vec2(0.5 + sin_theta_x*0.5, 0.5 + sin_theta_y*0.5));
|
||||
|
||||
gl_FragColor = detail0 * (0.5 + dot(lightdir, normal)) * vertex_color; // 0.5 is the ambient light.
|
||||
gl_FragColor = detail0 * (0.5 + dot(lightdir, normal)) * vertex_color; // 0.5 is the ambient light.
|
||||
//gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
|
||||
// specular (phong)
|
||||
vec3 R = normalize(reflect(lightVec, normal));
|
||||
float specular = max(dot(R,eyeVec),0.0);
|
||||
|
||||
|
||||
//gl_FragColor = vec4(specular, specular, specular, 1.0);
|
||||
|
||||
|
||||
if (specular > 0.0)
|
||||
{
|
||||
// weak specular
|
||||
@ -37,7 +37,7 @@ void main()
|
||||
specular = specular*specular;
|
||||
float specular_weak = specular*2.0; //max(specular*1.1, 1.0);
|
||||
gl_FragColor += vec4(specular_weak, specular_weak, specular_weak, 0.0);
|
||||
|
||||
|
||||
/*
|
||||
// strong specular
|
||||
specular = specular*specular;
|
||||
|
@ -9,19 +9,19 @@ void main()
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_Position = ftransform();
|
||||
vertex_color = gl_Color;
|
||||
|
||||
|
||||
//vec3 normal3 = normalize(gl_Normal);
|
||||
//vec4 normal4 = vec4(normal3.x, normal3.y, normal3.z, 0.0)*gl_ModelViewMatrix;
|
||||
//normal = normal4.xyz;
|
||||
|
||||
eyeVec = normalize(-gl_Position).xyz; // we are in Eye Coordinates, so EyePos is (0,0,0)
|
||||
|
||||
eyeVec = normalize(-gl_Position).xyz; // we are in Eye Coordinates, so EyePos is (0,0,0)
|
||||
normal = normalize(gl_NormalMatrix*gl_Normal);
|
||||
|
||||
|
||||
// Building the matrix Eye Space -> Tangent Space
|
||||
// gl_MultiTexCoord1.xyz
|
||||
vec3 t = normalize (gl_NormalMatrix * vec3(0.0, 0.0, 1.0)); // tangent
|
||||
vec3 b = cross (normal, t);
|
||||
|
||||
|
||||
// transform light and half angle vectors by tangent basis
|
||||
vec3 v;
|
||||
v.x = dot(lightdir, t);
|
||||
|
@ -18,7 +18,7 @@ void main()
|
||||
vec4 detail2 = texture2D(tex_detail2, gl_TexCoord[0].st);
|
||||
vec4 detail3 = texture2D(tex_detail3, gl_TexCoord[0].st);
|
||||
vec4 detail4 = texture2D(tex_detail4, gl_TexCoord[0].st);
|
||||
|
||||
|
||||
gl_FragColor = (splatting.r * detail0 +
|
||||
splatting.g * detail1 +
|
||||
splatting.b * detail2 +
|
||||
|
@ -9,7 +9,7 @@ void main()
|
||||
gl_TexCoord[1] = gl_MultiTexCoord1;
|
||||
gl_Position = ftransform();
|
||||
vertex_color = gl_Color;
|
||||
|
||||
|
||||
//normal = normalize(gl_NormalMatrix * gl_Normal);
|
||||
normal = normalize(gl_Normal);
|
||||
lightdir2 = normalize(lightdir);
|
||||
|
@ -17,13 +17,13 @@ void main()
|
||||
// lookup normal from normal map, move from [0,1] to [-1, 1] range, normalize
|
||||
vec3 normal = 2.0 * texture2D (BumpTex1, gl_TexCoord[0].st + delta1).rgb - 1.0;
|
||||
vec3 normal2 = 2.0 * texture2D (BumpTex2, gl_TexCoord[0].st + delta2).rgb - 1.0;
|
||||
|
||||
|
||||
// scale normals
|
||||
normal.y = 4.0*normal.y;
|
||||
normal2.y = 4.0*normal2.y;
|
||||
|
||||
|
||||
normal = (normalize(normal) + normalize(normal2))/2.0;
|
||||
|
||||
|
||||
// compute diffuse lighting
|
||||
float lamberFactor = max (dot (lightVec, normal), 0.0);
|
||||
vec4 diffuseMaterial;
|
||||
@ -38,11 +38,11 @@ void main()
|
||||
//}
|
||||
|
||||
gl_FragColor = diffuseMaterial * (0.3 + lamberFactor*0.7);
|
||||
|
||||
|
||||
// specular (phong)
|
||||
vec3 R = normalize(reflect(lightVec, normal));
|
||||
float specular = max(dot(R,eyeVec),0.0);
|
||||
|
||||
|
||||
if (specular > 0.0)
|
||||
{
|
||||
// weak specular
|
||||
@ -50,7 +50,7 @@ void main()
|
||||
specular = specular*specular;
|
||||
float specular_weak = specular*0.05;
|
||||
gl_FragColor += vec4(specular_weak, specular_weak, specular_weak, 0.0);
|
||||
|
||||
|
||||
// strong specular
|
||||
specular = specular*specular;
|
||||
float specular_strong = specular*0.3;
|
||||
|
@ -11,15 +11,15 @@ void main()
|
||||
{
|
||||
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
|
||||
|
||||
// Building the matrix Eye Space -> Tangent Space
|
||||
vec3 n = normalize (gl_NormalMatrix * gl_Normal);
|
||||
// gl_MultiTexCoord1.xyz
|
||||
vec3 t = normalize (gl_NormalMatrix * vec3(1.0, 0.0, 0.0)); // tangent
|
||||
vec3 b = cross (n, t);
|
||||
|
||||
|
||||
vec3 vertexPosition = vec3(gl_ModelViewMatrix * gl_Vertex);
|
||||
|
||||
|
||||
// transform light and half angle vectors by tangent basis
|
||||
vec3 v;
|
||||
v.x = dot (lightdir, t);
|
||||
@ -28,13 +28,13 @@ void main()
|
||||
lightVec = normalize (v);
|
||||
|
||||
vertexPosition = normalize(vertexPosition);
|
||||
|
||||
eyeVec = normalize(-vertexPosition); // we are in Eye Coordinates, so EyePos is (0,0,0)
|
||||
|
||||
eyeVec = normalize(-vertexPosition); // we are in Eye Coordinates, so EyePos is (0,0,0)
|
||||
|
||||
// Normalize the halfVector to pass it to the fragment shader
|
||||
|
||||
// No need to divide by two, the result is normalized anyway.
|
||||
// vec3 halfVector = normalize((vertexPosition + lightDir) / 2.0);
|
||||
// vec3 halfVector = normalize((vertexPosition + lightDir) / 2.0);
|
||||
vec3 halfVector = normalize(vertexPosition + lightdir);
|
||||
v.x = dot (halfVector, t);
|
||||
v.y = dot (halfVector, b);
|
||||
@ -42,7 +42,7 @@ void main()
|
||||
|
||||
// No need to normalize, t,b,n and halfVector are normal vectors.
|
||||
//normalize (v);
|
||||
halfVec = v ;
|
||||
|
||||
halfVec = v ;
|
||||
|
||||
gl_Position = ftransform();
|
||||
}
|
@ -22,13 +22,13 @@ void main()
|
||||
// lookup normal from normal map, move from [0,1] to [-1, 1] range, normalize
|
||||
vec3 normal = 2.0 * texture2D (BumpTex1, gl_TexCoord[0].st + delta1).rgb - 1.0;
|
||||
vec3 normal2 = 2.0 * texture2D (BumpTex2, gl_TexCoord[0].st + delta2).rgb - 1.0;
|
||||
|
||||
|
||||
// scale normals
|
||||
normal.y = 4.0*normal.y;
|
||||
normal2.y = 4.0*normal2.y;
|
||||
|
||||
|
||||
normal = (normalize(normal) + normalize(normal2))/2.0;
|
||||
|
||||
|
||||
// compute diffuse lighting
|
||||
float lamberFactor = max (dot (lightVec, normal), 0.0);
|
||||
vec4 diffuseMaterial;
|
||||
@ -43,11 +43,11 @@ void main()
|
||||
//}
|
||||
|
||||
gl_FragColor = diffuseMaterial * (0.3 + lamberFactor*0.7);
|
||||
|
||||
|
||||
// specular (phong)
|
||||
vec3 R = normalize(reflect(lightVec, normal));
|
||||
float specular = max(dot(R,eyeVec),0.0);
|
||||
|
||||
|
||||
if (specular > 0.0)
|
||||
{
|
||||
// weak specular
|
||||
@ -55,13 +55,13 @@ void main()
|
||||
specular = specular*specular;
|
||||
float specular_weak = specular*0.05;
|
||||
gl_FragColor += vec4(specular_weak, specular_weak, specular_weak, 0.0);
|
||||
|
||||
|
||||
// strong specular
|
||||
specular = specular*specular;
|
||||
float specular_strong = specular*0.3;
|
||||
gl_FragColor += vec4(specular_strong, specular_strong, specular_strong, 0.0);
|
||||
}
|
||||
|
||||
|
||||
if (coord.z > fogTo)
|
||||
{
|
||||
gl_FragColor = fogColor;
|
||||
|
@ -11,15 +11,15 @@ void main()
|
||||
{
|
||||
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
|
||||
|
||||
// Building the matrix Eye Space -> Tangent Space
|
||||
vec3 n = normalize (gl_NormalMatrix * gl_Normal);
|
||||
// gl_MultiTexCoord1.xyz
|
||||
vec3 t = normalize (gl_NormalMatrix * vec3(1.0, 0.0, 0.0)); // tangent
|
||||
vec3 b = cross (n, t);
|
||||
|
||||
|
||||
vec3 vertexPosition = vec3(gl_ModelViewMatrix * gl_Vertex);
|
||||
|
||||
|
||||
// transform light and half angle vectors by tangent basis
|
||||
vec3 v;
|
||||
v.x = dot (lightdir, t);
|
||||
@ -28,13 +28,13 @@ void main()
|
||||
lightVec = normalize (v);
|
||||
|
||||
vertexPosition = normalize(vertexPosition);
|
||||
|
||||
eyeVec = normalize(-vertexPosition); // we are in Eye Coordinates, so EyePos is (0,0,0)
|
||||
|
||||
eyeVec = normalize(-vertexPosition); // we are in Eye Coordinates, so EyePos is (0,0,0)
|
||||
|
||||
// Normalize the halfVector to pass it to the fragment shader
|
||||
|
||||
// No need to divide by two, the result is normalized anyway.
|
||||
// vec3 halfVector = normalize((vertexPosition + lightDir) / 2.0);
|
||||
// vec3 halfVector = normalize((vertexPosition + lightDir) / 2.0);
|
||||
vec3 halfVector = normalize(vertexPosition + lightdir);
|
||||
v.x = dot (halfVector, t);
|
||||
v.y = dot (halfVector, b);
|
||||
@ -42,8 +42,8 @@ void main()
|
||||
|
||||
// No need to normalize, t,b,n and halfVector are normal vectors.
|
||||
//normalize (v);
|
||||
halfVec = v ;
|
||||
|
||||
halfVec = v ;
|
||||
|
||||
gl_Position = ftransform();
|
||||
coord = gl_Position;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user