Huge merge from trunk, part 2.2 (splitting commits because they keep failing)

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/battleAI@14668 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
nixt
2013-12-08 20:33:54 +00:00
parent 65a7bd0d84
commit 09a966b2d7
76 changed files with 29962 additions and 48366 deletions

View File

@@ -11,9 +11,11 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "STKRelease")
endif()
option(USE_WIIUSE "Support for wiimote input devices" OFF)
option(USE_WIIUSE "Support for wiimote input devices" ON)
option(USE_FRIBIDI "Support for right-to-left languages" ON)
option(USE_CPP2011 "Activate C++ 2011 mode (GCC only)" OFF)
if(UNIX)
option(USE_CPP2011 "Activate C++ 2011 mode (GCC only)" OFF)
endif()
if(MSVC)
# Normally hide the option to build wiiuse on VS, since it depends
# on the installation of the Windows DDK (Driver Developer Kit),
@@ -117,8 +119,10 @@ if(USE_FRIBIDI)
endif()
endif()
if(USE_CPP2011)
add_definitions("-std=gnu++11")
if(UNIX)
if(USE_CPP2011)
add_definitions("-std=gnu++11")
endif()
endif()
# OpenGL
@@ -167,7 +171,7 @@ source_group_hierarchy(STK_SOURCES STK_HEADERS)
if(APPLE)
# icon files to copy in the bundle
set(OSX_ICON_FILES ${PROJECT_SOURCE_DIR}/src/ide/Xcode/stk.icns)
set(OSX_ICON_FILES ${PROJECT_SOURCE_DIR}/data/supertuxkart.icns)
set_source_files_properties(${OSX_ICON_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
set(STK_SOURCES ${STK_SOURCES} ${OSX_ICON_FILES})
@@ -189,7 +193,7 @@ if(APPLE)
# configure CMake to use a custom Info.plist
set_target_properties(supertuxkart PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/src/ide/Xcode/SuperTuxKart-Info.plist)
MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/data/SuperTuxKart-Info.plist)
if(CMAKE_GENERATOR MATCHES "Xcode")
add_custom_command(TARGET supertuxkart POST_BUILD
@@ -263,6 +267,9 @@ if(USE_WIIUSE)
endif()
if(MSVC)
target_link_libraries(supertuxkart iphlpapi.lib)
endif()
# Optional tools
add_subdirectory(tools/font_tool)
@@ -290,6 +297,7 @@ install(TARGETS supertuxkart RUNTIME DESTINATION ${STK_INSTALL_BINARY_DIR} BUNDL
install(DIRECTORY ${STK_DATA_DIR} DESTINATION ${STK_INSTALL_DATA_DIR} PATTERN ".svn" EXCLUDE)
install(FILES ${PROJECT_BINARY_DIR}/supertuxkart.desktop DESTINATION share/applications)
install(FILES data/supertuxkart_32.png data/supertuxkart_128.png DESTINATION share/pixmaps)
install(FILES data/supertuxkart.appdata DESTINATION share/appdata)
set(PREFIX ${CMAKE_INSTALL_PREFIX})
configure_file(data/supertuxkart_desktop.template supertuxkart.desktop)

View File

@@ -1,3 +1,25 @@
SuperTuxkart 0.8.1
~~~~~~~~~~~~~~~
* New track STK Enterprise
* Updated track The old mines
* Updated Lighthouse track
* Updated Zen Garden track
* New Soccer mode
* New Egg Hunt mode
* New karts Xue and Sara
* Updated Beastie kart
* Added Tutorial
* Added new Supertux difficulty
* New bubblegum shield weapon
* New Speeodmeter and nitro meter
* Add ability to filter addons
* Updated nitro models
* Add ability to save and resume Grand Prix
* Improve skid marks and nitro effects
* Wiimote support
SuperTuxkart 0.8
~~~~~~~~~~~~~~~
* Story mode and new challenge set

View File

@@ -3,13 +3,25 @@
# - SRCS list of source files
# - HDRS list of header files
function(source_group_hierarchy SRCS HDRS)
foreach(source_file ${${SRCS}})
source_group_file(${source_file} "Source Files\\")
endforeach()
if(MSVC)
# This removes the 'Source Files' folder, which is
# not really necessary. Also, put header and source
# files into the same folder
foreach(source_file ${${SRCS}})
source_group_file(${source_file} "")
endforeach()
foreach(header_file ${${HDRS}})
source_group_file(${header_file} "")
endforeach()
else()
foreach(source_file ${${SRCS}})
source_group_file(${source_file} "Source Files\\")
endforeach()
foreach(header_file ${${HDRS}})
source_group_file(${header_file} "Source Files\\")
endforeach()
endif()
foreach(header_file ${${HDRS}})
source_group_file(${header_file} "Header Files\\")
endforeach()
endfunction()
# Determine source_group depending on file path

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +1,26 @@
// 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 main_texture;
uniform sampler2D tex;
uniform float transparency;
varying vec2 uv;
void main()
{
gl_FragColor = texture2D(main_texture, uv);
gl_FragColor.a *= transparency;
gl_FragColor = texture2D(tex, uv);
gl_FragColor.a *= transparency;
}

View File

@@ -1,3 +1,21 @@
// 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;

View File

@@ -1,36 +1,8 @@
uniform vec4 fogColor;
uniform float fogFrom;
uniform float fogTo;
uniform int fog;
uniform sampler2D tex;
varying vec4 coord;
void main()
{
vec4 color = texture2D(tex, gl_TexCoord[0].st);
vec4 solidColor = vec4(color.r, color.g, color.b, 1);
vec4 color = texture2D(tex, gl_TexCoord[0].st);
if (fog == 1)
{
if (coord.z > fogTo)
{
gl_FragColor = fogColor;
gl_FragColor.a = color.a;
}
else if (coord.z > fogFrom)
{
float fogIntensity = (coord.z - fogFrom) / (fogTo - fogFrom);
vec4 color2 = fogIntensity*fogColor + (1.0 - fogIntensity)*solidColor;
color2.a = color.a;
gl_FragColor = color2;
}
else
{
gl_FragColor = color;
}
}
else
{
gl_FragColor = color;
}
gl_FragColor = color;
}

View File

@@ -1,15 +1,11 @@
uniform float angle;
uniform float amplitude;
varying vec4 coord;
uniform vec3 windDir;
void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
vec4 vertexPosition = ftransform(); //gl_ModelViewMatrix * gl_Vertex;
vertexPosition += vec4(1,0,0,0) * amplitude * gl_Color.r * sin(angle);
gl_Position = vertexPosition;
gl_FrontColor = vec4(1,1,1,1);
gl_BackColor = vec4(1,1,1,1);
coord = vertexPosition;
}
gl_TexCoord[0] = gl_MultiTexCoord0;
vec4 vertexPosition = gl_Vertex;
vertexPosition.xyz += windDir * gl_Color.r;
gl_Position = gl_ModelViewProjectionMatrix * vertexPosition;
}

View File

@@ -1,3 +1,21 @@
// 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.
// Jean-manuel clemencon (c) supertuxkart 2013
// bubble gum shield
// TODO: Add a nice texture and soft edges when intersect with geometry

View File

@@ -1,3 +1,21 @@
// 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.
// Jean-manuel clemencon (c) supertuxkart 2013
// Creates a bubble gum shield effect
// ---

View File

@@ -1,3 +1,21 @@
// 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.
// Jean-manuel clemencon supertuxkart
// Creates a cone lightbeam effect by smoothing edges
// Original idea: http://udn.epicgames.com/Three/VolumetricLightbeamTutorial.html

View File

@@ -1,4 +1,22 @@
// Jean-manuel clemencon supertuxkart
// 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.
// Jean-manuel clemencon (C) Copyright supertuxkart
// Creates a cone lightbeam effect by smoothing edges
varying vec2 uv;

View File

@@ -1,3 +1,21 @@
// 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.
// motion_blur.frag
// The actual boost amount (which linearly scales the blur to be shown).
@@ -23,7 +41,7 @@ uniform float mask_radius;
uniform float max_tex_height;
// Number of samples used for blurring
#define NB_SAMPLES 12
#define NB_SAMPLES 8
void main()
{
@@ -32,14 +50,6 @@ void main()
// 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)
{
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 :)

View File

@@ -1,3 +1,21 @@
// 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.
// motion_blur.vert
void main()

View File

@@ -4,7 +4,7 @@
uniform sampler2D BumpTex; //The bump-map
uniform sampler2D DecalTex; //The texture
uniform sampler2D LightMapTex;
int HasLightMap;
uniform int HasLightMap;
// New bumpmapping
varying vec3 lightVec;
@@ -19,18 +19,18 @@ void main()
normal = normalize (normal);
// compute diffuse lighting
float lamberFactor = max (dot (lightVec, normal), 0.0) ;
float lamberFactor = max (dot (lightVec, normal), 0.0);
vec4 diffuseMaterial;
diffuseMaterial = texture2D (DecalTex, gl_TexCoord[0].st);
diffuseMaterial = texture2D (DecalTex, gl_TexCoord[0].st);
if (HasLightMap < 1)
{
// 0.5 is the ambient light
gl_FragColor = diffuseMaterial * (0.5 + lamberFactor*0.5);
}
else
{
gl_FragColor = diffuseMaterial * (0.5 + lamberFactor*0.5) * texture2D(LightMapTex, gl_TexCoord[0].st);
}
if (HasLightMap < 1)
{
// 0.5 is the ambient light
gl_FragColor = diffuseMaterial * (0.5 + lamberFactor*0.5);
}
else
{
gl_FragColor = diffuseMaterial * (0.5 + lamberFactor*0.5) * texture2D(LightMapTex, gl_TexCoord[0].st);
}
}

View File

@@ -1,3 +1,20 @@
// 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.
// skinning.vert
#define MAX_JOINT_NUM 36

View File

@@ -1,3 +1,19 @@
// 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 texture;

View File

@@ -1,3 +1,21 @@
// 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.
varying vec3 normal;
varying vec4 vertex_color;
varying vec3 eyeVec;

View File

@@ -1,28 +1,48 @@
varying vec3 nor;
uniform float far;
uniform float objectid;
uniform sampler2D tex_layout;
uniform sampler2D tex_detail0;
uniform sampler2D tex_detail1;
uniform sampler2D tex_detail2;
uniform sampler2D tex_detail3;
uniform sampler2D tex_detail4;
varying vec3 normal;
varying vec3 lightdir2;
varying vec4 vertex_color;
//uniform sampler2D tex_detail4;
void main()
{
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);
const float near = 1.0;
gl_FragColor = (splatting.r * detail0 +
splatting.g * detail1 +
splatting.b * detail2 +
(1.0 - splatting.r - splatting.g - splatting.b) * detail3 +
(1.0 - splatting.a) * detail4)
* min(1.0, 0.2 + dot(lightdir2, normal)) * vertex_color; // 0.2 is the ambient light.
vec4 encdepth(float v) {
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
enc = fract(enc);
enc -= enc.yzww * vec4(1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0);
return enc;
}
void main() {
float linear_z = (2.0 * near) / (far + near - gl_FragCoord.z * (far - near));
// Tune for better inside range without losing outdoors
linear_z *= 2.0;
// 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 detail4 = vec4(0.0);
vec4 splatted = (splatting.r * detail0 +
splatting.g * detail1 +
splatting.b * detail2 +
(1.0 - splatting.r - splatting.g - splatting.b) * detail3 +
(1.0 - splatting.a) * detail4)
* gl_Color;
gl_FragData[0] = splatted;
gl_FragData[1] = vec4(nor, linear_z);
gl_FragData[2] = vec4(encdepth(gl_FragCoord.z).xyz, objectid);
}

View File

@@ -1,3 +1,21 @@
// 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.
varying vec3 normal;
varying vec4 vertex_color;
varying vec3 lightdir2;

View File

@@ -16,11 +16,11 @@ 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 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;
// scale normals
normal.y = 4.0*normal.y;
normal2.y = 4.0*normal2.y;
normal = (normalize(normal) + normalize(normal2))/2.0;
@@ -29,31 +29,28 @@ void main()
vec4 diffuseMaterial;
vec4 diffuseLight;
diffuseMaterial = texture2D (DecalTex, gl_TexCoord[0].st + vec2(delta1.x, 0.0));
diffuseLight = vec4(1.0, 1.0, 1.0, 1.0);
diffuseMaterial = texture2D (DecalTex, gl_TexCoord[0].st + vec2(delta1.x, 0.0));
diffuseLight = vec4(1.0, 1.0, 1.0, 1.0);
//if (lamberFactor < 0.7)
//{
// lamberFactor = 0.0;
//}
vec3 col = diffuseMaterial.xyz * (0.3 + lamberFactor*0.7);
gl_FragColor = diffuseMaterial * (0.3 + lamberFactor*0.7);
// specular (phong)
vec3 R = normalize(reflect(lightVec, normal));
float specular = max(dot(R, eyeVec), 0.0);
// specular (phong)
vec3 R = normalize(reflect(lightVec, normal));
float specular = max(dot(R,eyeVec),0.0);
// weak specular
specular = specular*specular;
specular = specular*specular;
float specular_weak = specular*0.05;
col += vec3(specular_weak, specular_weak, specular_weak);
if (specular > 0.0)
{
// weak specular
specular = specular*specular;
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;
col += vec3(specular_strong, specular_strong, specular_strong);
// strong specular
specular = specular*specular;
float specular_strong = specular*0.3;
gl_FragColor += vec4(specular_strong, specular_strong, specular_strong, 0.0);
}
float summed = dot(vec3(1.0), col) / 3.0;
float alpha = 0.9 + 0.1 * smoothstep(0.0, 1.0, summed);
gl_FragColor = vec4(col, alpha);
}

View File

@@ -1,25 +1,30 @@
// Shader based on work by Fabien Sanglard
// Released under the terms of CC-BY 3.0
uniform float speed;
uniform float height;
uniform float waveLength;
uniform vec3 lightdir;
varying vec3 lightVec;
varying vec3 halfVec;
varying vec3 eyeVec;
uniform vec3 lightdir;
void main()
{
vec4 pos = gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
pos.y += (sin(pos.x/waveLength + speed) + cos(pos.z/waveLength + speed)) * height;
vec3 vertexPosition = vec3(gl_ModelViewMatrix * pos);
// Building the matrix Eye Space -> Tangent Space
vec3 n = normalize (gl_NormalMatrix * gl_Normal);
// gl_MultiTexCoord1.xyz
// 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);
@@ -29,7 +34,7 @@ void main()
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
@@ -44,5 +49,7 @@ void main()
//normalize (v);
halfVec = v ;
gl_Position = ftransform();
}
gl_Position = gl_ModelViewProjectionMatrix * pos;
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[1] = gl_MultiTexCoord1;
}

View File

@@ -1,75 +0,0 @@
// Shader based on work by Fabien Sanglard
// Released under the terms of CC-BY 3.0
uniform sampler2D BumpTex1; // Normal map 1
uniform sampler2D BumpTex2; // Normal map 2
uniform sampler2D DecalTex; //The texture
uniform vec2 delta1;
uniform vec2 delta2;
varying vec3 lightVec;
varying vec3 halfVec;
varying vec3 eyeVec;
varying vec4 coord;
uniform vec4 fogColor;
uniform float fogFrom;
uniform float fogTo;
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;
vec4 diffuseLight;
diffuseMaterial = texture2D (DecalTex, gl_TexCoord[0].st + vec2(delta1.x, 0.0));
diffuseLight = vec4(1.0, 1.0, 1.0, 1.0);
//if (lamberFactor < 0.7)
//{
// lamberFactor = 0.0;
//}
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
specular = specular*specular;
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;
}
else if (coord.z > fogFrom)
{
float fogIntensity = (coord.z - fogFrom) / (fogTo - fogFrom);
gl_FragColor = fogIntensity*fogColor + (1.0 - fogIntensity)*gl_FragColor;
}
}

View File

@@ -1,49 +0,0 @@
// Shader based on work by Fabien Sanglard
// Released under the terms of CC-BY 3.0
varying vec3 lightVec;
varying vec3 halfVec;
varying vec3 eyeVec;
varying vec4 coord;
uniform vec3 lightdir;
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);
v.y = dot (lightdir, b);
v.z = dot (lightdir, n);
lightVec = normalize (v);
vertexPosition = normalize(vertexPosition);
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);
v.x = dot (halfVector, t);
v.y = dot (halfVector, b);
v.z = dot (halfVector, n);
// No need to normalize, t,b,n and halfVector are normal vectors.
//normalize (v);
halfVec = v ;
gl_Position = ftransform();
coord = gl_Position;
}