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

This commit is contained in:
Flakebi 2014-08-30 23:47:32 +02:00
commit dc4a30202f
261 changed files with 7341 additions and 5662 deletions

5
.gitignore vendored
View File

@ -1,8 +1,5 @@
bld*/
build/
build-32/
build-64/
build-win/
build*/
cmake_build/
dependencies/
CMakeFiles/

View File

@ -22,11 +22,19 @@ before_install:
- sudo apt-get update -qq
- sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev
script:
# Build commands
- mkdir build
- cd build
# First a debug build:
- mkdir build-debug
- cd build-debug
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DCHECK_ASSETS=off
- make VERBOSE=1 -j 4
# Then a release build:
- cd ..
- mkdir build-release
- cd build-release
- cmake .. -DCMAKE_BUILD_TYPE=Release -DCHECK_ASSETS=off
- make VERBOSE=1 -j 4
notifications:
irc:
channels:

View File

@ -17,7 +17,6 @@ option(CHECK_ASSETS "Check if assets are installed in ../stk-assets" ON)
if(UNIX)
option(USE_CPP2011 "Activate C++ 2011 mode (GCC only)" OFF)
option(USE_XRANDR "Use xrandr instead of vidmode" OFF)
endif()
if(MSVC)
# Normally hide the option to build wiiuse on VS, since it depends
@ -29,6 +28,11 @@ else()
set(WIIUSE_BUILD ON)
endif()
if(UNIX AND NOT APPLE)
option(USE_XRANDR "Use xrandr instead of vidmode" ON)
option(USE_ASAN "Build with Leak/Address sanitizer" OFF)
endif()
set(STK_SOURCE_DIR "src")
set(STK_DATA_DIR "${PROJECT_SOURCE_DIR}/data")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
@ -118,10 +122,6 @@ if(USE_FRIBIDI)
endif()
endif()
# Xrandr
if(UNIX AND USE_XRANDR)
find_package(Xrandr REQUIRED)
endif()
if(UNIX)
# if(USE_CPP2011)
@ -134,13 +134,17 @@ find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})
if(UNIX AND NOT APPLE)
find_library(IRRLICHT_XF86VM_LIBRARY Xxf86vm)
mark_as_advanced(IRRLICHT_XF86VM_LIBRARY)
else()
set(IRRLICHT_XF86VM_LIBRARY "")
if(USE_XRANDR)
find_package(Xrandr REQUIRED)
if(NOT XRANDR_FOUND)
message(FATAL_ERROR "XRANDR not found.")
endif()
else()
find_library(IRRLICHT_XF86VM_LIBRARY Xxf86vm)
mark_as_advanced(IRRLICHT_XF86VM_LIBRARY)
endif()
endif()
# Set some compiler options
if(UNIX)
@ -153,12 +157,12 @@ if(WIN32)
# And shut up about unsafe stuff
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
# VS will automatically add NDEBUG for release mode, but only _DEBUG in debug mode.
# Since STK uses DEBUG, this is added for debug compilation only:
# VS will automatically add NDEBUG for release mode, but only _DEBUG in debug mode.
# Since STK uses DEBUG, this is added for debug compilation only:
set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUG)
else()
# All non VS generators used create only a single compile mode, so
# compile flags can be simplye be added
# compile flags can be simplye be added
if(CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-DDEBUG)
else()
@ -169,6 +173,9 @@ endif()
# TODO: remove this switch
add_definitions(-DHAVE_OGGVORBIS)
if(WIN32)
configure_file("${STK_SOURCE_DIR}/windows_installer/icon_rc.template" "${PROJECT_BINARY_DIR}/tmp/icon.rc")
endif()
# Provides list of source and header files (STK_SOURCES and STK_HEADERS)
include(sources.cmake)
@ -224,7 +231,7 @@ else()
endif()
# Build the final executable
add_executable(supertuxkart ${STK_SOURCES} ${STK_HEADERS})
add_executable(supertuxkart ${STK_SOURCES} ${STK_RESOURCES} ${STK_HEADERS})
target_link_libraries(supertuxkart ${PTHREAD_LIBRARY})
endif()
@ -245,10 +252,21 @@ target_link_libraries(supertuxkart
stkirrlicht
${CURL_LIBRARIES}
${OGGVORBIS_LIBRARIES}
${IRRLICHT_XF86VM_LIBRARY}
${OPENAL_LIBRARY}
${OPENGL_LIBRARIES})
if(UNIX AND NOT APPLE)
if(USE_XRANDR)
target_link_libraries(supertuxkart ${XRANDR_LIBRARIES})
else()
target_link_libraries(supertuxkart ${IRRLICHT_XF86VM_LIBRARY})
endif()
if(USE_ASAN)
add_definitions("-fsanitize=address")
add_definitions("-fno-omit-frame-pointer")
target_link_libraries(supertuxkart "-fsanitize=address")
endif()
endif()
if(APPLE)
# In theory it would be cleaner to let CMake detect the right dependencies. In practice, this means that if a OSX user has
@ -284,11 +302,6 @@ if(USE_WIIUSE)
endif()
# Xrandr
if(UNIX AND USE_XRANDR)
target_link_libraries(supertuxkart ${XRANDR_LIBRARIES})
endif()
if(MSVC)
target_link_libraries(supertuxkart iphlpapi.lib)
add_custom_command(TARGET supertuxkart POST_BUILD
@ -355,11 +368,8 @@ install(DIRECTORY ${STK_DATA_DIR} DESTINATION ${STK_INSTALL_DATA_DIR} PATTERN ".
if(STK_ASSETS_DIR AND CHECK_ASSETS)
install(DIRECTORY ${STK_ASSETS_DIR} DESTINATION ${STK_INSTALL_DATA_DIR}/data PATTERN ".svn" EXCLUDE PATTERN ".git" EXCLUDE)
endif()
install(FILES ${PROJECT_BINARY_DIR}/supertuxkart.desktop DESTINATION share/applications)
install(FILES ${STK_DATA_DIR}/supertuxkart.desktop DESTINATION share/applications)
install(FILES data/supertuxkart_32.png DESTINATION share/icons/hicolor/32x32 RENAME supertuxkart.png)
install(FILES data/supertuxkart_128.png DESTINATION share/icons/hicolor/128x128 RENAME supertuxkart.png)
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)
add_dependencies(supertuxkart supertuxkart.desktop)

View File

@ -23,7 +23,7 @@ Ubuntu command:
```
sudo apt-get install autoconf automake build-essential cmake libogg-dev libvorbis-dev libopenal-dev libxxf86vm-dev \
libgl1-mesa-dev libglu1-mesa-dev libcurl4-openssl-dev libfribidi-dev libbluetooth-dev
libgl1-mesa-dev libglu1-mesa-dev libcurl4-openssl-dev libfribidi-dev libbluetooth-dev libxrandr-dev
```
Unpack the files from the tarball like this:

View File

@ -1,39 +1,33 @@
<?xml version="1.0"?>
<!--
Particle system to simulate it's raining heavily over an item/kart.
It should be applied no matter if kart is flying or on (any) ground,
and rotate to always fire up, it just simulates the rain bouncing
off the kart and being fired by wheels. It could also be applied to
bowling balls, for example.
-->
<particles emitter="box" box_x="0.5" box_y="1.0" box_z="1.0">
<spreading angle="10" />
<!-- For sky particles, the size of the box is ignored -->
<particles emitter="box">
<spreading angle="3" />
<velocity x="0.000"
y="0.009"
z="0.000" />
<velocity x="-0.00"
y="-0.05"
z="-0.00" />
<material file="water-splash.png" />
<material file="rain.png" clampu="Y" clampv="Y" />
<!-- Amount of particles emitted per second -->
<rate min="50"
max="60" />
<rate min="2000"
max="3000" />
<!-- Minimal and maximal lifetime of a particle, in milliseconds. -->
<lifetime min="1000"
max="1000" />
<lifetime min="10000"
max="10000" />
<!-- Size of the particles -->
<size min="0.35"
max="0.70" />
<size min="0.20"
max="0.40" />
<color min="255 255 255"
max="255 255 255" />
max="255 255 255" />
<!-- How much time in milliseconds before the particle is fully faded out -->
<fadeout time="750" />
<fadeout time="100" />
<gravity strength="-0.01"
only-force-time="500" />
</particles>

View File

@ -131,40 +131,21 @@
<spacer height="4" width="10" />
<div layout="horizontal-row" width="100%" proportion="1">
<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="ubo"/>
<spacer width="10" height="10"/>
<label text="Uniform buffer objects" I18N="Video settings"/>
</div>
<spacer height="4" width="10" />
<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="texture_compression"/>
<spacer width="10" height="10"/>
<label text="Texture compression" I18N="Video settings"/>
</div>
</div>
<spacer height="4" width="10" />
<div layout="horizontal-row" width="100%" proportion="1">
<spacer height="4" width="10" />
<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="hd-textures"/>
<spacer width="10" height="10"/>
<label text="Use high definition textures" I18N="Video settings"/>
</div>
<spacer height="4" width="10" />
<!--
<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="anim_gfx"/>
<spacer width="10" height="10"/>
<label text="Animated Scenery" I18N="Video settings"/>
</div>
-->
</div>
<spacer height="20" width="10" />
<div layout="horizontal-row" width="100%" proportion="1">

View File

@ -1,7 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<stkgui>
<div x="2%" y="10%" width="96%" height="80%" layout="vertical-row" >
<label id="title" width="100%"/>
<gauge id="value_slider" min_value="0" max_value="100" width="100%" />
<div proportion="1" width="100%" layout="horizontal-row">
<label id="Red" text="Red"/>
<spacer width="25"/>
<gauge id="red_slider" min_value="0" max_value="100" proportion="1"/>
</div>
<div proportion="1" width="100%" layout="horizontal-row">
<label id="Green" text="Green"/>
<spacer width="25"/>
<gauge id="green_slider" min_value="0" max_value="100" proportion="1"/>
</div>
<div proportion="1" width="100%" layout="horizontal-row">
<label id="Blue" text="Blue"/>
<spacer width="25"/>
<gauge id="blue_slider" min_value="0" max_value="100" proportion="1"/>
</div>
<div proportion="1" width="100%" layout="horizontal-row">
<label id="SSAO radius" text="SSAO Radius"/>
<spacer width="50"/>
<gauge id="ssao_radius" min_value="0" max_value="100" proportion="1" />
</div>
<div proportion="1" width="100%" layout="horizontal-row">
<label id="SSAO k" text="SSAO K"/>
<spacer width="25"/>
<gauge id="ssao_k" min_value="0" max_value="100" proportion="1"/>
</div>
<div proportion="1" width="100%" layout="horizontal-row">
<label id="SSAO Sigma" text="SSAO sigma"/>
<spacer width="50"/>
<gauge id="ssao_sigma" min_value="0" max_value="100" proportion="1"/>
</div>
</div>
</stkgui>

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<stkgui>
<div x="2%" y="2%" width="96%" height="96%" layout="vertical-row">
<spacer width="10" proportion="1"/>
<button id="continue" x="20" width="250" align="left" text="Continue"/>
<div x="2%" y="2%" width="96%" height="96%" layout="horizontal-row">
<button id="continue" width="250" align="bottom" text="Continue"/>
<spacer width="20"/>
<button id="save" width="250" align="bottom" text="Save Grand Prix"/>
</div>
</stkgui>

View File

@ -1,7 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<stkgui>
<div x="2%" y="2%" width="96%" height="96%" layout="vertical-row">
<spacer width="10" proportion="1"/>
<button id="continue" x="20" width="250" align="left" text="Continue"/>
<div x="2%" y="2%" width="96%" height="96%" layout="horizontal-row">
<button id="continue" width="250" align="bottom" text="Continue"/>
<spacer width="20"/>
<button id="save" width="250" align="bottom" text="Save Grand Prix"/>
</div>
</stkgui>

View File

@ -54,6 +54,8 @@
I18N="Login dialog" text="Add user" label_location="bottom"/>
<icon-button id="delete" width="64" height="64" icon="gui/gp_remove_track.png"
I18N="Login dialog" text="Delete" label_location="bottom"/>
<icon-button id="recover" width="64" height="64" icon="gui/main_options.png"
I18N="Login dialog" text="Recovery" label_location="bottom"/>
<icon-button id="rename" width="64" height="64" icon="gui/gp_rename.png"
I18N="Login dialog" text="Rename" label_location="bottom"/>
<icon-button id="cancel" width="64" height="64" icon="gui/main_quit.png"

View File

@ -1,18 +1,16 @@
uniform mat4 ModelViewMatrix;
uniform mat4 ProjectionMatrix;
uniform vec3 Position;
uniform vec2 Size;
#if __VERSION__ >= 130
#if __VERSION__ >= 330
layout(location = 0) in vec2 Corner;
layout(location = 3) in vec2 Texcoord;
#else
in vec2 Corner;
in vec2 Texcoord;
out vec2 uv;
#else
attribute vec2 Corner;
attribute vec2 Texcoord;
varying vec2 uv;
#endif
out vec2 uv;
void main(void)
{

View File

@ -2,16 +2,6 @@ uniform sampler2D tex_128;
uniform sampler2D tex_256;
uniform sampler2D tex_512;
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
out vec4 FragColor;
void main()

View File

@ -1,14 +1,14 @@
uniform vec2 center;
uniform vec2 size;
#if __VERSION__ >= 130
in vec2 position;
#if __VERSION__ >= 330
layout(location = 0) in vec2 Position;
#else
attribute vec2 position;
in vec2 Position;
#endif
void main()
{
gl_Position = vec4(position * size + center, 0., 1.);
gl_Position = vec4(Position * size + center, 0., 1.);
}

View File

@ -3,24 +3,22 @@ uniform vec2 size;
uniform vec2 texcenter;
uniform vec2 texsize;
#if __VERSION__ >= 130
in vec2 position;
in vec2 texcoord;
in uvec4 color;
out vec2 uv;
out vec4 col;
#if __VERSION__ >= 330
layout(location=0) in vec2 Position;
layout(location=3) in vec2 Texcoord;
layout(location=2) in uvec4 Color;
#else
attribute vec2 position;
attribute vec2 texcoord;
attribute uvec4 color;
varying vec2 uv;
varying vec4 col;
in vec2 Position;
in vec2 Texcoord;
in uvec4 Color;
#endif
out vec2 uv;
out vec4 col;
void main()
{
col = vec4(color) / 255.;
uv = texcoord * texsize + texcenter;
gl_Position = vec4(position * size + center, 0., 1.);
col = vec4(Color) / 255.;
uv = Texcoord * texsize + texcenter;
gl_Position = vec4(Position * size + center, 0., 1.);
}

View File

@ -1,5 +1,10 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D Albedo;
layout(bindless_sampler) uniform sampler2D Detail;
#else
uniform sampler2D Albedo;
uniform sampler2D Detail;
#endif
#if __VERSION__ >= 130
in vec2 uv;
@ -16,6 +21,11 @@ vec3 getLightFactor(float specMapValue);
void main(void)
{
vec4 color = texture(Albedo, uv);
#ifdef GL_ARB_bindless_texture
#ifdef SRGBBindlessFix
color.xyz = pow(color.xyz, vec3(2.2));
#endif
#endif
vec4 detail = texture(Detail, uv_bis);
color *= detail;
vec3 LightFactor = getLightFactor(1. - color.a);

View File

@ -3,15 +3,6 @@ uniform float greenLmn[9];
uniform float redLmn[9];
uniform sampler2D ntex;
uniform mat4 TransposeViewMatrix;
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
out vec4 Diff;

View File

@ -5,16 +5,6 @@ uniform sampler2D tex;
uniform vec2 dir;
uniform vec2 dir2;
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#if __VERSION__ >= 130
in vec2 uv;
in vec2 uv_bis;

View File

@ -1,20 +1,3 @@
#ifdef UBO_DISABLED
uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 InverseViewMatrix;
uniform mat4 InverseProjectionMatrix;
#else
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif
uniform mat4 ModelMatrix;
#if __VERSION__ >= 330

View File

@ -1,16 +1,6 @@
uniform sampler2D tex;
uniform sampler2D dtex;
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
out vec4 FragColor;
float focalDepth = 10.;

View File

@ -1,21 +1,12 @@
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
layout(location=0) in vec3 Position;
layout(location = 1) in float lifetime;
layout(location = 2) in float size;
in vec2 quadcorner;
in vec2 texcoord;
in vec3 position;
in float lifetime;
in float size;
layout(location = 3) in vec2 Texcoord;
layout(location = 4) in vec2 quadcorner;
in vec3 rotationvec;
in float anglespeed;
layout(location = 5) in vec3 rotationvec;
layout(location = 6) in float anglespeed;
out float lf;
out vec2 tc;
@ -23,9 +14,9 @@ out vec3 pc;
void main(void)
{
tc = texcoord;
tc = Texcoord;
lf = lifetime;
vec3 newposition = position;
vec3 newposition = Position;
// from http://jeux.developpez.com/faq/math
float angle = lf * anglespeed;

View File

@ -7,24 +7,6 @@ uniform float start;
uniform float end;
uniform vec3 col;
#ifdef UBO_DISABLED
uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 InverseViewMatrix;
uniform mat4 InverseProjectionMatrix;
uniform vec2 screen;
#else
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif
out vec4 FragColor;

View File

@ -1,13 +1,3 @@
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
uniform int idx;
in vec3 Position;

View File

@ -14,16 +14,6 @@ uniform vec3 extents;
uniform mat4 RHMatrix;
uniform mat4 InvRHMatrix;
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
vec4 SHBasis (const in vec3 dir)
{
float L00 = 0.282095;

View File

@ -1,20 +1,3 @@
#ifdef UBO_DISABLED
uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 InverseViewMatrix;
uniform mat4 InverseProjectionMatrix;
#else
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif
uniform vec3 windDir;
uniform mat4 ModelMatrix;
uniform mat4 InverseModelMatrix;

View File

@ -1,24 +1,12 @@
#ifdef UBO_DISABLED
uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 InverseViewMatrix;
uniform mat4 InverseProjectionMatrix;
uniform vec2 screen;
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D Albedo;
layout(bindless_sampler) uniform sampler2D dtex;
#else
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
uniform sampler2D Albedo;
uniform sampler2D dtex;
#endif
uniform sampler2D Albedo;
uniform vec3 SunDir;
uniform sampler2D dtex;
in vec3 nor;
in vec2 uv;
@ -44,6 +32,11 @@ void main(void)
float scattering = mix(fPowEdotL, fLdotNBack, .5);
vec4 color = texture(Albedo, uv);
#ifdef GL_ARB_bindless_texture
#ifdef SRGBBindlessFix
color.xyz = pow(color.xyz, vec3(2.2));
#endif
#endif
if (color.a < 0.5) discard;
vec3 LightFactor = (scattering * 0.3) + getLightFactor(1.);
FragColor = vec4(color.xyz * LightFactor, 1.);

17
data/shaders/header.txt Normal file
View File

@ -0,0 +1,17 @@
#ifdef UBO_DISABLED
uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 InverseViewMatrix;
uniform mat4 InverseProjectionMatrix;
uniform vec2 screen;
#else
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif

View File

@ -0,0 +1,31 @@
#ifndef GL_ARB_bindless_texture
uniform sampler2D Albedo;
uniform sampler2D Detail;
#endif
#ifdef GL_ARB_bindless_texture
flat in sampler2D handle;
flat in sampler2D secondhandle;
#endif
in vec2 uv;
in vec2 uv_bis;
out vec4 FragColor;
vec3 getLightFactor(float specMapValue);
void main(void)
{
#ifdef GL_ARB_bindless_texture
vec4 color = texture(handle, uv);
#ifdef SRGBBindlessFix
color.xyz = pow(color.xyz, vec3(2.2));
#endif
vec4 detail = texture(secondhandle, uv_bis);
#else
vec4 color = texture(Albedo, uv);
vec4 detail = texture(Detail, uv_bis);
#endif
color *= detail;
vec3 LightFactor = getLightFactor(1. - color.a);
FragColor = vec4(color.xyz * LightFactor, 1.);
}

View File

@ -1,13 +1,3 @@
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
uniform vec3 windDir;
#if __VERSION__ >= 330
@ -19,6 +9,10 @@ layout(location = 3) in vec2 Texcoord;
layout(location = 7) in vec3 Origin;
layout(location = 8) in vec3 Orientation;
layout(location = 9) in vec3 Scale;
#ifdef GL_ARB_bindless_texture
layout(location = 10) in sampler2D Handle;
#endif
#else
in vec3 Position;
in vec3 Normal;
@ -32,6 +26,9 @@ in vec3 Scale;
out vec3 nor;
out vec2 uv;
#ifdef GL_ARB_bindless_texture
flat out sampler2D handle;
#endif
mat4 getWorldMatrix(vec3 translation, vec3 rotation, vec3 scale);
mat4 getInverseWorldMatrix(vec3 translation, vec3 rotation, vec3 scale);
@ -43,4 +40,7 @@ void main()
gl_Position = ProjectionMatrix * ViewMatrix * ModelMatrix * vec4(Position, 1.);
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
uv = Texcoord;
#ifdef GL_ARB_bindless_texture
handle = Handle;
#endif
}

View File

@ -0,0 +1,47 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D dtex;
#else
uniform sampler2D Albedo;
uniform sampler2D dtex;
#endif
uniform vec3 SunDir;
#ifdef GL_ARB_bindless_texture
flat in sampler2D handle;
#endif
in vec3 nor;
in vec2 uv;
out vec4 FragColor;
vec3 getLightFactor(float specMapValue);
void main(void)
{
vec2 texc = gl_FragCoord.xy / screen;
float z = texture(dtex, texc).x;
vec4 xpos = 2.0 * vec4(texc, z, 1.0) - 1.0f;
xpos = InverseProjectionMatrix * xpos;
xpos /= xpos.w;
vec3 eyedir = normalize(xpos.xyz);
// Inspired from http://http.developer.nvidia.com/GPUGems3/gpugems3_ch16.html
float fEdotL = max(0., dot(SunDir, eyedir));
float fPowEdotL = pow(fEdotL, 4.);
float fLdotNBack = max(0., - dot(nor, SunDir) * 0.6 + 0.4);
float scattering = mix(fPowEdotL, fLdotNBack, .5);
#ifdef GL_ARB_bindless_texture
vec4 color = texture(handle, uv);
#ifdef SRGBBindlessFix
color.xyz = pow(color.xyz, vec3(2.2));
#endif
#else
vec4 color = texture(Albedo, uv);
#endif
if (color.a < 0.5) discard;
vec3 LightFactor = (scattering * 0.3) + getLightFactor(1.);
FragColor = vec4(color.xyz * LightFactor, 1.);
}

View File

@ -0,0 +1,35 @@
#ifndef GL_ARB_bindless_texture
uniform sampler2D normalMap;
uniform sampler2D DiffuseForAlpha;
#endif
#ifdef GL_ARB_bindless_texture
flat in sampler2D handle;
flat in sampler2D secondhandle;
#endif
in vec3 tangent;
in vec3 bitangent;
in vec2 uv;
out vec3 EncodedNormal;
vec2 EncodeNormal(vec3 n);
void main()
{
// normal in Tangent Space
#ifdef GL_ARB_bindless_texture
vec3 TS_normal = 2.0 * texture(secondhandle, uv).rgb - 1.0;
float alpha = texture(handle, uv).a;
#else
vec3 TS_normal = 2.0 * texture(normalMap, uv).rgb - 1.0;
float alpha = texture(DiffuseForAlpha, uv).a;
#endif
// Because of interpolation, we need to renormalize
vec3 Frag_tangent = normalize(tangent);
vec3 Frag_normal = normalize(cross(Frag_tangent, bitangent));
vec3 Frag_bitangent = cross(Frag_normal, Frag_tangent);
vec3 FragmentNormal = TS_normal.x * Frag_tangent + TS_normal.y * Frag_bitangent - TS_normal.z * Frag_normal;
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(FragmentNormal)) + 0.5;
EncodedNormal.z = exp2(10. * (1. - alpha) + 1.);
}

View File

@ -1,34 +1,26 @@
#ifdef UBO_DISABLED
uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 InverseViewMatrix;
uniform mat4 InverseProjectionMatrix;
#else
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif
#if __VERSION__ >= 330
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 2) in vec4 Color;
layout(location = 3) in vec2 Texcoord;
layout(location = 5) in vec3 Tangent;
layout(location = 6) in vec3 Bitangent;
layout(location = 7) in vec3 Origin;
layout(location = 8) in vec3 Orientation;
layout(location = 9) in vec3 Scale;
#ifdef GL_ARB_bindless_texture
layout(location = 10) in sampler2D Handle;
layout(location = 11) in sampler2D SecondHandle;
#endif
#else
in vec3 Position;
in vec3 Normal;
in vec4 Color;
in vec2 Texcoord;
in vec3 Tangent;
in vec3 Bitangent;
in vec3 Origin;
in vec3 Orientation;
@ -36,8 +28,14 @@ in vec3 Scale;
#endif
out vec3 nor;
out vec3 tangent;
out vec3 bitangent;
out vec2 uv;
out vec4 color;
#ifdef GL_ARB_bindless_texture
flat out sampler2D handle;
flat out sampler2D secondhandle;
#endif
mat4 getWorldMatrix(vec3 translation, vec3 rotation, vec3 scale);
mat4 getInverseWorldMatrix(vec3 translation, vec3 rotation, vec3 scale);
@ -48,6 +46,12 @@ void main(void)
mat4 TransposeInverseModelView = transpose(getInverseWorldMatrix(Origin, Orientation, Scale) * InverseViewMatrix);
gl_Position = ProjectionMatrix * ViewMatrix * ModelMatrix * vec4(Position, 1.);
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
tangent = (TransposeInverseModelView * vec4(Tangent, 1.)).xyz;
bitangent = (TransposeInverseModelView * vec4(Bitangent, 1.)).xyz;
uv = Texcoord;
color = Color.zyxw;
#ifdef GL_ARB_bindless_texture
handle = Handle;
secondhandle = SecondHandle;
#endif
}

View File

@ -0,0 +1,23 @@
#ifndef GL_ARB_bindless_texture
uniform sampler2D tex;
#endif
#ifdef GL_ARB_bindless_texture
flat in sampler2D handle;
#endif
in vec3 nor;
in vec2 uv;
out vec3 EncodedNormal;
vec2 EncodeNormal(vec3 n);
void main(void)
{
#ifdef GL_ARB_bindless_texture
vec4 col = texture(handle, uv);
#else
vec4 col = texture(tex, uv);
#endif
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(nor)) + 0.5;
EncodedNormal.z = exp2(10. * (1. - col.a) + 1.);
}

View File

@ -0,0 +1,27 @@
#ifndef GL_ARB_bindless_texture
uniform sampler2D Albedo;
#endif
#ifdef GL_ARB_bindless_texture
flat in sampler2D handle;
#endif
in vec2 uv;
in vec4 color;
out vec4 FragColor;
vec3 getLightFactor(float specMapValue);
void main(void)
{
#ifdef GL_ARB_bindless_texture
vec4 col = texture(handle, uv);
#ifdef SRGBBindlessFix
col.xyz = pow(col.xyz, vec3(2.2));
#endif
#else
vec4 col = texture(Albedo, uv);
#endif
col.xyz *= pow(color.xyz, vec3(2.2));
vec3 LightFactor = getLightFactor(1.);
FragColor = vec4(col.xyz * LightFactor, 1.);
}

View File

@ -0,0 +1,26 @@
#ifndef GL_ARB_bindless_texture
uniform sampler2D tex;
#endif
#ifdef GL_ARB_bindless_texture
flat in sampler2D handle;
#endif
in vec2 uv;
in vec4 color;
out vec4 FragColor;
void main(void)
{
#ifdef GL_ARB_bindless_texture
vec4 col = texture(handle, uv);
#ifdef SRGBBindlessFix
col.xyz = pow(col.xyz, vec3(2.2));
#endif
#else
vec4 col = texture(tex, uv);
#endif
col.xyz *= pow(color.xyz, vec3(2.2));
if (col.a < 0.5) discard;
FragColor = vec4(col.xyz, 1.);
}

View File

@ -0,0 +1,35 @@
// See http://www.ozone3d.net/tutorials/glsl_texturing_p04.php for ref
#ifndef GL_ARB_bindless_texture
uniform sampler2D tex;
#endif
#ifdef GL_ARB_bindless_texture
flat in sampler2D handle;
#endif
in vec3 nor;
out vec4 FragColor;
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
vec3 getLightFactor(float specMapValue);
void main() {
vec3 texc = gl_FragCoord.xyz / vec3(screen, 1.);
vec3 u = getPosFromUVDepth(texc, InverseProjectionMatrix).xyz;
vec3 r = reflect(u, nor);
float m = 2.0 * sqrt(r.x * r.x + r.y * r.y + (r.z + 1.0) * (r.z + 1.0));
r.y = - r.y;
#ifdef GL_ARB_bindless_texture
vec4 detail0 = texture(handle, r.xy / m + .5);
#ifdef SRGBBindlessFix
detail0.xyz = pow(detail0.xyz, vec3(2.2));
#endif
#else
vec4 detail0 = texture(tex, r.xy / m + .5);
#endif
vec3 LightFactor = getLightFactor(1.);
FragColor = vec4(detail0.xyz * LightFactor, 1.);
}

View File

@ -0,0 +1,25 @@
#ifndef GL_ARB_bindless_texture
uniform sampler2D tex;
#endif
#ifdef GL_ARB_bindless_texture
flat in sampler2D handle;
#endif
in vec3 nor;
in vec2 uv;
out vec3 EncodedNormal;
vec2 EncodeNormal(vec3 n);
void main() {
#ifdef GL_ARB_bindless_texture
vec4 col = texture(handle, uv);
#else
vec4 col = texture(tex, uv);
#endif
if (col.a < 0.5)
discard;
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(nor)) + 0.5;
EncodedNormal.z = 1.;
}

View File

@ -0,0 +1,28 @@
#ifndef GL_ARB_bindless_texture
uniform sampler2D Albedo;
#endif
#ifdef GL_ARB_bindless_texture
flat in sampler2D handle;
#endif
in vec2 uv;
in vec4 color;
out vec4 FragColor;
vec3 getLightFactor(float specMapValue);
void main(void)
{
#ifdef GL_ARB_bindless_texture
vec4 col = texture(handle, uv);
#ifdef SRGBBindlessFix
col.xyz = pow(col.xyz, vec3(2.2));
#endif
#else
vec4 col = texture(Albedo, uv);
#endif
col.xyz *= pow(color.xyz, vec3(2.2));
if (col.a * color.a < 0.5) discard;
vec3 LightFactor = getLightFactor(1.);
FragColor = vec4(col.xyz * LightFactor, 1.);
}

View File

@ -0,0 +1,28 @@
layout(triangles) in;
layout(triangle_strip, max_vertices=3) out;
#ifdef GL_ARB_bindless_texture
flat in uvec2 hdle[3];
#endif
in vec2 tc[3];
in int layerId[3];
out vec2 uv;
#ifdef GL_ARB_bindless_texture
out flat uvec2 handle;
#endif
void main(void)
{
gl_Layer = layerId[0];
#ifdef GL_ARB_bindless_texture
handle = hdle[0];
#endif
for(int i=0; i<3; i++)
{
uv = tc[i];
gl_Position = gl_in[i].gl_Position;
EmitVertex();
}
EndPrimitive();
}

View File

@ -0,0 +1,21 @@
#ifndef GL_ARB_bindless_texture
uniform sampler2D tex;
#endif
#ifdef GL_ARB_bindless_texture
flat in uvec2 handle;
#endif
in vec2 uv;
in vec4 color;
out vec4 FragColor;
void main(void)
{
#ifdef GL_ARB_bindless_texture
vec4 col = texture(sampler2D(handle), uv);
#else
vec4 col = texture(tex, uv);
#endif
if (col.a < 0.5) discard;
FragColor = vec4(1.);
}

View File

@ -1,11 +1,5 @@
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
};
uniform int layer;
uniform vec3 windDir;
#if __VERSION__ >= 330
layout(location = 0) in vec3 Position;
@ -15,6 +9,10 @@ layout(location = 3) in vec2 Texcoord;
layout(location = 7) in vec3 Origin;
layout(location = 8) in vec3 Orientation;
layout(location = 9) in vec3 Scale;
#ifdef GL_ARB_bindless_texture
layout(location = 10) in uvec2 Handle;
#endif
#else
in vec3 Position;
in vec4 Color;
@ -27,9 +25,15 @@ in vec3 Scale;
#ifdef VSLayer
out vec2 uv;
#ifdef GL_ARB_bindless_texture
flat out uvec2 handle;
#endif
#else
out vec2 tc;
out int layerId;
#ifdef GL_ARB_bindless_texture
flat out uvec2 hdle;
#endif
#endif
mat4 getWorldMatrix(vec3 translation, vec3 rotation, vec3 scale);
@ -39,12 +43,18 @@ void main(void)
{
mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale);
#ifdef VSLayer
gl_Layer = gl_InstanceID & 3;
gl_Layer = layer;
gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * vec4(Position + windDir * Color.r, 1.);
uv = Texcoord;
#ifdef GL_ARB_bindless_texture
handle = Handle;
#endif
#else
layerId = gl_InstanceID & 3;
layerId = layer;
gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * vec4(Position + windDir * Color.r, 1.);
tc = Texcoord;
#ifdef GL_ARB_bindless_texture
hdle = Handle;
#endif
#endif
}

View File

@ -1,11 +1,4 @@
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
};
uniform int layer;
#if __VERSION__ >= 330
layout(location = 0) in vec3 Position;
@ -14,6 +7,10 @@ layout(location = 3) in vec2 Texcoord;
layout(location = 7) in vec3 Origin;
layout(location = 8) in vec3 Orientation;
layout(location = 9) in vec3 Scale;
#ifdef GL_ARB_bindless_texture
layout(location = 10) in uvec2 Handle;
#endif
#else
in vec3 Position;
in vec2 Texcoord;
@ -25,9 +22,15 @@ in vec3 Scale;
#ifdef VSLayer
out vec2 uv;
#ifdef GL_ARB_bindless_texture
flat out uvec2 handle;
#endif
#else
out vec2 tc;
out int layerId;
#ifdef GL_ARB_bindless_texture
flat out uvec2 hdle;
#endif
#endif
mat4 getWorldMatrix(vec3 translation, vec3 rotation, vec3 scale);
@ -37,12 +40,18 @@ void main(void)
{
mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale);
#ifdef VSLayer
gl_Layer = gl_InstanceID & 3;
gl_Layer = layer;
gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * vec4(Position, 1.);
uv = Texcoord;
#ifdef GL_ARB_bindless_texture
handle = Handle;
#endif
#else
layerId = gl_InstanceID & 3;
layerId = layer;
gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * vec4(Position, 1.);
tc = Texcoord;
#ifdef GL_ARB_bindless_texture
hdle = Handle;
#endif
#endif
}

View File

@ -2,16 +2,6 @@ uniform sampler2D tex;
uniform float zn;
uniform float zf;
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
out float Depth;
void main()

View File

@ -1,16 +1,6 @@
uniform sampler2D edgesMap;
uniform sampler2D areaMap;
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#define MAX_SEARCH_STEPS 8.0
#define MAX_DISTANCE 33.0

View File

@ -1,13 +1,3 @@
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
in vec2 Position;
in vec2 Texcoord;

View File

@ -37,16 +37,6 @@ uniform float mask_radius;
uniform mat4 previous_viewproj;
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
out vec4 FragColor;
// Number of samples used for blurring

View File

@ -0,0 +1,22 @@
layout(triangles) in;
layout(line_strip, max_vertices = 6) out;
in vec3 nor[];
void main()
{
for(int i=0; i < gl_in.length(); i++)
{
vec4 pos = gl_in[i].gl_Position;
gl_Position = pos;
EmitVertex();
vec3 normal = normalize(nor[i]);
pos = inverse(ProjectionMatrix) * pos;
pos /= pos.w;
gl_Position = ProjectionMatrix * (pos + .2 * vec4(normal, 0.));
EmitVertex();
EndPrimitive();
}
}

View File

@ -1,5 +1,10 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D normalMap;
layout(bindless_sampler) uniform sampler2D DiffuseForAlpha;
#else
uniform sampler2D normalMap;
uniform sampler2D DiffuseForAlpha;
#endif
in vec3 tangent;
in vec3 bitangent;

View File

@ -1,38 +0,0 @@
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
};
uniform mat4 ModelMatrix;
uniform mat4 InverseModelMatrix;
#if __VERSION__ >= 330
layout(location = 0) in vec3 Position;
layout(location = 3) in vec2 Texcoord;
layout(location = 5) in vec3 Tangent;
layout(location = 6) in vec3 Bitangent;
#else
in vec3 Position;
in vec2 Texcoord;
in vec3 Tangent;
in vec3 Bitangent;
#endif
out vec3 tangent;
out vec3 bitangent;
out vec2 uv;
void main()
{
mat4 ModelViewProjectionMatrix = ProjectionMatrix * ViewMatrix * ModelMatrix;
mat4 TransposeInverseModelView = transpose(InverseModelMatrix * InverseViewMatrix);
uv = Texcoord;
tangent = (TransposeInverseModelView * vec4(Tangent, 1.)).xyz;
bitangent = (TransposeInverseModelView * vec4(Bitangent, 1.)).xyz;
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
}

View File

@ -1,20 +1,3 @@
#ifdef UBO_DISABLED
uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 InverseViewMatrix;
uniform mat4 InverseProjectionMatrix;
#else
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif
uniform mat4 ModelMatrix;
uniform mat4 InverseModelMatrix;
@ -30,15 +13,21 @@ layout(location = 1) in vec3 Normal;
layout(location = 2) in vec4 Color;
layout(location = 3) in vec2 Texcoord;
layout(location = 4) in vec2 SecondTexcoord;
layout(location = 5) in vec3 Tangent;
layout(location = 6) in vec3 Bitangent;
#else
in vec3 Position;
in vec3 Normal;
in vec4 Color;
in vec2 Texcoord;
in vec2 SecondTexcoord;
in vec3 Tangent;
in vec3 Bitangent;
#endif
out vec3 nor;
out vec3 tangent;
out vec3 bitangent;
out vec2 uv;
out vec2 uv_bis;
out vec4 color;
@ -51,6 +40,8 @@ void main(void)
mat4 TransposeInverseModelView = transpose(InverseModelMatrix * InverseViewMatrix);
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
tangent = (TransposeInverseModelView * vec4(Tangent, 1.)).xyz;
bitangent = (TransposeInverseModelView * vec4(Bitangent, 1.)).xyz;
uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy;
uv_bis = SecondTexcoord;
}

View File

@ -1,4 +1,8 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D tex;
#else
uniform sampler2D tex;
#endif
#if __VERSION__ >= 130
in vec3 nor;

View File

@ -1,4 +1,8 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D Albedo;
#else
uniform sampler2D Albedo;
#endif
in vec2 uv;
in vec4 color;
@ -8,7 +12,14 @@ vec3 getLightFactor(float specMapValue);
void main(void)
{
#ifdef GL_ARB_bindless_texture
vec4 col = texture(Albedo, uv);
#ifdef SRGBBindlessFix
col.xyz = pow(col.xyz, vec3(2.2));
#endif
#else
vec4 col = texture(Albedo, uv);
#endif
col.xyz *= pow(color.xyz, vec3(2.2));
vec3 LightFactor = getLightFactor(1.);
FragColor = vec4(col.xyz * LightFactor, 1.);

View File

@ -1,17 +1,22 @@
uniform sampler2D tex;
#if __VERSION__ >= 130
in vec2 uv;
out vec4 FragColor;
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D tex;
#else
varying vec2 uv;
#define FragColor gl_FragColor
uniform sampler2D tex;
#endif
in vec2 uv;
in vec4 color;
out vec4 FragColor;
void main(void)
{
vec4 color = texture(tex, uv);
if (color.a < 0.5) discard;
FragColor = vec4(color.xyz, 1.);
vec4 col = texture(tex, uv);
#ifdef GL_ARB_bindless_texture
#ifdef SRGBBindlessFix
col.xyz = pow(col.xyz, vec3(2.2));
#endif
#endif
col.xyz *= pow(color.xyz, vec3(2.2));
if (col.a < 0.5) discard;
FragColor = vec4(col.xyz, 1.);
}

View File

@ -1,24 +1,10 @@
// See http://www.ozone3d.net/tutorials/glsl_texturing_p04.php for ref
#ifdef UBO_DISABLED
uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 InverseViewMatrix;
uniform mat4 InverseProjectionMatrix;
uniform vec2 screen;
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D tex;
#else
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif
uniform sampler2D tex;
#endif
#if __VERSION__ >= 130
in vec3 nor;
@ -39,6 +25,11 @@ void main() {
float m = 2.0 * sqrt(r.x * r.x + r.y * r.y + (r.z + 1.0) * (r.z + 1.0));
r.y = - r.y;
vec4 detail0 = texture(tex, r.xy / m + .5);
#ifdef GL_ARB_bindless_texture
#ifdef SRGBBindlessFix
detail0.xyz = pow(detail0.xyz, vec3(2.2));
#endif
#endif
vec3 LightFactor = getLightFactor(1.);
FragColor = vec4(detail0.xyz * LightFactor, 1.);

View File

@ -1,4 +1,8 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D tex;
#else
uniform sampler2D tex;
#endif
#if __VERSION__ >= 130
in vec3 nor;

View File

@ -1,19 +1,25 @@
uniform sampler2D Albedo;
#if __VERSION__ >= 130
in vec2 uv;
out vec4 FragColor;
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D Albedo;
#else
varying vec2 uv;
#define FragColor gl_FragColor
uniform sampler2D Albedo;
#endif
in vec2 uv;
in vec4 color;
out vec4 FragColor;
vec3 getLightFactor(float specMapValue);
void main(void)
{
vec4 color = texture(Albedo, uv);
if (color.a < 0.5) discard;
vec4 col = texture(Albedo, uv);
#ifdef GL_ARB_bindless_texture
#ifdef SRGBBindlessFix
col.xyz = pow(col.xyz, vec3(2.2));
#endif
#endif
col.xyz *= pow(color.xyz, vec3(2.2));
if (col.a * color.a < 0.5) discard;
vec3 LightFactor = getLightFactor(1.);
FragColor = vec4(color.xyz * LightFactor, 1.);
FragColor = vec4(col.xyz * LightFactor, 1.);
}

View File

@ -2,32 +2,21 @@ uniform sampler2D tex;
uniform sampler2D dtex;
uniform mat4 invproj;
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
in float lf;
in vec2 tc;
in vec3 pc;
out vec4 FragColor;
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
void main(void)
{
vec2 xy = gl_FragCoord.xy / screen;
float FragZ = gl_FragCoord.z;
float EnvZ = texture(dtex, xy).x;
vec4 FragmentPos = invproj * (2. * vec4(xy, FragZ, 1.0) - 1.);
FragmentPos /= FragmentPos.w;
vec4 EnvPos = invproj * (2. * vec4(xy, EnvZ, 1.0) - 1.);
EnvPos /= EnvPos.w;
float alpha = clamp((EnvPos.z - FragmentPos.z) * 0.3, 0., 1.);
vec2 xy = gl_FragCoord.xy / screen;
float FragZ = gl_FragCoord.z;
vec4 FragmentPos = getPosFromUVDepth(vec3(xy, FragZ), InverseProjectionMatrix);
float EnvZ = texture(dtex, xy).x;
vec4 EnvPos = getPosFromUVDepth(vec3(xy, EnvZ), InverseProjectionMatrix);
float alpha = clamp((EnvPos.z - FragmentPos.z) * 0.3, 0., 1.);
vec4 color = texture(tex, tc) * vec4(pc, 1.0);
FragColor = color * alpha * smoothstep(1., 0.8, lf);
}

View File

@ -1,20 +1,12 @@
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
uniform vec3 color_from;
uniform vec3 color_to;
in vec2 quadcorner;
in vec2 texcoord;
in vec3 position;
in float lifetime;
in float size;
layout(location=0) in vec3 Position;
layout(location = 1) in float lifetime;
layout(location = 2) in float size;
layout(location=3) in vec2 Texcoord;
layout(location = 4) in vec2 quadcorner;
out float lf;
out vec2 tc;
@ -22,12 +14,12 @@ out vec3 pc;
void main(void)
{
tc = texcoord;
lf = lifetime;
tc = Texcoord;
lf = lifetime;
pc = color_from + (color_to - color_from) * lifetime;
vec3 newposition = position;
vec3 newposition = Position;
vec4 viewpos = ViewMatrix * vec4(newposition, 1.0);
viewpos += size * vec4(quadcorner, 0., 0.);
gl_Position = ProjectionMatrix * viewpos;
viewpos += size * vec4(quadcorner, 0., 0.);
gl_Position = ProjectionMatrix * viewpos;
}

View File

@ -9,15 +9,15 @@ uniform float track_x_len;
uniform float track_z_len;
uniform samplerBuffer heightmap;
in vec3 particle_position_initial;
in float lifetime_initial;
in vec3 particle_velocity_initial;
in float size_initial;
layout (location = 4) in vec3 particle_position_initial;
layout (location = 5) in float lifetime_initial;
layout (location = 6) in vec3 particle_velocity_initial;
layout (location = 7) in float size_initial;
in vec3 particle_position;
in float lifetime;
in vec3 particle_velocity;
in float size;
layout (location = 0) in vec3 particle_position;
layout (location = 1) in float lifetime;
layout (location = 2) in vec3 particle_velocity;
layout (location = 3) in float size;
out vec3 new_particle_position;
out float new_lifetime;

View File

@ -3,15 +3,15 @@ uniform mat4 sourcematrix;
uniform int level;
uniform float size_increase_factor;
in vec3 particle_position_initial;
in float lifetime_initial;
in vec3 particle_velocity_initial;
in float size_initial;
layout (location = 4) in vec3 particle_position_initial;
layout (location = 5) in float lifetime_initial;
layout (location = 6) in vec3 particle_velocity_initial;
layout (location = 7) in float size_initial;
in vec3 particle_position;
in float lifetime;
in vec3 particle_velocity;
in float size;
layout (location = 0) in vec3 particle_position;
layout (location = 1) in float lifetime;
layout (location = 2) in vec3 particle_velocity;
layout (location = 3) in float size;
out vec3 new_particle_position;
out float new_lifetime;

View File

@ -1,24 +1,5 @@
uniform sampler2D ntex;
uniform sampler2D dtex;
uniform float spec;
#ifdef UBO_DISABLED
uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 InverseViewMatrix;
uniform mat4 InverseProjectionMatrix;
uniform vec2 screen;
#else
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif
flat in vec3 center;
flat in float energy;

View File

@ -1,20 +1,3 @@
#ifdef UBO_DISABLED
uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 InverseViewMatrix;
uniform mat4 InverseProjectionMatrix;
#else
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif
in vec3 Position;
in float Energy;
in vec3 Color;

View File

@ -32,6 +32,44 @@ vec4 DirToSh(vec3 dir, float flux)
return SHBasis (dir) * flux;
}
// We need to manually unroll the loop, otherwise Nvidia driver crashes.
void loop(in int i,
in vec3 RHcenter,in vec3 RHCellSize, in vec2 RHuv, in float RHdepth,
inout vec4 SHr, inout vec4 SHg, inout vec4 SHb)
{
// produce a new sample location on the RSM texture
float alpha = (i + .5) / SAMPLES;
float theta = 2. * 3.14 * 7. * alpha;
float h = alpha;
vec2 offset = h * vec2(cos(theta), sin(theta));
vec2 uv = RHuv + offset * 0.01;
// Get world position and normal from the RSM sample
float depth = texture(dtex, uv).x;
vec4 RSMPos = inverse(RSMMatrix) * (2. * vec4(uv, depth, 1.) - 1.);
RSMPos /= RSMPos.w;
vec3 RSMAlbedo = texture(ctex, uv).xyz;
vec3 normal = normalize(2. * texture(ntex, uv).xyz - 1.);
// Sampled location inside the RH cell
vec3 offset3d = vec3(uv, 0);
vec3 SamplePos = RHcenter + .5 * offset3d.xzy * RHCellSize;
// Normalize distance to RSM sample
float dist = distance(SamplePos, RSMPos.xyz) / R_wcs;
// Determine the incident direction.
// Avoid very close samples (and numerical instability problems)
vec3 RSM_to_RH_dir = (dist <= 0.1) ? vec3(0.) : normalize(SamplePos - RSMPos.xyz);
float dotprod = max(dot(RSM_to_RH_dir, normal.xyz), 0.);
float factor = dotprod / (0.1 + dist * dist);
vec3 color = RSMAlbedo.rgb * factor;
SHr += DirToSh(RSM_to_RH_dir, color.r);
SHg += DirToSh(RSM_to_RH_dir, color.g);
SHb += DirToSh(RSM_to_RH_dir, color.b);
}
void main(void)
{
vec3 normalizedRHCenter = 2. * vec3(gl_FragCoord.xy, slice) / resolution - 1.;
@ -50,40 +88,22 @@ void main(void)
int x = int(gl_FragCoord.x), y = int(gl_FragCoord.y);
float phi = 30. * (x ^ y) + 10. * x * y;
for (int i = 0; i < SAMPLES; i++)
{
// produce a new sample location on the RSM texture
float alpha = (i + .5) / SAMPLES;
float theta = 2. * 3.14 * 7. * alpha;
float h = alpha;
vec2 offset = h * vec2(cos(theta), sin(theta));
vec2 uv = RHuv + offset * 0.01;
// Get world position and normal from the RSM sample
float depth = texture(dtex, uv).z;
vec4 RSMPos = inverse(RSMMatrix) * (2. * vec4(uv, depth, 1.) - 1.);
RSMPos /= RSMPos.w;
vec3 RSMAlbedo = texture(ctex, uv).xyz;
vec3 normal = normalize(2. * texture(ntex, uv).xyz - 1.);
// Sampled location inside the RH cell
vec3 offset3d = vec3(uv, 0);
vec3 SamplePos = RHcenter + .5 * offset3d.xzy * RHCellSize;
// Normalize distance to RSM sample
float dist = distance(SamplePos, RSMPos.xyz) / R_wcs;
// Determine the incident direction.
// Avoid very close samples (and numerical instability problems)
vec3 RSM_to_RH_dir = (dist <= 0.00) ? vec3(0.) : normalize(SamplePos - RSMPos.xyz);
float dotprod = max(dot(RSM_to_RH_dir, normal.xyz), 0.);
float factor = dotprod / (0.1 + dist * dist);
vec3 color = RSMAlbedo.rgb * factor;
SHr += DirToSh(RSM_to_RH_dir, color.r);
SHg += DirToSh(RSM_to_RH_dir, color.g);
SHb += DirToSh(RSM_to_RH_dir, color.b);
}
loop(0, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
loop(1, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
loop(2, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
loop(3, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
loop(4, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
loop(5, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
loop(6, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
loop(7, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
loop(8, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
loop(9, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
loop(10, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
loop(11, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
loop(12, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
loop(13, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
loop(14, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
loop(15, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
SHr /= 3.14159 * SAMPLES;
SHg /= 3.14159 * SAMPLES;
@ -92,4 +112,4 @@ void main(void)
SHRed = SHr;
SHGreen = SHg;
SHBlue = SHb;
}
}

View File

@ -10,5 +10,5 @@ void main()
float r = texture(SHR, uvw).w;
float g = texture(SHG, uvw).w;
float b = texture(SHB, uvw).w;
FragColor = max(vec4(r, g, b, 1.0), vec4(0.));
FragColor = max(10. * vec4(r, g, b, 1.0), vec4(0.));
}

View File

@ -1,15 +1,5 @@
uniform vec3 extents;
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
uniform mat4 RHMatrix;
ivec3 resolution = ivec3(32, 16, 32);
@ -25,6 +15,6 @@ void main(void)
uvw = vec3(gx, gy, gz) / vec3(resolution);
vec3 WorldPos = (2. * uvw - 1.) * extents;
gl_Position = ProjectionMatrix * ViewMatrix * RHMatrix * vec4(WorldPos, 1.);
gl_PointSize = 100. / gl_Position.w;
gl_PointSize = 500. / gl_Position.w;
}

View File

@ -8,6 +8,7 @@ layout (location = 1) out vec3 RSMNormals;
void main()
{
if (texture(tex, uv).a < .5) discard;
RSMColor = texture(tex, uv).xyz * color.rgb;
RSMNormals = .5 * normalize(nor) + .5;
}

View File

@ -1,5 +1,4 @@
uniform mat4 ModelMatrix;
uniform mat4 InverseModelMatrix;
uniform mat4 RSMMatrix;
uniform mat4 TextureMatrix =
@ -13,24 +12,28 @@ layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 2) in vec4 Color;
layout(location = 3) in vec2 Texcoord;
layout(location = 4) in vec2 SecondTexcoord;
#else
in vec3 Position;
in vec3 Normal;
in vec4 Color;
in vec2 Texcoord;
in vec2 SecondTexcoord;
#endif
out vec3 nor;
out vec2 uv;
out vec2 uv_bis;
out vec4 color;
void main(void)
{
mat4 ModelViewProjectionMatrix = RSMMatrix * ModelMatrix;
mat4 TransposeInverseModel = transpose(InverseModelMatrix);
mat4 TransposeInverseModel = transpose(inverse(ModelMatrix));
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
nor = (vec4(Normal, 0.)).xyz;
nor = (TransposeInverseModel * vec4(Normal, 0.)).xyz;
uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy;
uv_bis = SecondTexcoord;
color = Color.zyxw;
}

View File

@ -1,14 +1,15 @@
#if __VERSION__ >= 330
layout(location = 0) in vec2 Position;
layout(location = 3) in vec2 Texcoord;
#else
in vec2 Position;
in vec2 Texcoord;
#if __VERSION__ >= 130
out vec2 uv;
#else
varying vec2 uv;
#endif
out vec2 uv;
void main() {
uv = Texcoord;
gl_Position = vec4(Position, 0., 1.);
void main()
{
uv = Texcoord;
gl_Position = vec4(Position, 0., 1.);
}

View File

@ -1,12 +1,4 @@
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
};
uniform int layer;
uniform mat4 ModelMatrix;
#if __VERSION__ >= 330
@ -27,11 +19,11 @@ out int layerId;
void main(void)
{
#ifdef VSLayer
gl_Layer = gl_InstanceID & 3;
gl_Layer = layer;
uv = Texcoord;
gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * vec4(Position, 1.);
#else
layerId = gl_InstanceID & 3;
layerId = layer;
tc = Texcoord;
gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * vec4(Position, 1.);
#endif

View File

@ -1,12 +1,4 @@
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
};
uniform int layer;
uniform mat4 ModelMatrix;
uniform vec3 windDir;
@ -30,11 +22,11 @@ out int layerId;
void main(void)
{
#ifdef VSLayer
gl_Layer = gl_InstanceID & 3;
gl_Layer = layer;
uv = Texcoord;
gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * vec4(Position + windDir * Color.r, 1.);
#else
layerId = gl_InstanceID & 3;
layerId = layer;
tc = Texcoord;
gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * vec4(Position + windDir * Color.r, 1.);
#endif

View File

@ -1,21 +1,3 @@
#ifdef UBO_DISABLED
uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 InverseViewMatrix;
uniform mat4 InverseProjectionMatrix;
uniform vec2 screen;
#else
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif
uniform samplerCube tex;
#if __VERSION__ >= 130

View File

@ -3,22 +3,16 @@ in vec2 Texcoord;
#ifndef VSLayer
out int layer;
out vec2 uv_in;
#else
out vec2 uv;
flat out int slice;
#endif
void main() {
#ifdef VSLayer
gl_Layer = gl_InstanceID;
uv = Texcoord;
slice = gl_InstanceID;
#else
layer = gl_InstanceID;
uv_in = Texcoord;
#endif
gl_Position = vec4(Position, 0., 1.);
}

View File

@ -0,0 +1,11 @@
uniform int slice;
in vec2 Position;
in vec2 Texcoord;
out int layer;
void main() {
layer = slice;
gl_Position = vec4(Position, 0., 1.);
}

View File

@ -1,22 +1,16 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D tex_layout;
layout(bindless_sampler) uniform sampler2D tex_detail0;
layout(bindless_sampler) uniform sampler2D tex_detail1;
layout(bindless_sampler) uniform sampler2D tex_detail2;
layout(bindless_sampler) uniform sampler2D tex_detail3;
#else
uniform sampler2D tex_layout;
uniform sampler2D tex_detail0;
uniform sampler2D tex_detail1;
uniform sampler2D tex_detail2;
uniform sampler2D tex_detail3;
uniform sampler2D DiffuseMap;
uniform sampler2D SpecularMap;
uniform sampler2D SSAO;
uniform vec3 ambient;
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif
#if __VERSION__ >= 130
in vec2 uv;
@ -28,26 +22,30 @@ varying vec2 uv_bis;
#define FragColor gl_FragColor
#endif
vec3 getLightFactor(float specMapValue);
void main() {
// Splatting part
vec4 splatting = texture(tex_layout, uv_bis);
vec4 detail0 = texture(tex_detail0, uv);
vec4 detail1 = texture(tex_detail1, uv);
vec4 detail2 = texture(tex_detail2, uv);
vec4 detail3 = texture(tex_detail3, uv);
vec4 detail4 = vec4(0.0);
// Splatting part
vec4 splatting = texture(tex_layout, uv_bis);
vec4 detail0 = texture(tex_detail0, uv);
vec4 detail1 = texture(tex_detail1, uv);
vec4 detail2 = texture(tex_detail2, uv);
vec4 detail3 = texture(tex_detail3, uv);
vec4 detail4 = vec4(0.0);
#ifdef GL_ARB_bindless_texture
#ifdef SRGBBindlessFix
detail0.xyz = pow(detail0.xyz, vec3(2.2));
detail1.xyz = pow(detail1.xyz, vec3(2.2));
detail2.xyz = pow(detail2.xyz, vec3(2.2));
detail3.xyz = pow(detail3.xyz, vec3(2.2));
#endif
#endif
vec4 splatted = splatting.r * detail0 +
splatting.g * detail1 +
splatting.b * detail2 +
max(0., (1.0 - splatting.r - splatting.g - splatting.b)) * detail3;
vec4 splatted = splatting.r * detail0 +
splatting.g * detail1 +
splatting.b * detail2 +
max(0., (1.0 - splatting.r - splatting.g - splatting.b)) * detail3;
vec2 tc = gl_FragCoord.xy / screen;
vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz;
vec3 SpecularComponent = texture(SpecularMap, tc).xyz;
float ao = texture(SSAO, tc).x;
vec3 LightFactor = ao * ambient + DiffuseComponent + SpecularComponent;
FragColor = vec4(splatted.xyz * LightFactor, 1.);
vec3 LightFactor = getLightFactor(1.);
FragColor = vec4(splatted.xyz * LightFactor, 1.);
}

View File

@ -0,0 +1,27 @@
uniform sampler2D tex_layout;
uniform sampler2D tex_detail0;
uniform sampler2D tex_detail1;
uniform sampler2D tex_detail2;
uniform sampler2D tex_detail3;
in vec2 uv;
in vec2 uv_bis;
in vec3 nor;
layout (location = 0) out vec3 RSMColor;
layout (location = 1) out vec3 RSMNormals;
void main()
{
vec4 splatting = texture(tex_layout, uv_bis);
vec4 detail0 = texture(tex_detail0, uv);
vec4 detail1 = texture(tex_detail1, uv);
vec4 detail2 = texture(tex_detail2, uv);
vec4 detail3 = texture(tex_detail3, uv);
vec4 splatted = splatting.r * detail0 +
splatting.g * detail1 +
splatting.b * detail2 +
max(0., (1.0 - splatting.r - splatting.g - splatting.b)) * detail3;
RSMColor = splatted.rgb;
RSMNormals = .5 * normalize(nor) + .5;
}

View File

@ -2,34 +2,14 @@
// and improvements here http://graphics.cs.williams.edu/papers/SAOHPG12/
uniform sampler2D dtex;
uniform vec4 samplePoints[16];
#ifdef UBO_DISABLED
uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 InverseViewMatrix;
uniform mat4 InverseProjectionMatrix;
uniform vec2 screen;
#else
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif
uniform float radius = 1.;
uniform float k = 1.5;
uniform float sigma = 1.;
out float AO;
const float sigma = 1.;
const float tau = 7.;
const float beta = 0.002;
const float epsilon = .00001;
const float radius = 1.;
const float k = 1.5;
#define SAMPLES 16

View File

@ -8,24 +8,6 @@ uniform mat4 invproj;
//uniform int hasclouds;
//uniform vec2 wind;
#ifdef UBO_DISABLED
uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 InverseViewMatrix;
uniform mat4 InverseProjectionMatrix;
uniform vec2 screen;
#else
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif
out vec4 Diff;
out vec4 Spec;

View File

@ -10,25 +10,6 @@ uniform vec3 col;
//uniform vec2 wind;
//uniform float shadowoffset;
#ifdef UBO_DISABLED
uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 InverseViewMatrix;
uniform mat4 InverseProjectionMatrix;
uniform mat4 ShadowViewProjMatrixes[4];
uniform vec2 screen;
#else
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif
in vec2 uv;
out vec4 Diff;
out vec4 Spec;

View File

@ -1,76 +0,0 @@
uniform sampler2D ntex;
uniform sampler2D dtex;
uniform sampler2DArrayShadow shadowtex;
uniform vec3 direction;
uniform vec3 col;
#ifdef UBO_DISABLED
uniform mat4 ViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 InverseViewMatrix;
uniform mat4 InverseProjectionMatrix;
uniform mat4 ShadowViewProjMatrixes[4];
#else
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
};
#endif
in vec2 uv;
out vec4 Diff;
out vec4 Spec;
vec3 DecodeNormal(vec2 n);
vec3 getSpecular(vec3 normal, vec3 eyedir, vec3 lightdir, vec3 color, float roughness);
vec3 getShadowFactor(vec3 pos)
{
vec3 cascadeColor[] = vec3[](
vec3(1., 0., 0.),
vec3(0., 1., 0.),
vec3(0., 0., 1.),
vec3(1., 1., 1.)
);
for (int i = 0; i < 4; i++)
{
vec4 shadowcoord = (ShadowViewProjMatrixes[i] * vec4(pos, 1.0));
shadowcoord /= shadowcoord.w;
vec2 shadowtexcoord = shadowcoord.xy * 0.5 + 0.5;
if (shadowtexcoord.x < 0. || shadowtexcoord.x > 1. || shadowtexcoord.y < 0. || shadowtexcoord.y > 1.)
continue;
return cascadeColor[i] * texture(shadowtex, vec4(shadowtexcoord, float(i), 0.5 * shadowcoord.z + 0.5));
}
return vec3(1.);
}
void main() {
float z = texture(dtex, uv).x;
vec4 xpos = 2.0 * vec4(uv, z, 1.0) - 1.0;
xpos = InverseViewMatrix * InverseProjectionMatrix * xpos;
xpos.xyz /= xpos.w;
vec3 norm = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
float roughness =texture(ntex, uv).z;
vec3 eyedir = -normalize(xpos.xyz);
// Normalized on the cpu
vec3 L = direction;
float NdotL = max(0., dot(norm, L));
vec3 Specular = getSpecular(norm, eyedir, L, col, roughness) * NdotL;
vec3 outcol = NdotL * col;
// Shadows
vec3 factor = getShadowFactor(xpos.xyz);
Diff = vec4(factor * NdotL * col, 1.);
Spec = vec4(factor * Specular, 1.);
return;
}

View File

@ -3,19 +3,18 @@ uniform vec2 size;
uniform vec2 texcenter;
uniform vec2 texsize;
#if __VERSION__ >= 130
in vec2 position;
in vec2 texcoord;
out vec2 uv;
#if __VERSION__ >= 330
layout(location=0) in vec2 Position;
layout(location=3) in vec2 Texcoord;
#else
attribute vec2 position;
attribute vec2 texcoord;
varying vec2 uv;
in vec2 Position;
in vec2 Texcoord;
#endif
out vec2 uv;
void main()
{
uv = texcoord * texsize + texcenter;
gl_Position = vec4(position * size + center, 0., 1.);
uv = Texcoord * texsize + texcenter;
gl_Position = vec4(Position * size + center, 0., 1.);
}

View File

@ -6,16 +6,6 @@ uniform float exposure = .09;
uniform float Lwhite = 1.;
uniform float vignette_weight = 0.;
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
out vec4 FragColor;
vec3 getCIEYxy(vec3 rgbColor);

View File

@ -1,4 +1,8 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D tex;
#else
uniform sampler2D tex;
#endif
in vec2 uv;
in vec4 color;
@ -8,6 +12,9 @@ out vec4 FragColor;
void main()
{
vec4 Color = texture(tex, uv);
#ifdef GL_ARB_bindless_texture
Color.xyz = pow(Color.xyz, vec3(2.2));
#endif
Color.xyz *= pow(color.xyz, vec3(2.2));
Color.a *= color.a;
// Premultiply alpha

View File

@ -1,4 +1,9 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D tex;
#else
uniform sampler2D tex;
#endif
uniform float fogmax;
uniform float startH;
@ -7,17 +12,6 @@ uniform float start;
uniform float end;
uniform vec3 col;
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
in vec2 uv;
in vec4 color;
out vec4 FragColor;
@ -26,6 +20,9 @@ out vec4 FragColor;
void main()
{
vec4 diffusecolor = texture(tex, uv);
#ifdef GL_ARB_bindless_texture
diffusecolor.xyz = pow(diffusecolor.xyz, vec3(2.2));
#endif
diffusecolor.xyz *= pow(color.xyz, vec3(2.2));
diffusecolor.a *= color.a;
vec3 tmp = vec3(gl_FragCoord.xy / screen, gl_FragCoord.z);

View File

@ -1,17 +1,12 @@
#ifdef GL_ARB_bindless_texture
layout(bindless_sampler) uniform sampler2D DiffuseMap;
layout(bindless_sampler) uniform sampler2D SpecularMap;
layout(bindless_sampler) uniform sampler2D SSAO;
#else
uniform sampler2D DiffuseMap;
uniform sampler2D SpecularMap;
uniform sampler2D SSAO;
uniform vec3 ambient;
layout (std140) uniform MatrixesData
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
};
#endif
vec3 getLightFactor(float specMapValue)
{
@ -19,6 +14,6 @@ vec3 getLightFactor(float specMapValue)
vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz;
vec3 SpecularComponent = texture(SpecularMap, tc).xyz;
float ao = texture(SSAO, tc).x;
vec3 tmp = ao * ambient + DiffuseComponent + SpecularComponent * specMapValue;
vec3 tmp = DiffuseComponent + SpecularComponent * specMapValue;
return tmp * ao;
}

View File

@ -155,6 +155,8 @@
otherwise obstricts too much of the view. -->
<camera distance="1.5" forward-up-angle="15"
backward-up-angle="30"/>
<!-- Additional offset to move graphical chassis with regards to the physics. -->
<graphics y-offset="0.0"/>
<!-- Jump animation related values:
animation-time: only if the estimated time for a jump is larger
@ -431,7 +433,7 @@
exp-string-response: dampen the suspension spring reaction
exponentially.
max-force: Maximum suspension force -->
<suspension stiffness="248" rest="0.2" travel-cm="19"
<suspension stiffness="140" rest="0.3" travel-cm="29"
exp-spring-response="false" max-force="12000"/>
<!-- Wheel related parameters: damping-relaxation/compression: for
@ -440,7 +442,7 @@
position of the physics raycast wheels relative to the center of
gravity. Default is to use the corners of the chassis to attach
the wheels to. -->
<wheels damping-relaxation="20" damping-compression="4.4" radius="0.25">
<wheels damping-relaxation="35" damping-compression="5" radius="0.25">
<front-right position="0.38 0 0.6" />
<front-left position="-0.38 0 0.6" />
<rear-right position="0.38 0 -0.6" />
@ -463,12 +465,15 @@
track-connection-accel: An artificial force that pulls a wheel to
the ground if its off ground. Reduces the affect if a kart loses
contact with the ground (i.e. it then can't steer or accelerate
anymore). -->
<stability roll-influence="0.03"
anymore).
smooth-flying-impulse: apply a torque impulse to flying kart to keep
them parallel to the ground.-->
<stability roll-influence="0.3"
chassis-linear-damping="0.2"
chassis-angular-damping="0"
downward-impulse-factor="0"
track-connection-accel="2"/>
track-connection-accel="2"
smooth-flying-impulse="25"/>
<!-- collision
impulse-type: STK can apply an additional impulse in case of
@ -498,11 +503,19 @@
(1-bevelY). A value of 0 for all bevel coordinates disables
bevelling, and uses a simple box shape.
As an example, a value of 1 for x and z will result in a
sharp 'arrow' like shape. -->
sharp 'arrow' like shape.
physical-wheel-position: Defines where the 'physical' (raycast)
wheel will be located. It's a weight factor with 0 = being
at the widest side of the bevel, 1 = at the front and
narrowest part of the kart. If the value is less than 0, the old
physics settings are used which places the raycast wheels
outside of the chassis and results in more stable physical
behaviour of the karts. -->
<collision impulse-type="normal"
impulse="3000" impulse-time="0.1" terrain-impulse="8000"
restitution="1.0" bevel-factor="0.5 0.0 0.5" />
impulse="3000" impulse-time="0.1" terrain-impulse="1600"
restitution="1.0" bevel-factor="0.5 0.0 0.7"
physical-wheel-position="-1" />
<!-- If a kart starts within the specified time after 'go',
it receives the corresponding bonus from 'boost'. Those
fields must have the same size, and must be sorted by
@ -658,11 +671,16 @@
<!-- Speed and acceleration related values: power and max-speed (in m/s)
have 3 values, one for low, medium, and hard.
brake-factor: Value used when braking. max-speed-reverse-ratio is
the percentage of max speed for reverse gear. -->
brake-factor: Value used when braking.
brake-time-increase: The brake force is multiplied by
(1+brake_time*brake_time_increase - i.e. the longer the brake was
pressed, the harder the kart will brake.
max-speed-reverse-ratio is the percentage of max speed for reverse gear.
-->
<engine power="450 475 500 510" max-speed="17 21 23 25" brake-factor="11.0"
max-speed-reverse-ratio="0.3"/>
brake-time-increase="6"
max-speed-reverse-ratio="0.3"/>
<!-- Simulated gears: switch-ratio defines at what ratio of the maximum
speed what gear is selected, e.g. 0.25 means that if the speed is
bigger or equal to 0.25 x maxSpeed then use gear 1, 0.5 means if

View File

@ -1,15 +1,14 @@
[Desktop Entry]
Name=SuperTuxKart
Icon=@PREFIX@/share/pixmaps/supertuxkart_128.png
Icon=supertuxkart
GenericName=A kart racing game
GenericName[de]=Ein Kart-Rennspiel
GenericName[fr]=Un jeu de karting
GenericName[gl]=Xogo de carreiras con karts
GenericName[pl]=Wyścigi gokartów
GenericName[ro]=Un joc de curse cu carturi
Exec=@PREFIX@/@STK_INSTALL_BINARY_DIR@/supertuxkart --no-console
Exec=supertuxkart
Terminal=false
StartupNotify=false
Type=Application
TryExec=@PREFIX@/@STK_INSTALL_BINARY_DIR@/supertuxkart
Categories=Game;ArcadeGame;

View File

@ -1,4 +1,5 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// Copyright (C) 2014 Dawid Gan
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
@ -48,6 +49,9 @@
#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
#define XRANDR_ROTATION_LEFT (1 << 1)
#define XRANDR_ROTATION_RIGHT (1 << 3)
namespace irr
{
namespace video
@ -181,15 +185,19 @@ CIrrDeviceLinux::~CIrrDeviceLinux()
}
#endif // #ifdef _IRR_COMPILE_WITH_OPENGL_
// Reset fullscreen resolution change
switchToFullscreen(true);
if (SoftwareImage)
XDestroyImage(SoftwareImage);
if (!ExternalWindow)
{
XDestroyWindow(display,window);
}
// Reset fullscreen resolution change
restoreResolution();
if (!ExternalWindow)
{
XCloseDisplay(display);
}
}
@ -227,32 +235,62 @@ int IrrPrintXError(Display *display, XErrorEvent *event)
}
#endif
bool CIrrDeviceLinux::switchToFullscreen(bool reset)
bool CIrrDeviceLinux::restoreResolution()
{
if (!CreationParams.Fullscreen)
return true;
if (reset)
#ifdef _IRR_LINUX_X11_VIDMODE_
if (UseXVidMode && CreationParams.Fullscreen)
{
#ifdef _IRR_LINUX_X11_VIDMODE_
if (UseXVidMode && CreationParams.Fullscreen)
{
XF86VidModeSwitchToMode(display, screennr, &oldVideoMode);
XF86VidModeSetViewPort(display, screennr, 0, 0);
}
#endif
#ifdef _IRR_LINUX_X11_RANDR_
if (UseXRandR && CreationParams.Fullscreen)
{
XRRScreenConfiguration *config=XRRGetScreenInfo(display,DefaultRootWindow(display));
XRRSetScreenConfig(display,config,DefaultRootWindow(display),oldRandrMode,oldRandrRotation,CurrentTime);
XRRFreeScreenConfigInfo(config);
}
#endif
return true;
XF86VidModeSwitchToMode(display, screennr, &oldVideoMode);
XF86VidModeSetViewPort(display, screennr, 0, 0);
}
#endif
#ifdef _IRR_LINUX_X11_RANDR_
if (UseXRandR && CreationParams.Fullscreen && old_mode != BadRRMode)
{
XRRScreenResources* res = XRRGetScreenResources(display, DefaultRootWindow(display));
if (!res)
return false;
XRROutputInfo* output = XRRGetOutputInfo(display, res, output_id);
if (!output || !output->crtc || output->connection == RR_Disconnected)
{
XRRFreeOutputInfo(output);
return false;
}
XRRCrtcInfo* crtc = XRRGetCrtcInfo(display, res, output->crtc);
if (!crtc)
{
XRRFreeOutputInfo(output);
return false;
}
Status s = XRRSetCrtcConfig(display, res, output->crtc, CurrentTime,
crtc->x, crtc->y, old_mode,
crtc->rotation, &output_id, 1);
XRRFreeOutputInfo(output);
XRRFreeCrtcInfo(crtc);
XRRFreeScreenResources(res);
if (s != Success)
return false;
}
#endif
return true;
}
bool CIrrDeviceLinux::changeResolution()
{
if (!CreationParams.Fullscreen)
return true;
getVideoModeList();
#if defined(_IRR_LINUX_X11_VIDMODE_) || defined(_IRR_LINUX_X11_RANDR_)
s32 eventbase, errorbase;
s32 bestMode = -1;
@ -314,43 +352,114 @@ bool CIrrDeviceLinux::switchToFullscreen(bool reset)
XFree(modes);
}
else
#endif
#ifdef _IRR_LINUX_X11_RANDR_
if (XRRQueryExtension(display, &eventbase, &errorbase))
while (XRRQueryExtension(display, &eventbase, &errorbase))
{
s32 modeCount;
XRRScreenConfiguration *config=XRRGetScreenInfo(display,DefaultRootWindow(display));
XRRScreenSize *modes=XRRConfigSizes(config,&modeCount);
for (s32 i = 0; i<modeCount; ++i)
{
if (bestMode==-1 && (u32)modes[i].width >= Width && (u32)modes[i].height >= Height)
bestMode = i;
else if (bestMode!=-1 &&
(u32)modes[i].width >= Width &&
(u32)modes[i].height >= Height &&
modes[i].width <= modes[bestMode].width &&
modes[i].height <= modes[bestMode].height)
bestMode = i;
}
if (bestMode != -1)
{
os::Printer::log("Starting randr fullscreen mode...", ELL_INFORMATION);
os::Printer::log("width: ", core::stringc(modes[bestMode].width).c_str(), ELL_INFORMATION);
os::Printer::log("height: ", core::stringc(modes[bestMode].height).c_str(), ELL_INFORMATION);
if (output_id == BadRROutput)
break;
XRRSetScreenConfig(display,config,DefaultRootWindow(display),bestMode,oldRandrRotation,CurrentTime);
UseXRandR=true;
XRRScreenResources* res = XRRGetScreenResources(display, DefaultRootWindow(display));
if (!res)
break;
XRROutputInfo* output = XRRGetOutputInfo(display, res, output_id);
if (!output || !output->crtc || output->connection == RR_Disconnected)
{
XRRFreeOutputInfo(output);
XRRFreeScreenResources(res);
break;
}
XRRFreeScreenConfigInfo(config);
XRRCrtcInfo* crtc = XRRGetCrtcInfo(display, res, output->crtc);
if (!crtc)
{
XRRFreeOutputInfo(output);
XRRFreeScreenResources(res);
break;
}
float refresh_rate, refresh_rate_new;
core::dimension2d<u32> mode0_size = core::dimension2d<u32>(0, 0);
for (int i = 0; i < res->nmode; i++)
{
const XRRModeInfo* mode = &res->modes[i];
core::dimension2d<u32> size;
if (crtc->rotation & (XRANDR_ROTATION_LEFT|XRANDR_ROTATION_RIGHT))
{
size = core::dimension2d<u32>(mode->height, mode->width);
}
else
{
size = core::dimension2d<u32>(mode->width, mode->height);
}
if (bestMode == -1 && mode->id == output->modes[0])
{
mode0_size = size;
}
if (bestMode == -1 && size.Width == Width && size.Height == Height)
{
for (int j = 0; j < output->nmode; j++)
{
if (mode->id == output->modes[j])
{
bestMode = j;
refresh_rate = (mode->dotClock * 1000.0) / (mode->hTotal * mode->vTotal);
break;
}
}
}
else if (bestMode != -1 && size.Width == Width && size.Height == Height)
{
refresh_rate_new = (mode->dotClock * 1000.0) / (mode->hTotal * mode->vTotal);
if (refresh_rate_new <= refresh_rate)
break;
for (int j = 0; j < output->nmode; j++)
{
if (mode->id == output->modes[j])
{
bestMode = j;
refresh_rate = refresh_rate_new;
break;
}
}
}
}
// If video mode not found, try to use first available
if (bestMode == -1)
{
bestMode = 0;
Width = mode0_size.Width;
Height = mode0_size.Height;
}
Status s = XRRSetCrtcConfig(display, res, output->crtc, CurrentTime,
crtc->x, crtc->y, output->modes[bestMode],
crtc->rotation, &output_id, 1);
if (s == Success)
UseXRandR = true;
XRRFreeCrtcInfo(crtc);
XRRFreeOutputInfo(output);
XRRFreeScreenResources(res);
break;
}
else
#endif
if (UseXRandR == false)
{
os::Printer::log("VidMode or RandR extension must be installed to allow Irrlicht "
"to switch to fullscreen mode. Running in windowed mode instead.", ELL_WARNING);
os::Printer::log("Could not get video output. Try to run in windowed mode.", ELL_WARNING);
CreationParams.Fullscreen = false;
}
#endif
return CreationParams.Fullscreen;
}
@ -464,7 +573,7 @@ bool CIrrDeviceLinux::createWindow()
screennr = DefaultScreen(display);
switchToFullscreen();
changeResolution();
#ifdef _IRR_COMPILE_WITH_OPENGL_
@ -769,6 +878,17 @@ bool CIrrDeviceLinux::createWindow()
{
if (netWM)
{
// Some window managers don't respect values from XCreateWindow and
// place window in random position. This may cause that fullscreen
// window is showed in wrong screen. It doesn't matter for vidmode
// which displays cloned image in all devices.
#ifdef _IRR_LINUX_X11_RANDR_
XResizeWindow(display, window, Width, Height);
XMoveWindow(display, window, crtc_x, crtc_y);
XRaiseWindow(display, window);
XFlush(display);
#endif
// Workaround for Gnome which sometimes creates window smaller than display
XSizeHints *hints = XAllocSizeHints();
hints->flags=PMinSize;
@ -782,7 +902,8 @@ bool CIrrDeviceLinux::createWindow()
Atom WMStateAtom = XInternAtom(display, "_NET_WM_STATE", true);
Atom WMFullscreenAtom = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", true);
// Set the fullscreen property
XChangeProperty(display, window, WMStateAtom, XA_ATOM, 32, PropModeReplace, reinterpret_cast<unsigned char *>(& WMFullscreenAtom), 1);
XChangeProperty(display, window, WMStateAtom, XA_ATOM, 32, PropModeReplace,
reinterpret_cast<unsigned char*>(&WMFullscreenAtom), 1);
// Notify the root window
XEvent xev = {0}; // The event should be filled with zeros before setting its attributes
@ -793,7 +914,10 @@ bool CIrrDeviceLinux::createWindow()
xev.xclient.format = 32;
xev.xclient.data.l[0] = 1;
xev.xclient.data.l[1] = WMFullscreenAtom;
XSendEvent(display, DefaultRootWindow(display), false, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
XSendEvent(display, RootWindow(display, visual->screen), false,
SubstructureRedirectMask | SubstructureNotifyMask, &xev);
XFlush(display);
}
else
{
@ -1492,30 +1616,107 @@ video::IVideoModeList* CIrrDeviceLinux::getVideoModeList()
}
XFree(modes);
}
else
#endif
#ifdef _IRR_LINUX_X11_RANDR_
if (XRRQueryExtension(display, &eventbase, &errorbase))
output_id = BadRROutput;
old_mode = BadRRMode;
while (XRRQueryExtension(display, &eventbase, &errorbase))
{
int modeCount;
XRRScreenConfiguration *config=XRRGetScreenInfo(display,DefaultRootWindow(display));
oldRandrMode=XRRConfigCurrentConfiguration(config,&oldRandrRotation);
XRRScreenSize *modes=XRRConfigSizes(config,&modeCount);
VideoModeList.setDesktop(defaultDepth, core::dimension2d<u32>(
modes[oldRandrMode].width, modes[oldRandrMode].height));
for (int i = 0; i<modeCount; ++i)
XRROutputInfo* output = NULL;
XRRCrtcInfo* crtc = NULL;
crtc_x = crtc_y = -1;
XRRScreenResources* res = XRRGetScreenResources(display, DefaultRootWindow(display));
if (!res)
break;
RROutput primary_id = XRRGetOutputPrimary(display, DefaultRootWindow(display));
for (int i = 0; i < res->noutput; i++)
{
VideoModeList.addMode(core::dimension2d<u32>(
modes[i].width, modes[i].height), defaultDepth);
XRROutputInfo* output_tmp = XRRGetOutputInfo(display, res, res->outputs[i]);
if (!output_tmp || !output_tmp->crtc || output_tmp->connection == RR_Disconnected)
{
XRRFreeOutputInfo(output_tmp);
continue;
}
XRRCrtcInfo* crtc_tmp = XRRGetCrtcInfo(display, res, output_tmp->crtc);
if (!crtc_tmp)
{
XRRFreeOutputInfo(output_tmp);
continue;
}
if (res->outputs[i] == primary_id ||
output_id == BadRROutput || crtc_tmp->x < crtc->x ||
(crtc_tmp->x == crtc->x && crtc_tmp->y < crtc->y))
{
XRRFreeCrtcInfo(crtc);
XRRFreeOutputInfo(output);
output = output_tmp;
crtc = crtc_tmp;
output_id = res->outputs[i];
}
else
{
XRRFreeCrtcInfo(crtc_tmp);
XRRFreeOutputInfo(output_tmp);
}
if (res->outputs[i] == primary_id)
break;
}
XRRFreeScreenConfigInfo(config);
if (output_id == BadRROutput)
{
os::Printer::log("Could not get video output.", ELL_WARNING);
break;
}
crtc_x = crtc->x;
crtc_y = crtc->y;
for (int i = 0; i < res->nmode; i++)
{
const XRRModeInfo* mode = &res->modes[i];
core::dimension2d<u32> size;
if (crtc->rotation & (XRANDR_ROTATION_LEFT|XRANDR_ROTATION_RIGHT))
{
size = core::dimension2d<u32>(mode->height, mode->width);
}
else
{
size = core::dimension2d<u32>(mode->width, mode->height);
}
for (int j = 0; j < output->nmode; j++)
{
if (mode->id == output->modes[j])
{
VideoModeList.addMode(size, defaultDepth);
break;
}
}
if (mode->id == crtc->mode)
{
old_mode = crtc->mode;
VideoModeList.setDesktop(defaultDepth, size);
}
}
XRRFreeCrtcInfo(crtc);
XRRFreeOutputInfo(output);
XRRFreeScreenResources(res);
break;
}
else
#endif
{
os::Printer::log("VidMode or RandR X11 extension requireed for VideoModeList." , ELL_WARNING);
}
}
if (display && temporaryDisplay)
{
XCloseDisplay(display);

View File

@ -150,7 +150,8 @@ namespace irr
void initXAtoms();
bool switchToFullscreen(bool reset=false);
bool restoreResolution();
bool changeResolution();
//! Implementation of the linux cursor control
class CCursorControl : public gui::ICursorControl
@ -394,8 +395,10 @@ namespace irr
XF86VidModeModeInfo oldVideoMode;
#endif
#ifdef _IRR_LINUX_X11_RANDR_
SizeID oldRandrMode;
Rotation oldRandrRotation;
RROutput output_id;
RRMode old_mode;
int crtc_x;
int crtc_y;
#endif
#ifdef _IRR_COMPILE_WITH_OPENGL_
GLXWindow glxWin;

View File

@ -3,3 +3,4 @@
file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp")
file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp")
file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*")
file(GLOB_RECURSE STK_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${PROJECT_BINARY_DIR}/tmp/*.rc")

View File

@ -216,3 +216,15 @@ bool Addon::filterByWords(const core::stringw words) const
return false;
} // filterByWords
// ----------------------------------------------------------------------------
/** Deletes the icon file of this addon, and marks it to be re-downloaded (next
* time AddonsManager::downloadIcons() is called.
*/
void Addon::deleteInvalidIconFile()
{
m_icon_ready = false;
std::string icon = file_manager->getAddonsFile("icons/"+m_icon_basename);
file_manager->removeFile(icon);
m_installed = false;
} // redownloadIcon

View File

@ -130,6 +130,8 @@ public:
Addon() {};
/** Initialises the object from an XML node. */
Addon(const XMLNode &xml);
void deleteInvalidIconFile();
// ------------------------------------------------------------------------
/** Sets the sort order used in the comparison function. It is static, so
* that each instance can access the sort order. */
@ -164,7 +166,7 @@ public:
const std::string& getIconURL() const { return m_icon_url; }
// ------------------------------------------------------------------------
/** Returns the name of the icon (i.e. the basename of the url). */
const std::string getIconBasename() const { return m_icon_basename; }
const std::string& getIconBasename() const { return m_icon_basename; }
// ------------------------------------------------------------------------
/** Returns the name of the addon. */
const core::stringw& getDescription() const { return m_description; }

View File

@ -114,13 +114,13 @@ void AddonsManager::init(const XMLNode *xml,
if (download)
{
Log::info("NetworkHttp", "Downloading updated addons.xml");
Log::info("addons", "Downloading updated addons.xml.");
Online::HTTPRequest *download_request = new Online::HTTPRequest("addons.xml");
download_request->setURL(addon_list_url);
download_request->executeNow();
if(download_request->hadDownloadError())
{
Log::error("addons", "Error on download addons.xml: %s\n",
Log::error("addons", "Error on download addons.xml: %s.",
download_request->getDownloadErrorMessage());
delete download_request;
return;
@ -129,12 +129,12 @@ void AddonsManager::init(const XMLNode *xml,
UserConfigParams::m_addons_last_updated=StkTime::getTimeSinceEpoch();
}
else
Log::info("NetworkHttp", "Using cached addons.xml");
Log::info("addons", "Using cached addons.xml.");
const XMLNode *xml_addons = new XMLNode(filename);
addons_manager->initAddons(xml_addons); // will free xml_addons
if(UserConfigParams::logAddons())
Log::info("addons", "Addons manager list downloaded");
Log::info("addons", "Addons manager list downloaded.");
} // init
// ----------------------------------------------------------------------------
@ -195,7 +195,7 @@ void AddonsManager::initAddons(const XMLNode *xml)
if(file_manager->fileExists(full_path))
{
if(UserConfigParams::logAddons())
Log::warn("[AddonsManager] Removing cached icon '%s'.\n",
Log::warn("addons", "Removing cached icon '%s'.",
addon.getIconBasename().c_str());
file_manager->removeFile(full_path);
}
@ -226,9 +226,9 @@ void AddonsManager::initAddons(const XMLNode *xml)
}
else
{
Log::error("[AddonsManager]", "Found invalid node '%s' while downloading addons.",
Log::error("addons", "Found invalid node '%s' while downloading addons.",
node->getName().c_str());
Log::error("[AddonsManager]", "Ignored.");
Log::error("addons", "Ignored.");
}
} // for i<xml->getNumNodes
delete xml;
@ -254,9 +254,9 @@ void AddonsManager::initAddons(const XMLNode *xml)
// it from the list.
if(UserConfigParams::logAddons())
Log::warn(
"[AddonsManager] Removing '%s' which is not on the server anymore.\n",
"addons", "Removing '%s' which is not on the server anymore.",
m_addons_list.getData()[i].getId().c_str() );
std::string icon = m_addons_list.getData()[i].getIconBasename();
const std::string &icon = m_addons_list.getData()[i].getIconBasename();
std::string icon_file =file_manager->getAddonsFile("icons/"+icon);
if(file_manager->fileExists(icon_file))
{
@ -311,7 +311,7 @@ void AddonsManager::checkInstalledAddons()
if(n<0) continue;
if(!m_addons_list.getData()[n].isInstalled())
{
Log::info("[AddonsManager] Marking '%s' as being installed.",
Log::info("addons", "Marking '%s' as being installed.",
kp->getIdent().c_str());
m_addons_list.getData()[n].setInstalled(true);
something_was_changed = true;
@ -330,7 +330,7 @@ void AddonsManager::checkInstalledAddons()
if(n<0) continue;
if(!m_addons_list.getData()[n].isInstalled())
{
Log::info("[AddonsManager] Marking '%s' as being installed.",
Log::info("addons", "Marking '%s' as being installed.",
track->getIdent().c_str());
m_addons_list.getData()[n].setInstalled(true);
something_was_changed = true;
@ -361,7 +361,7 @@ void AddonsManager::downloadIcons()
if(icon=="")
{
if(UserConfigParams::logAddons())
Log::error("[AddonsManager]", "No icon or image specified for '%s'.",
Log::error("addons", "No icon or image specified for '%s'.",
addon.getId().c_str());
continue;
}
@ -400,7 +400,7 @@ void AddonsManager::loadInstalledAddons()
/* checking for installed addons */
if(UserConfigParams::logAddons())
{
Log::info("[AddonsManager]", "Loading an xml file for installed addons: %s",
Log::info("addons", "Loading an xml file for installed addons: %s.",
m_file_installed.c_str());
}
const XMLNode *xml = file_manager->createXMLTree(m_file_installed);
@ -478,15 +478,15 @@ bool AddonsManager::install(const Addon &addon)
if (!success)
{
// TODO: show a message in the interface
Log::error("[AddonsManager]", "Failed to unzip '%s' to '%s'",
Log::error("addons", "Failed to unzip '%s' to '%s'.",
from.c_str(), to.c_str());
Log::error("[AddonsManager]", "Zip file will not be removed.");
Log::error("addons", "Zip file will not be removed.");
return false;
}
if(!file_manager->removeFile(from))
{
Log::error("[AddonsManager]", "Problems removing temporary file '%s'",
Log::error("addons", "Problems removing temporary file '%s'.",
from.c_str());
}
@ -520,7 +520,7 @@ bool AddonsManager::install(const Addon &addon)
}
catch (std::exception& e)
{
Log::error("[AddonsManager]", "ERROR: Cannot load track <%s> : %s",
Log::error("addons", "Cannot load track '%s' : %s.",
addon.getDataDir().c_str(), e.what());
}
}
@ -535,8 +535,8 @@ bool AddonsManager::install(const Addon &addon)
*/
bool AddonsManager::uninstall(const Addon &addon)
{
Log::info("[AddonsManager]", "Uninstalling <%s>",
core::stringc(addon.getName()).c_str());
Log::info("addons", "Uninstalling '%s'.",
core::stringc(addon.getName()).c_str());
// addon is a const reference, and to avoid removing the const, we
// find the proper index again to modify the installed state

View File

@ -138,6 +138,7 @@ void* NewsManager::downloadNews(void *obj)
HTTPRequest *download_req = new HTTPRequest("news.xml");
download_req->setAddonsURL("news.xml");
// Initialise the online portion of the addons manager.
if(UserConfigParams::logAddons())
Log::info("addons", "Downloading news.");
@ -150,10 +151,12 @@ void* NewsManager::downloadNews(void *obj)
// that a redirect went wrong, or a wrong/incorrect
// address somehow made its way into the config file.
delete download_req;
// We need a new object, since the state of the old
// download request is now done.
download_req = new HTTPRequest("news.xml");
UserConfigParams::m_server_addons.revertToDefaults();
// make sure the new server address is actually used
download_req->setAddonsURL("news.xml");
download_req->executeNow();

View File

@ -67,8 +67,7 @@ AnimationBase::AnimationBase(Ipo *ipo)
void AnimationBase::setInitialTransform(const Vec3 &xyz,
const Vec3 &hpr)
{
Ipo* curr;
for_in (curr, m_all_ipos)
for_var_in(Ipo*, curr, m_all_ipos)
{
curr->setInitialTransform(xyz, hpr);
}
@ -80,8 +79,7 @@ void AnimationBase::setInitialTransform(const Vec3 &xyz,
void AnimationBase::reset()
{
m_current_time = 0;
Ipo* curr;
for_in (curr, m_all_ipos)
for_var_in(Ipo*, curr, m_all_ipos)
{
curr->reset();
}
@ -103,8 +101,7 @@ void AnimationBase::update(float dt, Vec3 *xyz, Vec3 *hpr, Vec3 *scale)
assert(!isnan(m_current_time));
Ipo* curr;
for_in (curr, m_all_ipos)
for_var_in (Ipo*, curr, m_all_ipos)
{
curr->update(m_current_time, xyz, hpr, scale);
}

View File

@ -90,8 +90,7 @@ public:
{
float duration = -1;
const Ipo* currIpo;
for_in (currIpo, m_all_ipos)
for_var_in (const Ipo*, currIpo, m_all_ipos)
{
duration = std::max(duration, currIpo->getEndTime());
}

View File

@ -42,8 +42,8 @@ public:
UNLOCK_GP,
UNLOCK_MODE,
UNLOCK_KART,
UNLOCK_DIFFICULTY}
;
UNLOCK_DIFFICULTY
};
// ------------------------------------------------------------------------
class UnlockableFeature
{

View File

@ -167,8 +167,7 @@ PlayerManager::PlayerManager()
PlayerManager::~PlayerManager()
{
// If the passwords should not be remembered, clear the saved session.
PlayerProfile *player;
for_in(player, m_all_players)
for_var_in(PlayerProfile*, player, m_all_players)
{
if(!player->rememberPassword())
player->clearSession();
@ -270,8 +269,7 @@ void PlayerManager::save()
}
// Save all non-guest players
PlayerProfile *player;
for_in(player, m_all_players)
for_var_in(PlayerProfile*, player, m_all_players)
{
if(!player->isGuestAccount())
player->save(players_file);
@ -320,8 +318,8 @@ void PlayerManager::deletePlayer(PlayerProfile *player)
void PlayerManager::enforceCurrentPlayer()
{
if (m_current_player) return;
PlayerProfile *player;
PlayerProfile* player;
for_in(player, m_all_players)
{
if (!player->isGuestAccount())
@ -408,8 +406,7 @@ void PlayerManager::createGuestPlayers(int n)
unsigned int PlayerManager::getNumNonGuestPlayers() const
{
unsigned int count=0;
const PlayerProfile *player;
for_in(player, m_all_players)
for_var_in(const PlayerProfile*, player, m_all_players)
{
if(!player->isGuestAccount()) count ++;
}
@ -422,8 +419,7 @@ unsigned int PlayerManager::getNumNonGuestPlayers() const
unsigned int PlayerManager::getUniqueId() const
{
unsigned int max_id=0;
const PlayerProfile *player;
for_in(player, m_all_players)
for_var_in(const PlayerProfile*, player, m_all_players)
{
if(player->getUniqueID()>max_id)
max_id = player->getUniqueID();
@ -439,8 +435,7 @@ unsigned int PlayerManager::getUniqueId() const
*/
const PlayerProfile *PlayerManager::getPlayerById(unsigned int id)
{
const PlayerProfile *player;
for_in(player, m_all_players)
for_var_in(const PlayerProfile*, player, m_all_players)
{
if(player->getUniqueID()==id)
return player;
@ -455,8 +450,7 @@ const PlayerProfile *PlayerManager::getPlayerById(unsigned int id)
*/
PlayerProfile *PlayerManager::getPlayer(const irr::core::stringw &name)
{
PlayerProfile *player;
for_in(player, m_all_players)
for_var_in(PlayerProfile*, player, m_all_players)
{
if(player->getName()==name)
return player;

View File

@ -156,8 +156,4 @@ public:
} // increaseAchievement
// ------------------------------------------------------------------------
}; // PlayerManager
#endif
/*EOF*/

View File

@ -127,7 +127,7 @@ public:
/** Abstract virtual classes, to be implemented by the OnlinePlayer. */
virtual void setUserDetails(Online::HTTPRequest *request,
const std::string &action,
const std::string &php_script = "") const = 0;
const std::string &url_path = "") const = 0;
virtual uint32_t getOnlineId() const = 0;
virtual PlayerProfile::OnlineState getOnlineState() const = 0;
virtual Online::OnlineProfile* getProfile() const = 0;

View File

@ -446,9 +446,6 @@ namespace UserConfigParams
PARAM_PREFIX BoolUserConfigParam m_high_definition_textures
PARAM_DEFAULT(BoolUserConfigParam(true, "enable_high_definition_textures",
&m_video_group, "Enable high definition textures"));
PARAM_PREFIX BoolUserConfigParam m_ubo_disabled
PARAM_DEFAULT(BoolUserConfigParam(false, "disable_ubo_support",
&m_video_group, "Disable UBO support"));
PARAM_PREFIX BoolUserConfigParam m_glow
PARAM_DEFAULT(BoolUserConfigParam(false, "enable_glow",
&m_video_group, "Enable Glow"));
@ -467,6 +464,9 @@ namespace UserConfigParams
PARAM_PREFIX BoolUserConfigParam m_gi
PARAM_DEFAULT(BoolUserConfigParam(false, "enable_gi",
&m_video_group, "Enable Global Illumination"));
PARAM_PREFIX BoolUserConfigParam m_azdo
PARAM_DEFAULT(BoolUserConfigParam(false, "enable_azdo",
&m_video_group, "Enable 'Approaching Zero Driver Overhead' mode (very experimental !)"));
// ---- Debug - not saved to config file
/** If gamepad debugging is enabled. */
@ -697,6 +697,12 @@ namespace UserConfigParams
&m_online_group,
"The server used for online multiplayer."));
PARAM_PREFIX IntUserConfigParam m_server_version
PARAM_DEFAULT( IntUserConfigParam( 1,
"server-version",
&m_online_group,
"Version of the server API to use."));
// ---- Addon server related entries
PARAM_PREFIX GroupUserConfigParam m_addon_group
PARAM_DEFAULT( GroupUserConfigParam("AddonAndNews",

View File

@ -24,7 +24,6 @@
#include "audio/music_manager.hpp"
#include "config/user_config.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/rain.hpp"
#include "io/xml_node.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/explosion_animation.hpp"
@ -45,12 +44,13 @@
AlignedArray<Camera::EndCameraInformation> Camera::m_end_cameras;
std::vector<Camera*> Camera::m_all_cameras;
Camera* Camera::s_active_camera = NULL;
// ============================================================================
Camera::Camera(int camera_index, AbstractKart* kart) : m_kart(NULL)
{
m_mode = CM_NORMAL;
m_index = camera_index;
m_rain = NULL;
m_original_kart = kart;
m_camera = irr_driver->addCameraSceneNode();
@ -90,8 +90,10 @@ Camera::Camera(int camera_index, AbstractKart* kart) : m_kart(NULL)
*/
Camera::~Camera()
{
if(m_rain) delete m_rain;
irr_driver->removeCameraSceneNode(m_camera);
if (s_active_camera == this)
s_active_camera = NULL;
} // ~Camera
//-----------------------------------------------------------------------------
@ -217,13 +219,6 @@ void Camera::setupCamera()
m_camera->setFOV(m_fov);
m_camera->setAspectRatio(m_aspect);
m_camera->setFarValue(World::getWorld()->getTrack()->getCameraFar());
if (UserConfigParams::m_weather_effects &&
World::getWorld()->getTrack()->getWeatherType() == WEATHER_RAIN)
{
m_rain = new Rain(this, NULL);
}
} // setupCamera
// ----------------------------------------------------------------------------
@ -525,12 +520,6 @@ void Camera::update(float dt)
getCameraSettings(&above_kart, &cam_angle, &side_way, &distance, &smoothing);
positionCamera(dt, above_kart, cam_angle, side_way, distance, smoothing);
}
if (UserConfigParams::m_graphical_effects && m_rain)
{
m_rain->setPosition( getCameraSceneNode()->getPosition() );
m_rain->update(dt);
} // UserConfigParams::m_graphical_effects
} // update
// ----------------------------------------------------------------------------
@ -667,9 +656,9 @@ void Camera::handleEndCamera(float dt)
*/
void Camera::activate()
{
s_active_camera = this;
irr::scene::ISceneManager *sm = irr_driver->getSceneManager();
sm->setActiveCamera(m_camera);
sm->setAmbientLight(m_ambient_light);
irr_driver->getVideoDriver()->setViewPort(m_viewport);
} // activate

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