Add the skybox shader for harvest. For the moment it's still an object in the transparent pass. The object should be in the skybox pass

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14909 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
samuncle
2014-01-04 20:43:18 +00:00
parent b2f2cb62f7
commit bd69c8c0d7
2 changed files with 116 additions and 0 deletions

67
data/shaders/skybox.frag Normal file
View File

@@ -0,0 +1,67 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2013 the SuperTuxKart team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
uniform sampler2D tex;
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;
void main()
{
vec3 V = normalize(vertex);
vec3 L = normalize(vec3(sun_pos));
vec3 col = texture2D(tex, vec2((L.y + 1.0) / 2.0, V.y));
float vl = clamp(dot(V, L), 0, 1);
vec3 paint = texture2D(tex, uv * 3).a;
uv += 20;
vec3 paint2 = texture2D(tex, uv * 5).a;
// Get the general cloud mask
float hello = texture2D(glow_tex, (uv_cl + paint2 * 0.07) *2).g;
float cld_mask = texture2D(glow_tex, (uv_anim + hello * 0.007 )).r;
vec2 fast = vec2(-uv_fast.x, uv_fast.y);// + (hello * 0.007);
float cld_fast = texture2D(glow_tex, fast ).r;
cld_mask = (cld_mask * hello * 0.5);
cld_fast = (cld_fast + hello );
col = cld_mask + col*(1 - cld_mask);
col = cld_fast + col*(1 - cld_fast);
gl_FragColor = vec4( (col * paint2 * paint), 1.0);
//gl_FragColor = vec4(vec3(ou), 1.0);
}

49
data/shaders/skybox.vert Normal file
View File

@@ -0,0 +1,49 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2013 the SuperTuxKart team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Creates a bubble (wave) effect by distorting the texture depending on time
uniform float time;
varying vec2 uv;
varying vec2 uv_anim;
varying vec2 uv_cl;
varying vec2 uv_fast;
varying vec3 vertex;
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 );
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_fast = gl_TexCoord[0].st + vec2(0.005*time, 0);
}