OGL32CTX: Replace deprecated "varying" by in/out semantic and make them explicit.

gl_Texcoord[]/gl_Color should be explocitly passed as in/out.
Compilers can pack varyings if the architecture does benefit from it (for instance intel mesa driver) but on the other hand they usually don't change size of varying even if there is only a single component used.
So storing vec2 into vec4 may waste performances.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14974 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
vincentlj 2014-01-09 00:17:28 +00:00
parent 2ba340b6cb
commit 42c16b32cb
21 changed files with 94 additions and 82 deletions

View File

@ -17,7 +17,7 @@
#version 130
uniform sampler2D tex;
uniform float transparency;
varying vec2 uv;
in vec2 uv;
void main()
{

View File

@ -19,15 +19,14 @@
// Creates a bubble (wave) effect by distorting the texture depending on time
#version 130
uniform float time;
varying vec2 uv;
out vec2 uv;
void main()
{
gl_TexCoord[0] = gl_TextureMatrix[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 );
uv = gl_TexCoord[0].st + vec2(0.02*delta_x, 0.02*delta_y);
uv = (gl_TextureMatrix[0] * gl_MultiTexCoord0).st + vec2(0.02*delta_x, 0.02*delta_y);
}

View File

@ -4,11 +4,13 @@ uniform vec2 screen;
uniform vec2 dir;
uniform vec2 dir2;
varying float camdist;
in vec2 uv;
in vec2 edger_uv;
in float camdist;
void main()
{
vec2 tc = gl_TexCoord[0].xy;
vec2 tc = uv;
vec4 col = vec4(0.0);
const float maxlen = 0.02;
@ -24,7 +26,7 @@ void main()
float fade = 1.0 - smoothstep(1.0, 100.0, camdist);
// Fade according to distance from the edges
vec2 edger = gl_TexCoord[1].xy;
vec2 edger = edger_uv;
const float mindist = 0.1;
fade *= smoothstep(0.0, mindist, edger.x) * smoothstep(0.0, mindist, edger.y) *
(1.0 - smoothstep(1.0 - mindist, 1.0, edger.x)) *

View File

@ -1,10 +1,13 @@
#version 130
varying float camdist;
out vec2 uv;
out vec2 edger_uv;
out float camdist;
void main() {
gl_Position = ftransform();
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[1] = gl_MultiTexCoord1;
uv = gl_MultiTexCoord0.xy;
edger_uv = gl_MultiTexCoord1.xy;
camdist = length((gl_ModelViewMatrix * gl_Vertex).xyz);
}

View File

@ -23,9 +23,9 @@
uniform sampler2D tex;
uniform float transparency;
varying vec2 uv;
varying vec3 eyeVec;
varying vec3 normal;
in vec2 uv;
noperspective in vec3 eyeVec;
noperspective in vec3 normal;
void main()
{

View File

@ -23,13 +23,12 @@
// such that the user gets to know whether the shield has several
// "layers" or whether the shield is about to break.
#version 130
varying vec2 uv;
varying vec3 eyeVec;
varying vec3 normal;
out vec2 uv;
noperspective out vec3 eyeVec;
noperspective out vec3 normal;
void main()
{
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
vec4 viewp = gl_ModelViewMatrix * gl_Vertex;
eyeVec = normalize(-viewp).xyz;
@ -37,5 +36,5 @@ void main()
gl_Position = ftransform();
uv = gl_TexCoord[0].st;
uv = (gl_TextureMatrix[0] * gl_MultiTexCoord0).st;
}

View File

@ -25,9 +25,9 @@
uniform sampler2D tex;
uniform float transparency;
varying vec2 uv;
varying vec3 eyeVec;
varying vec3 normal;
in vec2 uv;
noperspective in vec3 eyeVec;
noperspective in vec3 normal;
void main()
{

View File

@ -19,13 +19,12 @@
// Jean-manuel clemencon (C) Copyright supertuxkart
// Creates a cone lightbeam effect by smoothing edges
#version 130
varying vec2 uv;
varying vec3 eyeVec;
varying vec3 normal;
out vec2 uv;
noperspective out vec3 eyeVec;
noperspective out vec3 normal;
void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
vec4 viewp = gl_ModelViewMatrix * gl_Vertex;
eyeVec = normalize(-viewp).xyz;
@ -33,5 +32,5 @@ void main()
gl_Position = ftransform();
uv = gl_TexCoord[0].st;
uv = gl_MultiTexCoord0.st;
}

View File

@ -4,8 +4,8 @@ uniform sampler2D ctex;
uniform vec3 campos;
uniform int low;
varying vec3 wpos;
varying vec2 texc;
in vec3 wpos;
in vec2 texc;
float luminanceImp()
{

View File

@ -3,8 +3,8 @@ uniform sampler2D dtex;
uniform mat4 ipvmat;
uniform mat4 shadowmat;
varying vec3 wpos;
varying vec2 texc;
out vec3 wpos;
out vec2 texc;
float decdepth(vec4 rgba) {
return dot(rgba, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0));

View File

@ -5,6 +5,8 @@ uniform int viz;
uniform int wireframe;
uniform float objectid;
in vec2 uv;
vec4 encdepth(float v) {
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
enc = fract(enc);
@ -15,7 +17,7 @@ vec4 encdepth(float v) {
void main() {
if (hastex != 0) {
float alpha = texture2D(tex, gl_TexCoord[0].xy).a;
float alpha = texture2D(tex, uv).a;
if (alpha < 0.5)
discard;
@ -29,7 +31,7 @@ void main() {
if (wireframe > 0)
gl_FragColor = vec4(1.0);
else
gl_FragColor = texture2D(tex, gl_TexCoord[0].xy);
gl_FragColor = texture2D(tex, uv);
}
}

View File

@ -2,6 +2,8 @@
uniform sampler2D warpx;
uniform sampler2D warpy;
out vec2 uv;
float decdepth(vec4 rgba) {
return dot(rgba, vec4(1.0, 1.0/255.0, 1.0/65025.0, 1.0/16581375.0));
}
@ -9,7 +11,7 @@ float decdepth(vec4 rgba) {
void main()
{
vec4 pos = ftransform();
gl_TexCoord[0] = gl_MultiTexCoord0;
uv = gl_MultiTexCoord0.xy;
vec2 tc = pos.xy * vec2(0.5) + vec2(0.5);

View File

@ -20,11 +20,11 @@ uniform sampler2D glow_tex;
uniform float transparency;
uniform vec3 sun_pos;
varying vec2 uv_anim;
varying vec2 uv;
varying vec2 uv_cl;
varying vec3 vertex;
varying vec2 uv_fast;
in vec2 uv_anim;
in vec2 uv;
in vec2 uv_cl;
in vec3 vertex;
in vec2 uv_fast;
void main()
{

View File

@ -20,17 +20,17 @@
#version 130
uniform float time;
varying vec2 uv;
varying vec2 uv_anim;
varying vec2 uv_cl;
varying vec2 uv_fast;
out vec2 uv;
out vec2 uv_anim;
out vec2 uv_cl;
out vec2 uv_fast;
varying vec3 vertex;
out vec3 vertex;
void main()
{
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
uv = (gl_TextureMatrix[0] * gl_MultiTexCoord0).st;
gl_Position = ftransform();
@ -38,12 +38,10 @@ void main()
float delta_y = cos(time*2.0) * sin( 3.0 * gl_TexCoord[0].st.t * 6.28318531 );
vertex = gl_Vertex.xyz;
uv = gl_TexCoord[0].st;
uv_anim = gl_TexCoord[0].st + vec2(0.002*time, 0);
uv_cl = gl_TexCoord[0].st + vec2(-0.001*time, 0);
uv_anim = uv + vec2(0.002*time, 0);
uv_cl = uv + vec2(-0.001*time, 0);
uv_fast = gl_TexCoord[0].st + vec2(0.005*time, 0);
uv_fast = uv + vec2(0.005*time, 0);
}

View File

@ -17,11 +17,12 @@
#version 130
uniform sampler2D texture;
varying vec3 normal;
uniform vec3 lightdir;
varying vec4 vertex_color;
varying vec3 eyeVec;
varying vec3 lightVec;
noperspective in vec3 normal;
in vec4 vertex_color;
noperspective in vec3 eyeVec;
noperspective in vec3 lightVec;
void main()
{

View File

@ -16,15 +16,15 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#version 130
varying vec3 normal;
varying vec4 vertex_color;
varying vec3 eyeVec;
varying vec3 lightVec;
uniform vec3 lightdir;
noperspective out vec3 normal;
out vec4 vertex_color;
noperspective out vec3 eyeVec;
noperspective out vec3 lightVec;
void main()
{
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_Position = ftransform();
vertex_color = gl_Color;

View File

@ -7,15 +7,18 @@ uniform sampler2D tex_detail3;
//uniform sampler2D tex_detail4;
noperspective in vec3 nor;
in vec2 uv;
in vec2 uv_bis;
in vec4 color;
void main() {
// Splatting part
vec4 splatting = texture2D(tex_layout, gl_TexCoord[1].st);
vec4 detail0 = texture2D(tex_detail0, gl_TexCoord[0].st);
vec4 detail1 = texture2D(tex_detail1, gl_TexCoord[0].st);
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);
vec4 splatting = texture2D(tex_layout, uv_bis);
vec4 detail0 = texture2D(tex_detail0, uv);
vec4 detail1 = texture2D(tex_detail1, uv);
vec4 detail2 = texture2D(tex_detail2, uv);
vec4 detail3 = texture2D(tex_detail3, uv);
// vec4 detail4 = texture2D(tex_detail4, uv);
vec4 detail4 = vec4(0.0);
vec4 splatted = (splatting.r * detail0 +
@ -23,7 +26,7 @@ void main() {
splatting.b * detail2 +
(1.0 - splatting.r - splatting.g - splatting.b) * detail3 +
(1.0 - splatting.a) * detail4)
* gl_Color;
* color;
gl_FragData[0] = vec4(splatted.xyz, 1.);

View File

@ -18,13 +18,16 @@
#version 130
uniform vec3 lightdir;
noperspective out vec3 normal;
noperspective out vec3 nor;
out vec2 uv;
out vec2 uv_bis;
out vec4 color;
void main()
{
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_TexCoord[1] = gl_TextureMatrix[1] * gl_MultiTexCoord1;
uv = (gl_TextureMatrix[0] * gl_MultiTexCoord0).st;
uv_bis = (gl_TextureMatrix[1] * gl_MultiTexCoord1).st;
gl_Position = ftransform();
normal = gl_NormalMatrix * gl_Normal;
color = gl_Color;
nor = gl_NormalMatrix * gl_Normal;
}

View File

@ -8,15 +8,16 @@ uniform sampler2D DecalTex; //The texture
uniform vec2 delta1;
uniform vec2 delta2;
varying vec3 lightVec;
varying vec3 halfVec;
varying vec3 eyeVec;
noperspective in vec3 lightVec;
noperspective in vec3 halfVec;
noperspective in vec3 eyeVec;
in vec2 uv;
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;
vec3 normal = 2.0 * texture2D (BumpTex1, uv + delta1).rgb - 1.0;
vec3 normal2 = 2.0 * texture2D (BumpTex2, uv + delta2).rgb - 1.0;
// scale normals
normal.y = 4.0*normal.y;
@ -29,7 +30,7 @@ void main()
vec4 diffuseMaterial;
vec4 diffuseLight;
diffuseMaterial = texture2D (DecalTex, gl_TexCoord[0].st + vec2(delta1.x, 0.0));
diffuseMaterial = texture2D (DecalTex, uv + vec2(delta1.x, 0.0));
diffuseLight = vec4(1.0, 1.0, 1.0, 1.0);
vec3 col = diffuseMaterial.xyz * (0.3 + lamberFactor*0.7);

View File

@ -7,9 +7,10 @@ uniform float waveLength;
uniform vec3 lightdir;
varying vec3 lightVec;
varying vec3 halfVec;
varying vec3 eyeVec;
noperspective out vec3 lightVec;
noperspective out vec3 halfVec;
noperspective out vec3 eyeVec;
out vec2 uv;
void main()
{
@ -50,6 +51,5 @@ void main()
halfVec = v ;
gl_Position = gl_ModelViewProjectionMatrix * pos;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_TexCoord[1] = gl_TextureMatrix[1] * gl_MultiTexCoord1;
uv = (gl_TextureMatrix[0] * gl_MultiTexCoord0).st;
}

View File

@ -98,7 +98,7 @@ void Shaders::loadShaders()
m_shaders[ES_SKYBOX] = glslmat(dir + "skybox.vert", dir + "skybox.frag",
m_callbacks[ES_SKYBOX], EMT_TRANSPARENT_ALPHA_CHANNEL);
m_shaders[ES_SPLATTING] = glslmat(dir + "objectpass.vert", dir + "splatting.frag",
m_shaders[ES_SPLATTING] = glslmat(dir + "splatting.vert", dir + "splatting.frag",
m_callbacks[ES_SPLATTING], EMT_SOLID);
m_shaders[ES_WATER] = glslmat(dir + "water.vert", dir + "water.frag",