Merge remote-tracking branch 'origin/master' into game_protocol

This commit is contained in:
Benau 2018-01-24 10:20:06 +08:00
commit 6bcee60a1c
441 changed files with 47904 additions and 22124 deletions

1
.gitignore vendored
View File

@ -60,6 +60,7 @@ android/bin
android/build
android/libs
android/obj
android/res
android/.gradle
android-*
*.apk

View File

@ -1,8 +1,9 @@
cmake_minimum_required(VERSION 2.8.4)
# root CMakeLists for the SuperTuxKart project
project(SuperTuxKart)
set(PROJECT_VERSION "git")
cmake_minimum_required(VERSION 2.8.4)
if(NOT (CMAKE_MAJOR_VERSION VERSION_LESS 3))
cmake_policy(SET CMP0043 OLD)
endif()
@ -27,12 +28,13 @@ option(SERVER_ONLY "Create a server only (i.e. no graphics or sound)" OFF)
option(USE_FRIBIDI "Support for right-to-left languages" ON)
option(CHECK_ASSETS "Check if assets are installed in ../stk-assets" ON)
option(USE_SYSTEM_ANGELSCRIPT "Use system angelscript instead of built-in angelscript. If you enable this option, make sure to use a compatible version." OFF)
option(ENABLE_WAYLAND_DEVICE "Enable Wayland device for linux build" OFF)
option(USE_SYSTEM_GLEW "Use system GLEW instead of the built-in version, when available." ON)
CMAKE_DEPENDENT_OPTION(BUILD_RECORDER "Build opengl recorder" ON
"NOT SERVER_ONLY;NOT USE_GLES2;NOT APPLE" OFF)
if (UNIX AND NOT APPLE)
if ((UNIX AND NOT APPLE) AND NOT SERVER_ONLY)
option(ENABLE_WAYLAND_DEVICE "Enable Wayland device for linux build" ON)
option(USE_GLES2 "Use OpenGL ES2 renderer" OFF)
endif()
@ -109,11 +111,24 @@ include_directories("${PROJECT_SOURCE_DIR}/lib/bullet/src")
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/enet")
include_directories("${PROJECT_SOURCE_DIR}/lib/enet/include")
# Build glew library
# Find system GLEW library or build it if missing
if(NOT USE_GLES2 AND NOT SERVER_ONLY)
add_definitions(-DGLEW_NO_GLU)
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/glew")
include_directories("${PROJECT_SOURCE_DIR}/lib/glew/include")
if(USE_SYSTEM_GLEW)
find_package(PkgConfig)
if(PKGCONFIG_FOUND)
pkg_check_modules(GLEW glew>=2.1)
endif()
endif()
if(GLEW_FOUND)
include_directories(${GLEW_INCLUDE_DIRS})
else()
# Fallback to built-in version silently
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/glew")
include_directories("${PROJECT_SOURCE_DIR}/lib/glew/include")
set(GLEW_LIBRARIES "glew")
endif()
endif()
if(MSVC OR APPLE)
@ -175,6 +190,19 @@ if(NOT SERVER_ONLY AND NOT USE_GLES2)
include_directories("${PROJECT_SOURCE_DIR}/lib/graphics_utils")
endif()
if(NOT SERVER_ONLY AND NOT USE_GLES2)
find_library(SQUISH_LIBRARY NAMES squish libsquish)
find_path(SQUISH_INCLUDEDIR NAMES squish.h PATHS)
if (NOT SQUISH_LIBRARY OR NOT SQUISH_INCLUDEDIR)
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/libsquish")
include_directories("${PROJECT_SOURCE_DIR}/lib/libsquish")
SET(SQUISH_LIBRARY squish)
else()
include_directories("${SQUISH_INCLUDEDIR}")
MESSAGE(STATUS "Use system libsquish: ${SQUISH_LIBRARY}")
endif()
endif()
# Build the irrlicht library
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/irrlicht")
include_directories("${PROJECT_SOURCE_DIR}/lib/irrlicht/include")
@ -420,12 +448,16 @@ target_link_libraries(supertuxkart
if(NOT SERVER_ONLY)
if(NOT USE_GLES2)
target_link_libraries(supertuxkart ${OPENGL_gl_LIBRARY} glew graphics_utils)
target_link_libraries(supertuxkart ${OPENGL_gl_LIBRARY} ${GLEW_LIBRARIES} graphics_utils)
else()
target_link_libraries(supertuxkart GLESv2)
endif()
endif()
if(NOT SERVER_ONLY AND NOT USE_GLES2)
target_link_libraries(supertuxkart ${SQUISH_LIBRARY})
endif()
if(UNIX AND NOT APPLE)
if(USE_LIBBFD)
target_link_libraries(supertuxkart ${LIBBFD_LIBRARIES})

49
ISSUE_TEMPLATE.md Normal file
View File

@ -0,0 +1,49 @@
## Description
Provide a description of your issue.
For any suggestions, please address them on the [forum](https://forum.freegamedev.net/viewforum.php?f=16).
## Steps to reproduce
## Configuration
STK release version:
STK Source (ppa, distribution package, official bin,...):
If you did not download STK from the official website, please specify where you got it:
System:
Graphics card:
CPU:
Gamepads/keyboards models if related to the issue:
## Additional information
Please provide stdout.log, it is located in
* %appdata%\supertuxkart\0.8.2 (windows)
* ~/Library/Application Support/supertuxkart/0.8.2 (mac)
* $XDG_CONFIG_HOME/supertuxkart/0.8.2 or ~/.config/supertuxkart/0.8.2 (linux, and other unix based systems)
stdout.log
```
```
If your issue is related to the input config (gamepads, keyboards), please provide your file input.xml located in the same directory as stdout.log.
input.xml
```xml
```
If an error message was shown, please copy paste the complete error message or a screenshot of it.
error
```
```

View File

@ -10,7 +10,7 @@ The SuperTuxKart homepage can be found at <https://supertuxkart.net/>. There is
## Hardware Requirements
To run SuperTuxKart, make sure that your computer's specifications are equal or higher than the following specifications:
* A graphics card capable of 3D rendering - NVIDIA GeForce 8 series and newer (GeForce 8100 or newer), AMD/ATI Radeon HD 4000 series and newer, Intel HD Graphics 3000 and newer. OpenGL >= 3.1
* A graphics card capable of 3D rendering - NVIDIA GeForce 8 series and newer (GeForce 8100 or newer), AMD/ATI Radeon HD 4000 series and newer, Intel HD Graphics 3000 and newer. OpenGL >= 3.3
* You should have a CPU that's running at 1 GHz or faster.
* You'll need at least 512 MB of free VRAM (video memory).
* Minimum disk space: 800 MB

BIN
android/icon-dbg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

View File

@ -36,6 +36,13 @@ export HOST_AARCH64=aarch64-linux-android
export NDK_PLATFORM_AARCH64=android-21
export SDK_VERSION_AARCH64=21
export APP_NAME_RELEASE="SuperTuxKart"
export APP_NAME_DEBUG="SuperTuxKart Debug"
export PACKAGE_NAME_RELEASE="org.supertuxkart.stk"
export PACKAGE_NAME_DEBUG="org.supertuxkart.stk_dev"
export APP_ICON_RELEASE="$DIRNAME/icon.png"
export APP_ICON_DEBUG="$DIRNAME/icon-dbg.png"
# A helper function that checks if error ocurred
check_error()
@ -52,6 +59,7 @@ if [ ! -z "$1" ] && [ "$1" = "clean" ]; then
rm -rf build
rm -rf libs
rm -rf obj
rm -rf res
rm -rf .gradle
exit
fi
@ -108,10 +116,16 @@ if [ "$BUILD_TYPE" = "debug" ] || [ "$BUILD_TYPE" = "Debug" ]; then
export ANT_BUILD_TYPE="debug"
export GRADLE_BUILD_TYPE="assembleDebug"
export IS_DEBUG_BUILD=1
export APP_NAME="$APP_NAME_DEBUG"
export PACKAGE_NAME="$PACKAGE_NAME_DEBUG"
export APP_ICON="$APP_ICON_DEBUG"
elif [ "$BUILD_TYPE" = "release" ] || [ "$BUILD_TYPE" = "Release" ]; then
export ANT_BUILD_TYPE="release"
export GRADLE_BUILD_TYPE="assembleRelease"
export IS_DEBUG_BUILD=0
export APP_NAME="$APP_NAME_RELEASE"
export PACKAGE_NAME="$PACKAGE_NAME_RELEASE"
export APP_ICON="$APP_ICON_RELEASE"
else
echo "Unsupported BUILD_TYPE: $BUILD_TYPE. Possible values are: " \
"debug, release"
@ -342,8 +356,31 @@ check_error
# Build apk
echo "Building APK"
mkdir -p "$DIRNAME/res/drawable/"
mkdir -p "$DIRNAME/res/drawable-hdpi/"
mkdir -p "$DIRNAME/res/drawable-mdpi/"
mkdir -p "$DIRNAME/res/drawable-xhdpi/"
mkdir -p "$DIRNAME/res/drawable-xxhdpi/"
mkdir -p "$DIRNAME/res/values/"
STRINGS_FILE="$DIRNAME/res/values/strings.xml"
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>" > "$STRINGS_FILE"
echo "<resources>" >> "$STRINGS_FILE"
echo " <string name=\"app_name\">$APP_NAME</string>" >> "$STRINGS_FILE"
echo "</resources>" >> "$STRINGS_FILE"
sed -i "s/minSdkVersion=\".*\"/minSdkVersion=\"$SDK_VERSION\"/g" \
"$DIRNAME/AndroidManifest.xml"
sed -i "s/package=\".*\"/package=\"$PACKAGE_NAME\"/g" \
"$DIRNAME/AndroidManifest.xml"
cp "$APP_ICON" "$DIRNAME/res/drawable/icon.png"
convert -scale 72x72 "$APP_ICON" "$DIRNAME/res/drawable-hdpi/icon.png"
convert -scale 48x48 "$APP_ICON" "$DIRNAME/res/drawable-mdpi/icon.png"
convert -scale 96x96 "$APP_ICON" "$DIRNAME/res/drawable-xhdpi/icon.png"
convert -scale 144x144 "$APP_ICON" "$DIRNAME/res/drawable-xxhdpi/icon.png"
if [ "$BUILD_TOOL" = "gradle" ]; then

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">SuperTuxKart</string>
</resources>

View File

@ -1,20 +1,18 @@
<?xml version="1.0"?>
<graphical-restrictions>
<card is="Intel(R) HD Graphics" os="windows" version="<9.0" disable="ForceLegacyDevice"/>
<card is="Intel(R) HD Graphics" os="windows" version="<9.0" disable="HighDefinitionTextures"/>
<card is="Intel(R) HD Graphics 2000" os="windows" disable="UniformBufferObject"/>
<card is="Intel(R) HD Graphics 2000" os="windows" disable="FramebufferSRGB"/>
<card is="Intel(R) HD Graphics" os="windows" version="<10.0" disable="ForceLegacyDevice"/>
<card is="Intel(R) HD Graphics" os="windows" version="<10.0" disable="HighDefinitionTextures"/>
<card is="Intel(R) HD Graphics 2000" os="windows" disable="ForceLegacyDevice"/>
<card is="Intel(R) HD Graphics 2000" os="windows" disable="HighDefinitionTextures"/>
<card is="Intel(R) HD Graphics 3000" os="windows" disable="UniformBufferObject"/>
<card is="Intel(R) HD Graphics 3000" os="windows" disable="FramebufferSRGB"/>
<card is="Intel(R) HD Graphics 3000" os="windows" disable="ForceLegacyDevice"/>
<card is="Intel(R) HD Graphics 3000" os="windows" disable="HighDefinitionTextures"/>
<card is="Intel(R) HD Graphics 4600" os="windows" disable="ComputeShader"/>
<card contains="Intel" os="osx" disable="GI"/>
<card contains="Intel" os="linux" version="<11.2" disable="ComputeShader"/>
<card contains="Intel" os="linux" version="<11.2" disable="GeometryShader"/>
<card contains="Intel" os="linux" disable="FramebufferSRGBWorkaround2"/>
<card contains="Ivybridge" os="linux" version="<17.4" disable="Correct10bitNormalization"/>
<card contains="Sandybridge" os="linux" version="<17.4" disable="Correct10bitNormalization"/>
<card contains="Intel" os="linux" version="<11.2" disable="TextureCompressionS3TC"/>
<card contains="Intel" os="windows" disable="TextureCompressionS3TC"/>
<card contains="Intel" os="osx" disable="TextureCompressionS3TC"/>
<card contains="NVIDIA" os="windows" version="<344.65" disable="BufferStorage"/>
<card contains="NVIDIA" os="linux" version="<343.22" disable="BufferStorage"/>
@ -37,6 +35,6 @@
<card os="android" disable="ColorBufferFloat"/>
<card contains="Adreno" os="android" version="<=19" disable="VertexIdWorking"/>
<card contains="Android Emulator" os="android" disable="ForceLegacyDevice"/>
<card os="android" disable="UniformBufferObject"/>
<card contains="Android Emulator" os="android" disable="NpotTextures"/>
<card vendor="Broadcom" os="linux" disable="HighDefinitionTextures256"/>
</graphical-restrictions>

View File

@ -23,7 +23,7 @@
<spacer height="4" width="10" />
<div layout="horizontal-row" width="100%" proportion="1">
<div layout="horizontal-row" width="50%" proportion="1">
<spacer width="70" height="10" />
<div layout="horizontal-row" proportion="1" height="fit">
@ -31,14 +31,6 @@
<spacer width="10" height="10"/>
<gauge id="shadows" min_value="0" max_value="2" proportion="1"/>
</div>
<spacer height="4" width="10" />
<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="ibl"/>
<spacer width="10" height="10"/>
<label text="Image-based lighting" I18N="Video settings"/>
</div>
</div>
<spacer height="4" width="10" />
@ -75,9 +67,9 @@
<spacer height="4" width="10" />
<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="global_illumination"/>
<checkbox id="dof"/>
<spacer width="10" height="10"/>
<label text="Global illumination" I18N="Video settings"/>
<label text="Depth of field" I18N="Video settings"/>
</div>
</div>
@ -115,9 +107,9 @@
<spacer height="4" width="10" />
<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="dof"/>
<checkbox id="ibl"/>
<spacer width="10" height="10"/>
<label text="Depth of field" I18N="Video settings"/>
<label text="Image-based lighting" I18N="Video settings"/>
</div>
</div>
@ -125,9 +117,9 @@
<div layout="horizontal-row" width="100%" proportion="1">
<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="weather_gfx"/>
<checkbox id="animated_characters"/>
<spacer width="10" height="10"/>
<label text="Weather Effects" I18N="Video settings"/>
<label text="Animated Characters" I18N="Video settings"/>
</div>
<spacer height="4" width="10" />
@ -142,17 +134,9 @@
<spacer height="20" width="10" />
<div layout="horizontal-row" width="100%" proportion="1">
<label text="Animated Scenery" I18N="Video settings" width="40%"/>
<label text="Particles Effects" I18N="Video settings" width="40%"/>
<spacer width="10" height="10"/>
<gauge id="anim_gfx" min_value="0" max_value="2" width="50%" />
</div>
<spacer height="4" width="10" />
<div layout="horizontal-row" width="100%" proportion="1">
<label text="Animated Characters" I18N="Video settings" width="40%"/>
<spacer width="10" height="10"/>
<gauge id="steering_animations" min_value="0" max_value="2" width="50%" />
<gauge id="particles_effects" min_value="0" max_value="2" width="50%" />
</div>
<spacer height="4" width="10" />
@ -160,7 +144,7 @@
<div layout="horizontal-row" width="100%" proportion="1">
<label text="Rendered image quality" I18N="Video settings" width="40%"/>
<spacer width="10" height="10"/>
<gauge id="image_quality" min_value="0" max_value="3" width="50%" />
<gauge id="image_quality" min_value="0" max_value="2" width="50%" />
</div>
<spacer height="4" width="10" />

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<stkgui>
<div x="2%" y="10%" width="96%" height="70%" layout="vertical-row">
<div id="kart-screen" layout="horizontal-row" width="100%" height="60%" proportion="10" align="center">
<placeholder width="100%" layout="horizontal-row" height="100%">
<!-- Content is added programmatically -->
</placeholder>
</div>
<label text="0 to use the original color, otherwise pick one from slider."
width="100%" text_align="center" word_wrap="true"
I18N="In the kart color slider dialog"/>
<spacer height="30" width="10"/>
<div proportion="1" width="100%" layout="horizontal-row">
<gauge id="color-slider" min_value="0" max_value="100" proportion="1"/>
</div>
<spacer height="30" width="10"/>
<button id="close" text="Apply" align="center"/>
</div>
</stkgui>

View File

@ -62,6 +62,8 @@
I18N="In the user screen" text="Delete" label_location="bottom"/>
<icon-button id="rename" width="64" height="64" icon="gui/rename.png"
I18N="In the user screen" text="Rename" label_location="bottom"/>
<icon-button id="default_kart_color" width="64" height="64" icon="gui/edit.png"
I18N="In the user screen" text="Default kart color" label_location="bottom"/>
<icon-button id="cancel" width="64" height="64" icon="gui/main_quit.png"
I18N="In the user screen" text="Cancel" label_location="bottom"/>
</buttonbar>

View File

@ -67,6 +67,8 @@
I18N="In the user screen" text="Delete" label_location="bottom"/>
<icon-button id="rename" width="64" height="64" icon="gui/rename.png"
I18N="In the user screen" text="Rename" label_location="bottom"/>
<icon-button id="default_kart_color" width="64" height="64" icon="gui/edit.png"
I18N="In the user screen" text="Default kart color" label_location="bottom"/>
<icon-button id="cancel" width="64" height="64" icon="gui/main_quit.png"
I18N="In the user screen" text="Cancel" label_location="bottom"/>
</buttonbar>

View File

@ -9,7 +9,6 @@
handled as one, so list it here -->
<bubblegum model="bubblegum.spm" lowmodel="bubblegum-low.spm" glow="246 150 209"/>
<bubblegum-nolok model="bubblegum-nolok.spm" lowmodel="bubblegum-nolok-low.spm"/>
<!-- <easter-egg model="easter_egg.spm" /> -->
<easter-egg model="easter_egg.spm" />
<easter-egg model="easter_egg.spm" glow="0 60 120" />
</items>

View File

@ -16,14 +16,14 @@ out vec4 Spec;
void main(void)
{
vec2 uv = gl_FragCoord.xy / screen;
vec2 uv = gl_FragCoord.xy / u_screen;
vec3 normal = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
Diff = vec4(0.25 * DiffuseIBL(normal), 1.);
float z = texture(dtex, uv).x;
vec4 xpos = getPosFromUVDepth(vec3(uv, z), InverseProjectionMatrix);
vec4 xpos = getPosFromUVDepth(vec3(uv, z), u_inverse_projection_matrix);
vec3 eyedir = -normalize(xpos.xyz);
float specval = texture(ntex, uv).z;

View File

@ -1,142 +0,0 @@
uniform sampler2D depth;
uniform float split0;
uniform float split1;
uniform float split2;
uniform float splitmax;
uniform mat4 SunCamMatrix;
layout (local_size_x = 8, local_size_y = 8) in;
struct CascadeBoundingBox
{
int xmin;
int xmax;
int ymin;
int ymax;
int zmin;
int zmax;
};
layout (std430) buffer BoundingBoxes
{
CascadeBoundingBox BB[4];
};
#stk_include "utils/getPosFromUVDepth.frag"
shared int xmin[4];
shared int xmax[4];
shared int ymin[4];
shared int ymax[4];
shared int zmin[4];
shared int zmax[4];
void main()
{
if (gl_LocalInvocationIndex < 4) {
xmin[gl_LocalInvocationIndex] = ymin[gl_LocalInvocationIndex] = zmin[gl_LocalInvocationIndex] = 1000;
xmax[gl_LocalInvocationIndex] = ymax[gl_LocalInvocationIndex] = zmax[gl_LocalInvocationIndex] = -1000;
}
barrier();
ivec3 lmax0 = ivec3(-1000);
ivec3 lmin0 = ivec3(1000);
ivec3 lmax1 = ivec3(-1000);
ivec3 lmin1 = ivec3(1000);
ivec3 lmax2 = ivec3(-1000);
ivec3 lmin2 = ivec3(1000);
ivec3 lmax3 = ivec3(-1000);
ivec3 lmin3 = ivec3(1000);
vec2 start_xy = gl_LocalInvocationID.xy + gl_WorkGroupID.xy * gl_WorkGroupSize.xy * 8;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
vec2 uv = (start_xy + vec2(i, j) * gl_WorkGroupID.xy) / screen;
float z = texture(depth, uv).x;
vec4 xpos = getPosFromUVDepth(vec3(uv, z), InverseProjectionMatrix);
vec4 lightcoord = InverseViewMatrix * xpos;
lightcoord /= lightcoord.w;
lightcoord = SunCamMatrix * lightcoord;
lightcoord /= lightcoord.w;
ivec3 lc = ivec3(lightcoord.xyz) * 4;
if (xpos.z < split0) {
lmax0 = max(lmax0, lc);
lmin0 = min(lmin0, lc);
} else if (xpos.z < split1) {
lmax1 = max(lmax1, lc);
lmin1 = min(lmin1, lc);
} else if (xpos.z < split2) {
lmax2 = max(lmax2, lc);
lmin2 = min(lmin2, lc);
} else if (xpos.z < splitmax) {
lmax3 = max(lmax3, lc);
lmin3 = min(lmin3, lc);
}
}
}
atomicMax(xmax[0], lmax0.x);
atomicMax(ymax[0], lmax0.y);
atomicMax(zmax[0], lmax0.z);
atomicMin(xmin[0], lmin0.x);
atomicMin(ymin[0], lmin0.y);
atomicMin(zmin[0], lmin0.z);
atomicMax(xmax[1], lmax1.x);
atomicMax(ymax[1], lmax1.y);
atomicMax(zmax[1], lmax1.z);
atomicMin(xmin[1], lmin1.x);
atomicMin(ymin[1], lmin1.y);
atomicMin(zmin[1], lmin1.z);
atomicMax(xmax[2], lmax2.x);
atomicMax(ymax[2], lmax2.y);
atomicMax(zmax[2], lmax2.z);
atomicMin(xmin[2], lmin2.x);
atomicMin(ymin[2], lmin2.y);
atomicMin(zmin[2], lmin2.z);
atomicMax(xmax[3], lmax3.x);
atomicMax(ymax[3], lmax3.y);
atomicMax(zmax[3], lmax3.z);
atomicMin(xmin[3], lmin3.x);
atomicMin(ymin[3], lmin3.y);
atomicMin(zmin[3], lmin3.z);
barrier();
if (gl_LocalInvocationIndex == 0) {
atomicMax(BB[0].xmax, xmax[0]);
atomicMax(BB[0].ymax, ymax[0]);
atomicMax(BB[0].zmax, zmax[0]);
atomicMin(BB[0].xmin, xmin[0]);
atomicMin(BB[0].ymin, ymin[0]);
atomicMin(BB[0].zmin, zmin[0]);
atomicMax(BB[1].xmax, xmax[1]);
atomicMax(BB[1].ymax, ymax[1]);
atomicMax(BB[1].zmax, zmax[1]);
atomicMin(BB[1].xmin, xmin[1]);
atomicMin(BB[1].ymin, ymin[1]);
atomicMin(BB[1].zmin, zmin[1]);
atomicMax(BB[2].xmax, xmax[2]);
atomicMax(BB[2].ymax, ymax[2]);
atomicMax(BB[2].zmax, zmax[2]);
atomicMin(BB[2].xmin, xmin[2]);
atomicMin(BB[2].ymin, ymin[2]);
atomicMin(BB[2].zmin, zmin[2]);
atomicMax(BB[3].xmax, xmax[3]);
atomicMax(BB[3].ymax, ymax[3]);
atomicMax(BB[3].zmax, zmax[3]);
atomicMin(BB[3].xmin, xmin[3]);
atomicMin(BB[3].ymin, ymin[3]);
atomicMin(BB[3].zmin, zmin[3]);
}
}

View File

@ -39,7 +39,7 @@ void main(void)
vec4 particle_color = vec4(color_lifetime.zyx, 1.0);
tc = Texcoord;
#if !defined(sRGB_Framebuffer_Usable) && !defined(Advanced_Lighting_Enabled)
#if !defined(Advanced_Lighting_Enabled)
particle_color.rgb = pow(particle_color.rgb, vec3(1.0 / 2.2));
#endif
pc = particle_color;
@ -54,12 +54,12 @@ void main(void)
vec3 newquadcorner = vec3(size * quadcorner, 0.0);
newquadcorner = newquadcorner + 2.0 * cross(cross(newquadcorner,
quat.xyz) + quat.w * newquadcorner, quat.xyz);
viewpos = ViewMatrix * vec4(Position + newquadcorner, 1.0);
viewpos = u_view_matrix * vec4(Position + newquadcorner, 1.0);
}
else
{
viewpos = ViewMatrix * vec4(Position, 1.0);
viewpos = u_view_matrix * vec4(Position, 1.0);
viewpos += vec4(size * quadcorner, 0.0, 0.0);
}
gl_Position = ProjectionMatrix * viewpos;
gl_Position = u_projection_matrix * viewpos;
}

View File

@ -8,7 +8,7 @@ out vec4 FragColor;
void main()
{
vec2 uv = gl_FragCoord.xy / screen;
vec2 uv = gl_FragCoord.xy / u_screen;
vec4 col = .125 * texture(tex_128, uv);
col += .25 * texture(tex_256, uv);
col += .5 * texture(tex_512, uv);

View File

@ -1,8 +1,8 @@
uniform ivec4 color;
out vec4 FragColor;
void main()
{
FragColor = vec4(color) / 255.;
}
uniform ivec4 color;
out vec4 FragColor;
void main()
{
FragColor = vec4(color) / 255.;
}

View File

@ -1,14 +1,14 @@
uniform vec2 center;
uniform vec2 size;
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec2 Position;
#else
in vec2 Position;
#endif
void main()
{
gl_Position = vec4(Position * size + center, 0., 1.);
}
uniform vec2 center;
uniform vec2 size;
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec2 Position;
#else
in vec2 Position;
#endif
void main()
{
gl_Position = vec4(Position * size + center, 0., 1.);
}

View File

@ -1,11 +1,11 @@
uniform sampler2D tex;
in vec2 uv;
in vec4 col;
out vec4 FragColor;
void main()
{
vec4 res = texture(tex, uv);
FragColor = res * col;
}
uniform sampler2D tex;
in vec2 uv;
in vec4 col;
out vec4 FragColor;
void main()
{
vec4 res = texture(tex, uv);
FragColor = res * col;
}

View File

@ -1,24 +1,24 @@
uniform vec2 center;
uniform vec2 size;
uniform vec2 texcenter;
uniform vec2 texsize;
#ifdef Explicit_Attrib_Location_Usable
layout(location=0) in vec2 Position;
layout(location=3) in vec2 Texcoord;
layout(location=2) in vec4 Color;
#else
in vec2 Position;
in vec2 Texcoord;
in vec4 Color;
#endif
out vec2 uv;
out vec4 col;
void main()
{
col = Color.zyxw;
uv = Texcoord * texsize + texcenter;
gl_Position = vec4(Position * size + center, 0., 1.);
}
uniform vec2 center;
uniform vec2 size;
uniform vec2 texcenter;
uniform vec2 texsize;
#ifdef Explicit_Attrib_Location_Usable
layout(location=0) in vec2 Position;
layout(location=3) in vec2 Texcoord;
layout(location=2) in vec4 Color;
#else
in vec2 Position;
in vec2 Texcoord;
in vec4 Color;
#endif
out vec2 uv;
out vec4 col;
void main()
{
col = Color.zyxw;
uv = Texcoord * texsize + texcenter;
gl_Position = vec4(Position * size + center, 0., 1.);
}

View File

@ -0,0 +1,43 @@
uniform sampler2D diffuse_map;
uniform sampler2D specular_map;
uniform sampler2D ssao_tex;
uniform sampler2D gloss_map;
uniform sampler2D diffuse_color;
uniform sampler2D depth_stencil;
out vec4 o_final_color;
#stk_include "utils/getPosFromUVDepth.frag"
void main()
{
vec2 tc = gl_FragCoord.xy / u_screen;
vec4 diffuseMatColor = texture(diffuse_color, tc);
// Gloss map here is stored in red and green for metallic and emit map
// Real gloss channel is stored in normal and depth framebuffer .z
float metallicMapValue = texture(gloss_map, tc).x;
float emitMapValue = texture(gloss_map, tc).y;
float ao = texture(ssao_tex, tc).x;
vec3 DiffuseComponent = texture(diffuse_map, tc).xyz;
vec3 SpecularComponent = texture(specular_map, tc).xyz;
vec3 diffuse_color_for_mix = diffuseMatColor.xyz * 4.0;
vec3 metallicMatColor = mix(vec3(0.04), diffuse_color_for_mix, metallicMapValue);
vec3 tmp = DiffuseComponent * mix(diffuseMatColor.xyz, vec3(0.0), metallicMapValue) + (metallicMatColor * SpecularComponent);
vec3 emitCol = diffuseMatColor.xyz * diffuseMatColor.xyz * diffuseMatColor.xyz * 15.;
vec4 color_1 = vec4(tmp * ao + (emitMapValue * emitCol), diffuseMatColor.a);
// Fog
float z = texture(depth_stencil, tc).x;
vec4 xpos = getPosFromUVDepth(vec3(tc, z), u_inverse_projection_matrix);
float dist = length(xpos.xyz);
// fog density
float factor = (1.0 - exp(u_fog_data.w * dist));
vec3 fog = u_fog_color.xyz * factor;
// Additively blend the color by fog
o_final_color = color_1 + vec4(fog, factor);
}

View File

@ -15,7 +15,7 @@ out vec4 Spec;
void main(void)
{
vec2 uv = gl_FragCoord.xy / screen;
vec2 uv = gl_FragCoord.xy / u_screen;
vec3 normal = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
Diff = vec4(0.25 * DiffuseIBL(normal), 1.);

View File

@ -1,30 +0,0 @@
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D Albedo;
layout(bindless_sampler) uniform sampler2D Detail;
layout(bindless_sampler) uniform sampler2D SpecMap;
#else
uniform sampler2D Albedo;
uniform sampler2D Detail;
uniform sampler2D SpecMap;
#endif
in vec2 uv;
in vec2 uv_bis;
out vec4 FragColor;
#stk_include "utils/getLightFactor.frag"
void main(void)
{
vec4 color = texture(Albedo, uv);
#ifdef Use_Bindless_Texture
#ifdef SRGBBindlessFix
color.xyz = pow(color.xyz, vec3(2.2));
#endif
#endif
vec4 detail = texture(Detail, uv_bis);
detail.rgb = detail.a * detail.rgb;
color.rgb = detail.rgb + color.rgb * (1. - detail.a);
float specmap = texture(SpecMap, uv).g;
FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap, 0.), 1.);
}

View File

@ -1,46 +0,0 @@
uniform sampler2D displacement_tex;
uniform sampler2D mask_tex;
uniform sampler2D color_tex;
uniform sampler2D tex;
uniform vec2 dir;
uniform vec2 dir2;
in vec2 uv;
in float camdist;
out vec4 FragColor;
const float maxlen = 0.02;
void main()
{
float horiz = texture(displacement_tex, uv + dir).x;
float vert = texture(displacement_tex, (uv.yx + dir2) * vec2(0.9)).x;
vec2 offset = vec2(horiz, vert);
offset *= 2.0;
offset -= 1.0;
// Fade according to distance to cam
float fade = 1.0 - smoothstep(1.0, 100.0, camdist);
vec4 shiftval;
shiftval.r = step(offset.x, 0.0) * -offset.x;
shiftval.g = step(0.0, offset.x) * offset.x;
shiftval.b = step(offset.y, 0.0) * -offset.y;
shiftval.a = step(0.0, offset.y) * offset.y;
vec2 shift;
shift.x = -shiftval.x + shiftval.y;
shift.y = -shiftval.z + shiftval.w;
shift /= 50.;
vec2 tc = gl_FragCoord.xy / screen;
float mask = texture(mask_tex, tc + shift).x;
tc += (mask < 1.) ? vec2(0.) : shift;
vec4 col = texture(color_tex, tc);
vec4 blend_tex = texture(tex, uv);
col.rgb = blend_tex.rgb * blend_tex.a + (1. - blend_tex.a) * col.rgb;
FragColor = vec4(col.rgb, 1.);
}

View File

@ -9,15 +9,15 @@ float range = 100.;
void main()
{
vec2 uv = gl_FragCoord.xy / screen;
vec2 uv = gl_FragCoord.xy / u_screen;
float curdepth = texture(dtex, uv).x;
vec4 FragPos = InverseProjectionMatrix * (2.0 * vec4(uv, curdepth, 1.0) - 1.0);
vec4 FragPos = u_inverse_projection_matrix * (2.0 * vec4(uv, curdepth, 1.0) - 1.0);
FragPos /= FragPos.w;
float depth = FragPos.z;
float blur = clamp(abs(depth - focalDepth) / range, -maxblur, maxblur);
vec2 offset = 10. / screen;
vec2 offset = 10. / u_screen;
vec4 col = texture(tex, uv);
vec4 colOriginal = col;

View File

@ -1,23 +0,0 @@
uniform sampler2D tex;
uniform float density;
uniform vec3 col;
out vec4 FragColor;
#stk_include "utils/getPosFromUVDepth.frag"
void main()
{
vec2 uv = gl_FragCoord.xy / screen;
float z = texture(tex, uv).x;
vec4 xpos = getPosFromUVDepth(vec3(uv, z), InverseProjectionMatrix);
float dist = length(xpos.xyz);
float factor = (1. - exp(- density * dist));
vec3 fog = col * factor;
// fog is scattering component, factor is the beer lambert absorption
FragColor = vec4(fog, factor);
}

View File

@ -4,5 +4,5 @@ layout(location = 0) in vec3 Position;
void main(void)
{
gl_Position = ShadowViewProjMatrixes[idx] * vec4(Position, 1.);
gl_Position = u_shadow_projection_view_matrices[idx] * vec4(Position, 1.);
}

View File

@ -1,89 +0,0 @@
// From http://graphics.cs.aueb.gr/graphics/research_illumination.html
// "Real-Time Diffuse Global Illumination Using Radiance Hints"
// paper and shader code
uniform sampler2D ntex;
uniform sampler2D dtex;
uniform sampler3D SHR;
uniform sampler3D SHG;
uniform sampler3D SHB;
uniform vec3 extents;
uniform mat4 RHMatrix;
uniform mat4 InvRHMatrix;
vec4 SHBasis (const in vec3 dir)
{
float L00 = 0.282095;
float L1_1 = 0.488603 * dir.y;
float L10 = 0.488603 * dir.z;
float L11 = 0.488603 * dir.x;
return vec4 (L11, L1_1, L10, L00);
}
vec3 SH2RGB (in vec4 sh_r, in vec4 sh_g, in vec4 sh_b, in vec3 dir)
{
vec4 Y = vec4(1.023326*dir.x, 1.023326*dir.y, 1.023326*dir.z, 0.886226);
return vec3 (dot(Y,sh_r), dot(Y,sh_g), dot(Y,sh_b));
}
out vec4 Diffuse;
#stk_include "utils/decodeNormal.frag"
#stk_include "utils/getPosFromUVDepth.frag"
vec3 resolution = vec3(32, 16, 32);
void main()
{
vec2 uv = gl_FragCoord.xy / screen;
vec3 GI = vec3(0.);
float depth = texture2D(dtex, uv).x;
// Discard background fragments
if (depth==1.0) discard;
vec4 pos_screen_space = getPosFromUVDepth(vec3(uv, depth), InverseProjectionMatrix);
vec4 tmp = (InvRHMatrix * InverseViewMatrix * pos_screen_space);
vec3 pos = tmp.xyz / tmp.w;
vec3 normal_screen_space = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
vec3 normal = (transpose(ViewMatrix) * vec4(normal_screen_space, 0.)).xyz;
// Convert to grid coordinates
vec3 uvw = .5 + 0.5 * pos / extents;
if (uvw.x < 0. || uvw.x > 1. || uvw.y < 0. || uvw.y > 1. || uvw.z < 0. || uvw.z > 1.) discard;
// Sample the RH volume at 4 locations, one directly above the shaded point,
// three on a ring 80degs away from the normal direction.
vec3 rnd = vec3(0,0,0);
// Generate the sample locations
vec3 v_rand = vec3(0.5);
vec3 tangent = normalize(cross(normal, v_rand));
vec3 bitangent = cross(normal, tangent);
vec3 D[4];
D[0] = vec3(1.0,0.0,0.0);
int i;
for (i=1; i<4; i++)
{
D[i] = vec3(0.1, 0.8*cos((rnd.x*1.5+i)*6.2832/3.0), 0.8*sin((rnd.x*1.5+i)*6.2832/3.0));
D[i] = normalize(D[i]);
}
for (i=0; i<4; i++)
{
vec3 SampleDir = normal * D[i].x + tangent * D[i].y + bitangent *D[i].z;
vec3 SampleOffset = (0.5 * normal + SampleDir) / resolution;
vec3 uvw_new = uvw + SampleOffset;
vec4 IncidentSHR = texture(SHR, uvw_new);
vec4 IncidentSHG = texture(SHG, uvw_new);
vec4 IncidentSHB = texture(SHB, uvw_new);
GI += SH2RGB(IncidentSHR, IncidentSHG, IncidentSHB, -normal);
}
GI /= 4;
Diffuse = max(16. * vec4(GI, 1.), vec4(0.));
}

View File

@ -1,8 +0,0 @@
flat in vec4 glowColor;
out vec4 FragColor;
void main()
{
FragColor = vec4(glowColor.bgr, 1.0);
}

View File

@ -1,24 +0,0 @@
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 7) in vec3 Origin;
layout(location = 8) in vec3 Orientation;
layout(location = 9) in vec3 Scale;
layout(location = 10) in vec4 misc_data;
#else
in vec3 Position;
in vec3 Origin;
in vec3 Orientation;
in vec3 Scale;
in vec4 misc_data;
#endif
flat out vec4 glowColor;
#stk_include "utils/getworldmatrix.vert"
void main(void)
{
mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale);
mat4 TransposeInverseModelView = transpose(getInverseWorldMatrix(Origin, Orientation, Scale) * InverseViewMatrix);
gl_Position = ProjectionViewMatrix * ModelMatrix * vec4(Position, 1.);
glowColor = misc_data;
}

View File

@ -6,7 +6,7 @@ out vec4 FragColor;
void main()
{
// Use quarter resolution
vec2 uv = 4. * gl_FragCoord.xy / screen;
vec2 uv = 4. * gl_FragCoord.xy / u_screen;
vec4 res = texture(tex, uv);
// Keep the sun fully bright, but fade the sky

View File

@ -9,7 +9,7 @@ out vec4 FragColor;
void main()
{
vec2 uv = 4. * gl_FragCoord.xy / screen;
vec2 uv = 4. * gl_FragCoord.xy / u_screen;
vec2 texc = uv;
vec2 tosun = sunpos - texc;

View File

@ -1,39 +0,0 @@
uniform vec3 windDir;
uniform mat4 ModelMatrix;
uniform mat4 InverseModelMatrix;
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 2) in vec4 Color;
layout(location = 3) in vec2 Texcoord;
#else
in vec3 Position;
in vec3 Normal;
in vec4 Color;
in vec2 Texcoord;
#endif
out vec3 nor;
out vec2 uv;
void main()
{
vec3 test = sin(windDir * (Position.y * 0.1)) * 1.;
test += cos(windDir) * 0.7;
mat4 new_model_matrix = ModelMatrix;
mat4 new_inverse_model_matrix = InverseModelMatrix;
new_model_matrix[3].xyz += test * Color.r;
// FIXME doesn't seem to make too much difference in pass 2, because this
// affects "nor" which is later only * 0.1 by scattering
new_inverse_model_matrix[3].xyz -= test * Color.r;
mat4 ModelViewProjectionMatrix = ProjectionViewMatrix * new_model_matrix;
mat4 TransposeInverseModelView = transpose(InverseViewMatrix * new_inverse_model_matrix);
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
uv = Texcoord;
}

View File

@ -1,41 +0,0 @@
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D Albedo;
layout(bindless_sampler) uniform sampler2D SpecMap;
layout(bindless_sampler) uniform sampler2D colorization_mask;
#else
uniform sampler2D Albedo;
uniform sampler2D SpecMap;
uniform sampler2D colorization_mask;
#endif
in vec3 nor;
in vec2 uv;
uniform vec2 color_change;
out vec4 FragColor;
#stk_include "utils/getLightFactor.frag"
#stk_include "utils/rgb_conversion.frag"
void main(void)
{
vec4 color = texture(Albedo, uv);
#ifdef Use_Bindless_Texture
#ifdef SRGBBindlessFix
color.xyz = pow(color.xyz, vec3(2.2));
#endif
#endif
if (color.a < 0.5) discard;
float mask = texture(colorization_mask, uv).a;
if (color_change.x > 0.0)
{
vec3 old_hsv = rgbToHsv(color.rgb);
float mask_step = step(mask, 0.5);
vec2 new_xy = mix(vec2(old_hsv.x, old_hsv.y), vec2(color_change.x, max(old_hsv.y, color_change.y)), vec2(mask_step, mask_step));
color.xyz = hsvToRgb(vec3(new_xy.x, new_xy.y, old_hsv.z));
}
float specmap = texture(SpecMap, uv).g;
float emitmap = texture(SpecMap, uv).b;
vec3 LightFactor = getLightFactor(color.xyz, vec3(1.), specmap, emitmap);
FragColor = vec4(LightFactor, 1.);
}

View File

@ -16,15 +16,16 @@ uniform float greenLmn[9];
uniform float redLmn[9];
#else
layout (std140) uniform MatrixesData
layout (std140) uniform Matrices
{
mat4 ViewMatrix;
mat4 ProjectionMatrix;
mat4 InverseViewMatrix;
mat4 InverseProjectionMatrix;
mat4 ProjectionViewMatrix;
mat4 ShadowViewProjMatrixes[4];
vec2 screen;
mat4 u_view_matrix;
mat4 u_projection_matrix;
mat4 u_inverse_view_matrix;
mat4 u_inverse_projection_matrix;
mat4 u_projection_view_matrix;
mat4 u_shadow_projection_view_matrices[4];
vec2 u_screen;
};
// Expand because of catalyst (14.12) not correctly associating array in UBO
@ -64,5 +65,12 @@ layout (std140) uniform LightingData
float rL22;
};
layout (std140) uniform SPFogData
{
// x: fog_start, y: fog_end, z: fog_max, w: fog_density
vec4 u_fog_data;
vec4 u_fog_color;
};
#endif
#endif // HEADER_TXT

View File

@ -1,35 +0,0 @@
#ifndef Use_Bindless_Texture
uniform sampler2D Albedo;
uniform sampler2D Detail;
uniform sampler2D SpecMap;
#endif
#ifdef Use_Bindless_Texture
flat in sampler2D handle;
flat in sampler2D secondhandle;
flat in sampler2D fourthhandle;
#endif
in vec2 uv;
in vec2 uv_bis;
out vec4 FragColor;
#stk_include "utils/getLightFactor.frag"
void main(void)
{
#ifdef Use_Bindless_Texture
vec4 color = texture(handle, uv);
float specmap = texture(secondhandle, uv).g;
#ifdef SRGBBindlessFix
color.xyz = pow(color.xyz, vec3(2.2));
#endif
vec4 detail = texture(fourthhandle, uv_bis);
#else
vec4 color = texture(Albedo, uv);
vec4 detail = texture(Detail, uv_bis);
float specmap = texture(SpecMap, uv).g;
#endif
detail.rgb = detail.a * detail.rgb;
color.rgb = detail.rgb + color.rgb * (1. - detail.a);
FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap, 0.), 1.);
}

View File

@ -1,57 +0,0 @@
uniform vec3 windDir;
#ifdef Explicit_Attrib_Location_Usable
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 = 7) in vec3 Origin;
layout(location = 8) in vec3 Orientation;
layout(location = 9) in vec3 Scale;
layout(location = 10) in vec4 misc_data;
#ifdef Use_Bindless_Texture
layout(location = 11) in sampler2D Handle;
layout(location = 12) in sampler2D SecondHandle;
layout(location = 13) in sampler2D ThirdHandle;
#endif
#else
in vec3 Position;
in vec3 Normal;
in vec4 Color;
in vec2 Texcoord;
in vec3 Origin;
in vec3 Orientation;
in vec3 Scale;
in vec4 misc_data;
#endif
out vec3 nor;
out vec2 uv;
flat out vec2 color_change;
#ifdef Use_Bindless_Texture
flat out sampler2D handle;
flat out sampler2D secondhandle;
flat out sampler2D thirdhandle;
#endif
#stk_include "utils/getworldmatrix.vert"
void main()
{
vec3 test = sin(windDir * (Position.y * 0.1)) * 1.;
test += cos(windDir) * 0.7;
mat4 ModelMatrix = getWorldMatrix(Origin + test * Color.r, Orientation, Scale);
mat4 TransposeInverseModelView = transpose(getInverseWorldMatrix(Origin + test * Color.r, Orientation, Scale) * InverseViewMatrix);
gl_Position = ProjectionViewMatrix * ModelMatrix * vec4(Position, 1.);
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
uv = Texcoord;
color_change = misc_data.zw;
#ifdef Use_Bindless_Texture
handle = Handle;
secondhandle = SecondHandle;
thirdhandle = ThirdHandle;
#endif
}

View File

@ -1,47 +0,0 @@
#ifndef Use_Bindless_Texture
uniform sampler2D Albedo;
uniform sampler2D SpecMap;
uniform sampler2D colorization_mask;
#endif
#ifdef Use_Bindless_Texture
flat in sampler2D handle;
flat in sampler2D secondhandle;
flat in sampler2D thirdhandle;
#endif
in vec3 nor;
in vec2 uv;
flat in vec2 color_change;
out vec4 FragColor;
#stk_include "utils/getLightFactor.frag"
#stk_include "utils/rgb_conversion.frag"
void main(void)
{
#ifdef Use_Bindless_Texture
vec4 color = texture(handle, uv);
float specmap = texture(secondhandle, uv).g;
float emitmap = texture(secondhandle, uv).b;
float mask = texture(thirdhandle, uv).a;
#ifdef SRGBBindlessFix
color.xyz = pow(color.xyz, vec3(2.2));
#endif
#else
vec4 color = texture(Albedo, uv);
float specmap = texture(SpecMap, uv).g;
float emitmap = texture(SpecMap, uv).b;
float mask = texture(colorization_mask, uv).a;
#endif
if (color.a < 0.5) discard;
if (color_change.x > 0.0)
{
vec3 old_hsv = rgbToHsv(color.rgb);
float mask_step = step(mask, 0.5);
vec2 new_xy = mix(vec2(old_hsv.x, old_hsv.y), vec2(color_change.x, max(old_hsv.y, color_change.y)), vec2(mask_step, mask_step));
color.xyz = hsvToRgb(vec3(new_xy.x, new_xy.y, old_hsv.z));
}
vec3 LightFactor = getLightFactor(color.xyz, vec3(1.), specmap, emitmap);
FragColor = vec4(LightFactor, 1.);
}

View File

@ -1,62 +0,0 @@
uniform int layer;
uniform vec3 windDir;
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 2) in vec4 Color;
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 Use_Bindless_Texture
layout(location = 11) in uvec2 Handle;
#endif
#else
in vec3 Position;
in vec4 Color;
in vec2 Texcoord;
in vec3 Origin;
in vec3 Orientation;
in vec3 Scale;
#endif
#ifdef VSLayer
out vec2 uv;
#ifdef Use_Bindless_Texture
flat out uvec2 handle;
#endif
#else
out vec2 tc;
out int layerId;
#ifdef Use_Bindless_Texture
flat out uvec2 hdle;
#endif
#endif
#stk_include "utils/getworldmatrix.vert"
void main(void)
{
vec3 test = sin(windDir * (Position.y* 0.5)) * 0.5;
test += cos(windDir) * 0.7;
mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale);
#ifdef VSLayer
gl_Layer = layer;
gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * vec4(Position + test * Color.r, 1.);
uv = Texcoord;
#ifdef Use_Bindless_Texture
handle = Handle;
#endif
#else
layerId = layer;
gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * vec4(Position + test * Color.r, 1.);
tc = Texcoord;
#ifdef Use_Bindless_Texture
hdle = Handle;
#endif
#endif
}

View File

@ -1,35 +0,0 @@
#ifndef Use_Bindless_Texture
uniform sampler2D normalMap;
uniform sampler2D glossMap;
#endif
#ifdef Use_Bindless_Texture
flat in sampler2D secondhandle;
flat in sampler2D fourthhandle;
#endif
in vec3 tangent;
in vec3 bitangent;
in vec2 uv;
out vec3 EncodedNormal;
#stk_include "utils/encode_normal.frag"
void main()
{
// normal in Tangent Space
#ifdef Use_Bindless_Texture
vec3 TS_normal = 2.0 * texture(fourthhandle, uv).rgb - 1.0;
float gloss = texture(secondhandle, uv).x;
#else
vec3 TS_normal = 2.0 * texture(normalMap, uv).rgb - 1.0;
float gloss = texture(glossMap, uv).x;
#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 = gloss;
}

View File

@ -1,72 +0,0 @@
#ifdef Explicit_Attrib_Location_Usable
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;
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;
layout(location = 10) in vec4 misc_data;
#ifdef Use_Bindless_Texture
layout(location = 11) in sampler2D Handle;
layout(location = 12) in sampler2D SecondHandle;
layout(location = 13) in sampler2D ThirdHandle;
layout(location = 14) in sampler2D FourthHandle;
#endif
#else
in vec3 Position;
in vec3 Normal;
in vec4 Color;
in vec2 Texcoord;
in vec2 SecondTexcoord;
in vec3 Tangent;
in vec3 Bitangent;
in vec3 Origin;
in vec3 Orientation;
in vec3 Scale;
in vec4 misc_data;
#endif
out vec3 nor;
out vec3 tangent;
out vec3 bitangent;
out vec2 uv;
out vec2 uv_bis;
out vec4 color;
flat out vec2 color_change;
#ifdef Use_Bindless_Texture
flat out sampler2D handle;
flat out sampler2D secondhandle;
flat out sampler2D thirdhandle;
flat out sampler2D fourthhandle;
#endif
#stk_include "utils/getworldmatrix.vert"
void main(void)
{
mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale);
mat4 TransposeInverseModelView = transpose(getInverseWorldMatrix(Origin, Orientation, Scale) * InverseViewMatrix);
gl_Position = ProjectionViewMatrix * ModelMatrix * vec4(Position, 1.);
// Keep orthogonality
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
// Keep direction
tangent = (ViewMatrix * ModelMatrix * vec4(Tangent, 0.)).xyz;
bitangent = (ViewMatrix * ModelMatrix * vec4(Bitangent, 0.)).xyz;
uv = vec2(Texcoord.x + misc_data.x, Texcoord.y + misc_data.y);
uv_bis = SecondTexcoord;
color = Color.zyxw;
color_change = misc_data.zw;
#ifdef Use_Bindless_Texture
handle = Handle;
secondhandle = SecondHandle;
thirdhandle = ThirdHandle;
fourthhandle = FourthHandle;
#endif
}

View File

@ -1,23 +0,0 @@
#ifndef Use_Bindless_Texture
uniform sampler2D glosstex;
#endif
#ifdef Use_Bindless_Texture
flat in sampler2D secondhandle;
#endif
in vec3 nor;
in vec2 uv;
out vec3 EncodedNormal;
#stk_include "utils/encode_normal.frag"
void main(void)
{
#ifdef Use_Bindless_Texture
float glossmap = texture(secondhandle, uv).x;
#else
float glossmap = texture(glosstex, uv).x;
#endif
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(nor)) + 0.5;
EncodedNormal.z = glossmap;
}

View File

@ -1,54 +0,0 @@
#ifndef Use_Bindless_Texture
uniform sampler2D Albedo;
uniform sampler2D SpecMap;
uniform sampler2D colorization_mask;
#endif
#ifdef Use_Bindless_Texture
flat in sampler2D handle;
flat in sampler2D secondhandle;
flat in sampler2D thirdhandle;
#endif
in vec2 uv;
in vec4 color;
flat in vec2 color_change;
out vec4 FragColor;
#stk_include "utils/getLightFactor.frag"
#stk_include "utils/rgb_conversion.frag"
void main(void)
{
#ifdef Use_Bindless_Texture
vec4 col = texture(handle, uv);
float specmap = texture(secondhandle, uv).g;
float emitmap = texture(secondhandle, uv).b;
float mask = texture(thirdhandle, uv).a;
#ifdef SRGBBindlessFix
col.xyz = pow(col.xyz, vec3(2.2));
#endif
#else
vec4 col = texture(Albedo, uv);
float specmap = texture(SpecMap, uv).g;
float emitmap = texture(SpecMap, uv).b;
float mask = texture(colorization_mask, uv).a;
#endif
if (color_change.x > 0.0)
{
vec3 old_hsv = rgbToHsv(col.rgb);
float mask_step = step(mask, 0.5);
vec2 new_xy = mix(vec2(old_hsv.x, old_hsv.y), vec2(color_change.x, max(old_hsv.y, color_change.y)), vec2(mask_step, mask_step));
vec3 new_color = hsvToRgb(vec3(new_xy.x, new_xy.y, old_hsv.z));
col = vec4(new_color.r, new_color.g, new_color.b, col.a);
}
#if defined(sRGB_Framebuffer_Usable) || defined(Advanced_Lighting_Enabled)
col.xyz *= pow(color.xyz, vec3(2.2));
#else
col.xyz *= color.xyz;
#endif
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, emitmap) , 1.);
}

View File

@ -1,32 +0,0 @@
#ifndef Use_Bindless_Texture
uniform sampler2D tex;
#endif
#ifdef Use_Bindless_Texture
flat in sampler2D handle;
#endif
in vec2 uv;
in vec4 color;
out vec4 FragColor;
void main(void)
{
#ifdef Use_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
if (col.a < 0.5) discard;
#if defined(sRGB_Framebuffer_Usable) || defined(Advanced_Lighting_Enabled)
col.xyz *= pow(color.xyz, vec3(2.2));
#else
col.xyz *= color.xyz;
#endif
FragColor = vec4(col.xyz, 1.);
}

View File

@ -1,33 +0,0 @@
// See http://www.ozone3d.net/tutorials/glsl_texturing_p04.php for ref
#ifndef Use_Bindless_Texture
uniform sampler2D tex;
#endif
#ifdef Use_Bindless_Texture
flat in sampler2D handle;
#endif
in vec3 nor;
out vec4 FragColor;
#stk_include "utils/getPosFromUVDepth.frag"
#stk_include "utils/getLightFactor.frag"
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 Use_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
FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 0., 0.), 1.);
}

View File

@ -1,29 +0,0 @@
#ifndef Use_Bindless_Texture
uniform sampler2D tex;
uniform sampler2D glosstex;
#endif
#ifdef Use_Bindless_Texture
flat in sampler2D handle;
flat in sampler2D secondhandle;
#endif
in vec3 nor;
in vec2 uv;
out vec3 EncodedNormal;
#stk_include "utils/encode_normal.frag"
void main() {
#ifdef Use_Bindless_Texture
vec4 col = texture(handle, uv);
float glossmap = texture(secondhandle, uv).x;
#else
vec4 col = texture(tex, uv);
float glossmap = texture(glosstex, uv).x;
#endif
if (col.a < 0.5)
discard;
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(nor)) + 0.5;
EncodedNormal.z = glossmap;
}

View File

@ -1,54 +0,0 @@
#ifndef Use_Bindless_Texture
uniform sampler2D Albedo;
uniform sampler2D SpecMap;
uniform sampler2D colorization_mask;
#endif
#ifdef Use_Bindless_Texture
flat in sampler2D handle;
flat in sampler2D secondhandle;
flat in sampler2D thirdhandle;
#endif
in vec2 uv;
in vec4 color;
flat in vec2 color_change;
out vec4 FragColor;
#stk_include "utils/getLightFactor.frag"
#stk_include "utils/rgb_conversion.frag"
void main(void)
{
#ifdef Use_Bindless_Texture
vec4 col = texture(handle, uv);
float specmap = texture(secondhandle, uv).g;
float emitmap = texture(secondhandle, uv).b;
float mask = texture(thirdhandle, uv).a;
#ifdef SRGBBindlessFix
col.xyz = pow(col.xyz, vec3(2.2));
#endif
#else
vec4 col = texture(Albedo, uv);
float specmap = texture(SpecMap, uv).g;
float emitmap = texture(SpecMap, uv).b;
float mask = texture(colorization_mask, uv).a;
#endif
if (col.a * color.a < 0.5) discard;
#if defined(sRGB_Framebuffer_Usable) || defined(Advanced_Lighting_Enabled)
col.xyz *= pow(color.xyz, vec3(2.2));
#else
col.xyz *= color.xyz;
#endif
if (color_change.x > 0.0)
{
vec3 old_hsv = rgbToHsv(col.rgb);
float mask_step = step(mask, 0.5);
vec2 new_xy = mix(vec2(old_hsv.x, old_hsv.y), vec2(color_change.x, max(old_hsv.y, color_change.y)), vec2(mask_step, mask_step));
vec3 new_color = hsvToRgb(vec3(new_xy.x, new_xy.y, old_hsv.z));
col = vec4(new_color.r, new_color.g, new_color.b, col.a);
}
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, emitmap), 1.);
}

View File

@ -1,27 +0,0 @@
#ifndef Use_Bindless_Texture
uniform sampler2D tex;
#endif
in vec2 uv;
in vec3 nor;
in vec4 color;
#ifdef Use_Bindless_Texture
flat in uvec2 handle;
#endif
layout (location = 0) out vec3 RSMColor;
layout (location = 1) out vec3 RSMNormals;
void main()
{
#ifdef Use_Bindless_Texture
vec4 col = texture(sampler2D(handle), uv);
#ifdef SRGBBindlessFix
col.xyz = pow(col.xyz, vec3(2.2));
#endif
#else
vec4 col = texture(tex, uv);
#endif
if (col.a < .5) discard;
RSMColor = col.xyz * color.rgb;
RSMNormals = .5 * normalize(nor) + .5;
}

View File

@ -1,38 +0,0 @@
uniform mat4 RSMMatrix;
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;
layout(location = 7) in vec3 Origin;
layout(location = 8) in vec3 Orientation;
layout(location = 9) in vec3 Scale;
#ifdef Use_Bindless_Texture
layout(location = 11) in uvec2 Handle;
#endif
out vec3 nor;
out vec2 uv;
out vec2 uv_bis;
out vec4 color;
#ifdef Use_Bindless_Texture
flat out uvec2 handle;
#endif
#stk_include "utils/getworldmatrix.vert"
void main(void)
{
mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale);
mat4 ModelViewProjectionMatrix = RSMMatrix * ModelMatrix;
mat4 TransposeInverseModel = transpose(inverse(ModelMatrix));
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
nor = (TransposeInverseModel * vec4(Normal, 0.)).xyz;
uv = Texcoord;
color = Color.zyxw;
#ifdef Use_Bindless_Texture
handle = Handle;
#endif
}

View File

@ -1,28 +0,0 @@
layout(triangles) in;
layout(triangle_strip, max_vertices=3) out;
#ifdef Use_Bindless_Texture
flat in uvec2 hdle[3];
#endif
in vec2 tc[3];
in int layerId[3];
out vec2 uv;
#ifdef Use_Bindless_Texture
out flat uvec2 handle;
#endif
void main(void)
{
gl_Layer = layerId[0];
#ifdef Use_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

@ -1,56 +0,0 @@
uniform int layer;
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
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 Use_Bindless_Texture
layout(location = 11) in uvec2 Handle;
#endif
#else
in vec3 Position;
in vec2 Texcoord;
in vec3 Origin;
in vec3 Orientation;
in vec3 Scale;
#endif
#ifdef VSLayer
out vec2 uv;
#ifdef Use_Bindless_Texture
flat out uvec2 handle;
#endif
#else
out vec2 tc;
out int layerId;
#ifdef Use_Bindless_Texture
flat out uvec2 hdle;
#endif
#endif
#stk_include "utils/getworldmatrix.vert"
void main(void)
{
mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale);
#ifdef VSLayer
gl_Layer = layer;
gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * vec4(Position, 1.);
uv = Texcoord;
#ifdef Use_Bindless_Texture
handle = Handle;
#endif
#else
layerId = layer;
gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * vec4(Position, 1.);
tc = Texcoord;
#ifdef Use_Bindless_Texture
hdle = Handle;
#endif
#endif
}

View File

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

View File

@ -1,94 +0,0 @@
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 2) in vec4 Color;
layout(location = 3) in vec4 Data1;
layout(location = 4) in vec4 Data2;
layout(location = 5) in ivec4 Joint;
layout(location = 6) in vec4 Weight;
layout(location = 7) in vec3 Origin;
layout(location = 8) in vec3 Orientation;
layout(location = 9) in vec3 Scale;
layout(location = 10) in vec4 misc_data;
#ifdef Use_Bindless_Texture
layout(location = 11) in sampler2D Handle;
layout(location = 12) in sampler2D SecondHandle;
layout(location = 13) in sampler2D ThirdHandle;
layout(location = 14) in sampler2D FourthHandle;
#endif
layout(location = 15) in int skinning_offset;
#else
in vec3 Position;
in vec3 Normal;
in vec4 Color;
in vec4 Data1;
in vec4 Data2;
in ivec4 Joint;
in vec4 Weight;
in vec3 Origin;
in vec3 Orientation;
in vec3 Scale;
in vec4 misc_data;
in int skinning_offset;
#endif
out vec3 nor;
out vec3 tangent;
out vec3 bitangent;
out vec2 uv;
out vec4 color;
flat out vec2 color_change;
#ifdef Use_Bindless_Texture
flat out sampler2D handle;
flat out sampler2D secondhandle;
flat out sampler2D thirdhandle;
flat out sampler2D fourthhandle;
#endif
#stk_include "utils/getworldmatrix.vert"
uniform samplerBuffer skinning_tex;
void main(void)
{
mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale);
mat4 TransposeInverseModelView = transpose(getInverseWorldMatrix(Origin, Orientation, Scale) * InverseViewMatrix);
vec4 idle_position = vec4(Position, 1.);
vec4 idle_normal = vec4(Normal, 0.);
vec4 idle_tangent = vec4(Data1.z, Data1.w, Data2.x, 0.);
vec4 idle_bitangent = vec4(Data2.y, Data2.z, Data2.w, 0.);
vec4 skinned_position = vec4(0.);
vec4 skinned_normal = vec4(0.);
vec4 skinned_tangent = vec4(0.);
vec4 skinned_bitangent = vec4(0.);
for (int i = 0; i < 4; i++)
{
mat4 joint_matrix = mat4(
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4),
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 1),
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 2),
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 3));
skinned_position += Weight[i] * joint_matrix * idle_position;
skinned_normal += Weight[i] * joint_matrix * idle_normal;
skinned_tangent += Weight[i] * joint_matrix * idle_tangent;
skinned_bitangent += Weight[i] * joint_matrix * idle_bitangent;
}
gl_Position = ProjectionViewMatrix * ModelMatrix * skinned_position;
// Keep orthogonality
nor = (TransposeInverseModelView * skinned_normal).xyz;
// Keep direction
tangent = (ViewMatrix * ModelMatrix * skinned_tangent).xyz;
bitangent = (ViewMatrix * ModelMatrix * skinned_bitangent).xyz;
uv = vec2(Data1.x + misc_data.x, Data1.y + misc_data.y);
color = Color.zyxw;
color_change = misc_data.zw;
#ifdef Use_Bindless_Texture
handle = Handle;
secondhandle = SecondHandle;
thirdhandle = ThirdHandle;
fourthhandle = FourthHandle;
#endif
}

View File

@ -1,73 +0,0 @@
uniform int layer;
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 3) in vec4 Data1;
layout(location = 5) in ivec4 Joint;
layout(location = 6) in vec4 Weight;
layout(location = 7) in vec3 Origin;
layout(location = 8) in vec3 Orientation;
layout(location = 9) in vec3 Scale;
#ifdef Use_Bindless_Texture
layout(location = 11) in uvec2 Handle;
#endif
layout(location = 15) in int skinning_offset;
#else
in vec3 Position;
in vec4 Data1;
in ivec4 Joint;
in vec4 Weight;
in vec3 Origin;
in vec3 Orientation;
in vec3 Scale;
in int skinning_offset;
#endif
#ifdef VSLayer
out vec2 uv;
#ifdef Use_Bindless_Texture
flat out uvec2 handle;
#endif
#else
out vec2 tc;
out int layerId;
#ifdef Use_Bindless_Texture
flat out uvec2 hdle;
#endif
#endif
#stk_include "utils/getworldmatrix.vert"
uniform samplerBuffer skinning_tex;
void main(void)
{
mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale);
vec4 idle_position = vec4(Position, 1.);
vec4 skinned_position = vec4(0.);
for (int i = 0; i < 4; i++)
{
mat4 joint_matrix = mat4(
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4),
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 1),
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 2),
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 3));
skinned_position += Weight[i] * joint_matrix * idle_position;
}
#ifdef VSLayer
gl_Layer = layer;
gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * skinned_position;
uv = Data1.xy;
#ifdef Use_Bindless_Texture
handle = Handle;
#endif
#else
layerId = layer;
gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * skinned_position;
tc = Data1.xy;
#ifdef Use_Bindless_Texture
hdle = Handle;
#endif
#endif
}

View File

@ -11,7 +11,7 @@ out vec4 FragColor;
void main()
{
vec2 uv = gl_FragCoord.xy / screen;
vec2 uv = gl_FragCoord.xy / u_screen;
vec4 col = .125 * texture(tex_128, uv);
col += .25 * texture(tex_256, uv);
col += .5 * texture(tex_512, uv);

View File

@ -6,7 +6,7 @@ out float Depth;
void main()
{
vec2 uv = gl_FragCoord.xy / screen;
vec2 uv = gl_FragCoord.xy / u_screen;
float d = texture(tex, uv).x;
float c0 = zn * zf, c1 = zn - zf, c2 = zf;
Depth = c0 / (d * c1 + c2);

View File

@ -12,7 +12,7 @@ out vec4 FragColor;
* bit.
*/
vec4 tex2Doffset(sampler2D map, vec2 texcoord, vec2 offset) {
return textureLod(map, texcoord + offset / screen, 0.0);
return textureLod(map, texcoord + offset / u_screen, 0.0);
}
float SearchXLeft(vec2 texcoord) {
@ -68,7 +68,7 @@ vec2 Area(vec2 distance, float e1, float e2) {
void main() {
vec4 areas = vec4(0.0);
vec2 uv = gl_FragCoord.xy / screen;
vec2 uv = gl_FragCoord.xy / u_screen;
vec2 e = texture(edgesMap, uv).rg;
@ -79,7 +79,7 @@ void main() {
// Now fetch the crossing edges. Instead of sampling between edgels, we
// sample at 0.25, to be able to discern what value has each edgel:
vec4 coords = vec4(d.x, 0.25, d.y + 1.0, 0.25) / screen.xyxy + uv.xyxy;
vec4 coords = vec4(d.x, 0.25, d.y + 1.0, 0.25) / u_screen.xyxy + uv.xyxy;
float e1 = textureLod(edgesMap, coords.xy, 0.0).r;
float e2 = textureLod(edgesMap, coords.zw, 0.0).r;
@ -94,7 +94,7 @@ void main() {
vec2 d = vec2(SearchYUp(uv), SearchYDown(uv));
// Now fetch the crossing edges (yet again):
vec4 coords = vec4(-0.25, d.x, -0.25, d.y - 1.0) / screen.xyxy + uv.xyxy;
vec4 coords = vec4(-0.25, d.x, -0.25, d.y - 1.0) / u_screen.xyxy + uv.xyxy;
float e1 = textureLod(edgesMap, coords.xy, 0.0).g;
float e2 = textureLod(edgesMap, coords.zw, 0.0).g;

View File

@ -7,11 +7,11 @@ out vec4 FragColor;
void main() {
vec3 weights = vec3(0.2126,0.7152, 0.0722); // ITU-R BT. 709
vec2 uv = gl_FragCoord.xy / screen;
vec2 uv_left = uv + vec2(-1., 0.) / screen;
vec2 uv_top = uv + vec2(0., 1.) / screen;
vec2 uv_right = uv + vec2(1., 0.) / screen;
vec2 uv_bottom = uv + vec2(0., -1.) / screen;
vec2 uv = gl_FragCoord.xy / u_screen;
vec2 uv_left = uv + vec2(-1., 0.) / u_screen;
vec2 uv_top = uv + vec2(0., 1.) / u_screen;
vec2 uv_right = uv + vec2(1., 0.) / u_screen;
vec2 uv_bottom = uv + vec2(0., -1.) / u_screen;
/**
* Luma calculation requires gamma-corrected colors:

View File

@ -4,11 +4,11 @@ uniform sampler2D colorMap;
out vec4 FragColor;
void main() {
vec2 uv = gl_FragCoord.xy / screen;
vec2 uv_left = uv + vec2(-1., 0.) / screen;
vec2 uv_top = uv + vec2(0., 1.) / screen;
vec2 uv_right = uv + vec2(1., 0.) / screen;
vec2 uv_bottom = uv + vec2(0., -1.) / screen;
vec2 uv = gl_FragCoord.xy / u_screen;
vec2 uv_left = uv + vec2(-1., 0.) / u_screen;
vec2 uv_top = uv + vec2(0., 1.) / u_screen;
vec2 uv_right = uv + vec2(1., 0.) / u_screen;
vec2 uv_bottom = uv + vec2(0., -1.) / u_screen;
// Fetch the blending weights for current pixel:
vec4 topLeft = texture(blendMap, uv);

View File

@ -46,14 +46,14 @@ out vec4 FragColor;
void main()
{
vec2 texcoords = gl_FragCoord.xy / screen;
vec2 texcoords = gl_FragCoord.xy / u_screen;
// Sample the color buffer
vec3 color = texture(color_buffer, texcoords).rgb;
float z = texture(dtex, texcoords).x;
vec4 ViewPos = getPosFromUVDepth(vec3(texcoords, z), InverseProjectionMatrix);
vec4 OldScreenPos = previous_viewproj * InverseViewMatrix * ViewPos;
vec4 ViewPos = getPosFromUVDepth(vec3(texcoords, z), u_inverse_projection_matrix);
vec4 OldScreenPos = previous_viewproj * u_inverse_view_matrix * ViewPos;
OldScreenPos /= OldScreenPos.w;
OldScreenPos = .5 * OldScreenPos + .5;

View File

@ -1,22 +0,0 @@
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,29 +0,0 @@
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D normalMap;
layout(bindless_sampler) uniform sampler2D glossMap;
#else
uniform sampler2D normalMap;
uniform sampler2D glossMap;
#endif
in vec3 tangent;
in vec3 bitangent;
in vec2 uv;
out vec3 EncodedNormal;
#stk_include "utils/encode_normal.frag"
void main()
{
// normal in Tangent Space
vec3 TS_normal = 2.0 * texture(normalMap, uv).rgb - 1.0;
float gloss = texture(glossMap, uv).x;
// 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 = gloss;
}

View File

@ -1,60 +0,0 @@
#ifdef GL_ES
uniform mat4 ModelMatrix;
uniform mat4 InverseModelMatrix;
uniform vec2 texture_trans;
#else
uniform mat4 ModelMatrix =
mat4(1., 0., 0., 0.,
0., 1., 0., 0.,
0., 0., 1., 0.,
0., 0., 0., 1.);
uniform mat4 InverseModelMatrix =
mat4(1., 0., 0., 0.,
0., 1., 0., 0.,
0., 0., 1., 0.,
0., 0., 0., 1.);
uniform vec2 texture_trans = vec2(0., 0.);
#endif
#ifdef Explicit_Attrib_Location_Usable
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;
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;
out float camdist;
void main(void)
{
color = Color.zyxw;
mat4 ModelViewProjectionMatrix = ProjectionViewMatrix * ModelMatrix;
mat4 TransposeInverseModelView = transpose(InverseModelMatrix * InverseViewMatrix);
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
// Keep orthogonality
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
// Keep direction
tangent = (ViewMatrix * ModelMatrix * vec4(Tangent, 0.)).xyz;
bitangent = (ViewMatrix * ModelMatrix * vec4(Bitangent, 0.)).xyz;
uv = vec2(Texcoord.x + texture_trans.x, Texcoord.y + texture_trans.y);
uv_bis = SecondTexcoord;
camdist = length(ViewMatrix * ModelMatrix * vec4(Position, 1.));
}

View File

@ -1,18 +0,0 @@
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D tex;
#else
uniform sampler2D tex;
#endif
in vec3 nor;
in vec2 uv;
out vec3 EncodedNormal;
#stk_include "utils/encode_normal.frag"
void main(void)
{
float glossmap = texture(tex, uv).x;
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(nor)) + 0.5;
EncodedNormal.z = glossmap;
}

View File

@ -1,52 +0,0 @@
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D Albedo;
layout(bindless_sampler) uniform sampler2D SpecMap;
layout(bindless_sampler) uniform sampler2D colorization_mask;
#else
uniform sampler2D Albedo;
uniform sampler2D SpecMap;
uniform sampler2D colorization_mask;
#endif
uniform vec2 color_change;
in vec2 uv;
in vec4 color;
out vec4 FragColor;
#stk_include "utils/getLightFactor.frag"
#stk_include "utils/rgb_conversion.frag"
void main(void)
{
#ifdef Use_Bindless_Texture
vec4 col = texture(Albedo, uv);
float mask = texture(colorization_mask, uv).a;
#ifdef SRGBBindlessFix
col.xyz = pow(col.xyz, vec3(2.2));
#endif
#else
vec4 col = texture(Albedo, uv);
float mask = texture(colorization_mask, uv).a;
#endif
if (color_change.x > 0.0)
{
vec3 old_hsv = rgbToHsv(col.rgb);
float mask_step = step(mask, 0.5);
vec2 new_xy = mix(vec2(old_hsv.x, old_hsv.y), vec2(color_change.x, max(old_hsv.y, color_change.y)), vec2(mask_step, mask_step));
vec3 new_color = hsvToRgb(vec3(new_xy.x, new_xy.y, old_hsv.z));
col = vec4(new_color.r, new_color.g, new_color.b, col.a);
}
#if defined(sRGB_Framebuffer_Usable) || defined(Advanced_Lighting_Enabled)
col.xyz *= pow(color.xyz, vec3(2.2));
#else
col.xyz *= color.xyz;
#endif
float specmap = texture(SpecMap, uv).g;
float emitmap = texture(SpecMap, uv).b;
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, emitmap), 1.);
}

View File

@ -1,28 +0,0 @@
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D tex;
#else
uniform sampler2D tex;
#endif
in vec2 uv;
in vec4 color;
out vec4 FragColor;
void main(void)
{
vec4 col = texture(tex, uv);
#ifdef Use_Bindless_Texture
#ifdef SRGBBindlessFix
col.xyz = pow(col.xyz, vec3(2.2));
#endif
#endif
if (col.a < 0.5) discard;
#if defined(sRGB_Framebuffer_Usable) || defined(Advanced_Lighting_Enabled)
col.xyz *= pow(color.xyz, vec3(2.2));
#else
col.xyz *= color.xyz;
#endif
FragColor = vec4(col.xyz, 1.);
}

View File

@ -1,30 +0,0 @@
// See http://www.ozone3d.net/tutorials/glsl_texturing_p04.php for ref
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D tex;
#else
uniform sampler2D tex;
#endif
in vec3 nor;
out vec4 FragColor;
#stk_include "utils/getPosFromUVDepth.frag"
#stk_include "utils/getLightFactor.frag"
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;
vec4 detail0 = texture(tex, r.xy / m + .5);
#ifdef Use_Bindless_Texture
#ifdef SRGBBindlessFix
detail0.xyz = pow(detail0.xyz, vec3(2.2));
#endif
#endif
FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 0., 0.), 1.);
}

View File

@ -1,23 +0,0 @@
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D tex;
layout(bindless_sampler) uniform sampler2D glosstex;
#else
uniform sampler2D tex;
uniform sampler2D glosstex;
#endif
in vec3 nor;
in vec2 uv;
out vec3 EncodedNormal;
#stk_include "utils/encode_normal.frag"
void main() {
vec4 col = texture(tex, uv);
if (col.a < 0.5)
discard;
float glossmap = texture(glosstex, uv).x;
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(nor)) + 0.5;
EncodedNormal.z = glossmap;
}

View File

@ -1,49 +0,0 @@
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D Albedo;
layout(bindless_sampler) uniform sampler2D SpecMap;
layout(bindless_sampler) uniform sampler2D colorization_mask;
#else
uniform sampler2D Albedo;
uniform sampler2D SpecMap;
uniform sampler2D colorization_mask;
#endif
uniform vec2 color_change;
in vec2 uv;
in vec4 color;
out vec4 FragColor;
#stk_include "utils/getLightFactor.frag"
#stk_include "utils/rgb_conversion.frag"
void main(void)
{
vec4 col = texture(Albedo, uv);
#ifdef Use_Bindless_Texture
#ifdef SRGBBindlessFix
col.xyz = pow(col.xyz, vec3(2.2));
#endif
#endif
if (col.a * color.a < 0.5) discard;
#if defined(sRGB_Framebuffer_Usable) || defined(Advanced_Lighting_Enabled)
col.xyz *= pow(color.xyz, vec3(2.2));
#else
col.xyz *= color.xyz;
#endif
float mask = texture(colorization_mask, uv).a;
if (color_change.x > 0.0)
{
vec3 old_hsv = rgbToHsv(col.rgb);
float mask_step = step(mask, 0.5);
vec2 new_xy = mix(vec2(old_hsv.x, old_hsv.y), vec2(color_change.x, max(old_hsv.y, color_change.y)), vec2(mask_step, mask_step));
col.xyz = hsvToRgb(vec3(new_xy.x, new_xy.y, old_hsv.z));
}
float specmap = texture(SpecMap, uv).g;
float emitmap = texture(SpecMap, uv).b;
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, emitmap), 1.);
}

View File

@ -1,10 +0,0 @@
#version 140
uniform sampler2D tex;
in vec2 uv;
out vec4 FragColor;
void main()
{
FragColor = texture(tex, uv);
}

View File

@ -1,11 +0,0 @@
// Passthrough shader for drawQuad()
#version 140
in vec3 Position;
in vec2 Texcoord;
out vec2 uv;
void main() {
uv = Texcoord;
gl_Position = vec4(Position, 1.);
}

View File

@ -1,13 +0,0 @@
#version 300 es
precision mediump float;
uniform sampler2D tex;
in vec2 uv;
out vec4 FragColor;
void main()
{
FragColor = texture(tex, uv);
}

View File

@ -1,12 +0,0 @@
#version 300 es
precision mediump float;
in vec3 Position;
in vec2 Texcoord;
out vec2 uv;
void main() {
uv = Texcoord;
gl_Position = vec4(Position, 1.);
}

View File

@ -21,15 +21,15 @@ out vec4 Spec;
void main()
{
vec2 texc = gl_FragCoord.xy / screen;
vec2 texc = gl_FragCoord.xy / u_screen;
float z = texture(dtex, texc).x;
vec3 norm = normalize(DecodeNormal(2. * texture(ntex, texc).xy - 1.));
float roughness = texture(ntex, texc).z;
vec4 xpos = getPosFromUVDepth(vec3(texc, z), InverseProjectionMatrix);
vec4 xpos = getPosFromUVDepth(vec3(texc, z), u_inverse_projection_matrix);
vec3 eyedir = -normalize(xpos.xyz);
vec4 pseudocenter = ViewMatrix * vec4(center.xyz, 1.0);
vec4 pseudocenter = u_view_matrix * vec4(center.xyz, 1.0);
pseudocenter /= pseudocenter.w;
vec3 light_pos = pseudocenter.xyz;
vec3 light_col = col.xyz;

View File

@ -60,8 +60,8 @@ vec2 UpdateClipRegion(float lc, /* Light x/y coordinate (view space) */
vec4 ComputeClipRegion(vec3 lightPosView, float lightRadius)
{
if (lightPosView.z + lightRadius >= zNear) {
vec2 clipX = UpdateClipRegion(lightPosView.x, lightPosView.z, lightRadius, ProjectionMatrix[0][0]);
vec2 clipY = UpdateClipRegion(lightPosView.y, lightPosView.z, lightRadius, ProjectionMatrix[1][1]);
vec2 clipX = UpdateClipRegion(lightPosView.x, lightPosView.z, lightRadius, u_projection_matrix[0][0]);
vec2 clipY = UpdateClipRegion(lightPosView.y, lightPosView.z, lightRadius, u_projection_matrix[1][1]);
return vec4(clipX, clipY);
}
@ -72,7 +72,7 @@ vec4 ComputeClipRegion(vec3 lightPosView, float lightRadius)
void main(void)
{
vec4 Center = ViewMatrix * vec4(Position, 1.);
vec4 Center = u_view_matrix * vec4(Position, 1.);
Center /= Center.w;
vec2 ProjectedCornerPosition;
@ -98,7 +98,7 @@ void main(void)
float quadDepth = max(zNear, Center.z - Radius);
// Project quad depth into clip space
vec4 quadClip = ProjectionMatrix * vec4(0., 0., quadDepth, 1.0f);
vec4 quadClip = u_projection_matrix * vec4(0., 0., quadDepth, 1.0f);
gl_Position = vec4(ProjectedCornerPosition, quadClip.z / quadClip.w, 1.);
col = Color;

View File

@ -13,15 +13,15 @@ out vec4 Fog;
void main()
{
vec4 pseudocenter = ViewMatrix * vec4(center.xyz, 1.0);
vec4 pseudocenter = u_view_matrix * vec4(center.xyz, 1.0);
pseudocenter /= pseudocenter.w;
vec3 light_pos = pseudocenter.xyz;
vec3 light_col = col.xyz;
// Compute pixel position
vec2 texc = 2. * gl_FragCoord.xy / screen;
vec2 texc = 2. * gl_FragCoord.xy / u_screen;
float z = texture(dtex, texc).x;
vec4 pixelpos = getPosFromUVDepth(vec3(texc, z), InverseProjectionMatrix);
vec4 pixelpos = getPosFromUVDepth(vec3(texc, z), u_inverse_projection_matrix);
vec3 eyedir = -normalize(pixelpos.xyz);
vec3 farthestpoint = - eyedir * (min(dot(-eyedir, light_pos) + radius, length(pixelpos.xyz)));

View File

@ -16,13 +16,15 @@ in vec3 Tangent;
in vec3 Bitangent;
#endif
uniform vec2 fullscreen;
out vec2 uv;
out vec4 color;
void main(void)
{
color = Color.zyxw;
vec3 P = Position / vec3(screen, 1.);
vec3 P = Position / vec3(fullscreen, 1.);
P = 2. * P - 1.;
P.y *= -1.;
gl_Position = vec4(P, 1.);

View File

@ -1,116 +0,0 @@
// From http://graphics.cs.aueb.gr/graphics/research_illumination.html
// "Real-Time Diffuse Global Illumination Using Radiance Hints"
// paper and shader code
uniform float R_wcs = 10.; // Rmax: maximum sampling distance (in WCS units)
uniform vec3 extents;
uniform mat4 RHMatrix;
uniform mat4 RSMMatrix;
uniform sampler2D dtex;
uniform sampler2D ctex;
uniform sampler2D ntex;
uniform vec3 suncol;
flat in int slice;
layout (location = 0) out vec4 SHRed;
layout (location = 1) out vec4 SHGreen;
layout (location = 2) out vec4 SHBlue;
vec3 resolution = vec3(32, 16, 32);
#define SAMPLES 16
vec4 SHBasis (const in vec3 dir)
{
float L00 = 0.282095;
float L1_1 = 0.488603 * dir.y;
float L10 = 0.488603 * dir.z;
float L11 = 0.488603 * dir.x;
return vec4 (L11, L1_1, L10, L00);
}
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 * suncol.rgb;
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.;
vec3 RHcenter = (RHMatrix * vec4(normalizedRHCenter * extents, 1.)).xyz;
vec4 ShadowProjectedRH = RSMMatrix * vec4(RHcenter, 1.);
vec3 RHCellSize = extents / resolution;
vec2 RHuv = .5 * ShadowProjectedRH.xy / ShadowProjectedRH.w + .5;
float RHdepth = .5 * ShadowProjectedRH.z / ShadowProjectedRH.w + .5;
vec4 SHr = vec4(0.);
vec4 SHg = vec4(0.);
vec4 SHb = vec4(0.);
int x = int(gl_FragCoord.x), y = int(gl_FragCoord.y);
float phi = 30. * (x ^ y) + 10. * x * y;
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;
SHb /= 3.14159 * SAMPLES;
SHRed = SHr;
SHGreen = SHg;
SHBlue = SHb;
}

View File

@ -1,14 +0,0 @@
uniform sampler3D SHR;
uniform sampler3D SHG;
uniform sampler3D SHB;
in vec3 uvw;
out vec4 FragColor;
void main()
{
float r = texture(SHR, uvw).w;
float g = texture(SHG, uvw).w;
float b = texture(SHB, uvw).w;
FragColor = max(10. * vec4(r, g, b, 1.0), vec4(0.));
}

View File

@ -1,20 +0,0 @@
uniform vec3 extents;
uniform mat4 RHMatrix;
ivec3 resolution = ivec3(32, 16, 32);
out vec3 uvw;
void main(void)
{
// Determine the RH center
float gx = int(gl_VertexID) & (resolution.x - 1);
float gy = int(gl_VertexID >> 5) & (resolution.y - 1);
float gz = int(gl_VertexID >> 9) & (resolution.z - 1);
uvw = vec3(gx, gy, gz) / vec3(resolution);
vec3 WorldPos = (2. * uvw - 1.) * extents;
gl_Position = ProjectionViewMatrix * RHMatrix * vec4(WorldPos, 1.);
gl_PointSize = 500. / gl_Position.w;
}

View File

@ -1,17 +0,0 @@
layout(triangles) in;
layout(triangle_strip, max_vertices=3) out;
in int layer[3];
flat out int slice;
void main(void)
{
gl_Layer = layer[0];
for(int i=0; i<3; i++)
{
slice = layer[0];
gl_Position = gl_in[i].gl_Position;
EmitVertex();
}
EndPrimitive();
}

View File

@ -1,14 +0,0 @@
uniform sampler2D tex;
in vec2 uv;
in vec3 nor;
in vec4 color;
layout (location = 0) out vec3 RSMColor;
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,34 +0,0 @@
uniform mat4 ModelMatrix;
uniform mat4 RSMMatrix;
uniform vec2 texture_trans = vec2(0., 0.);
#ifdef Explicit_Attrib_Location_Usable
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(inverse(ModelMatrix));
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
nor = (TransposeInverseModel * vec4(Normal, 0.)).xyz;
uv = vec2(Texcoord.x + texture_trans.x, Texcoord.y + texture_trans.y);
uv_bis = SecondTexcoord;
color = Color.zyxw;
}

View File

@ -1,6 +0,0 @@
out vec4 FragColor;
void main()
{
FragColor = vec4(exp(32. * (2. * gl_FragCoord.z - 1.) / gl_FragCoord.w));
}

View File

@ -1,19 +0,0 @@
layout(triangles) in;
layout(triangle_strip, max_vertices=3) out;
in vec2 tc[3];
in int layerId[3];
out vec2 uv;
void main(void)
{
gl_Layer = layerId[0];
for(int i=0; i<3; i++)
{
uv = tc[i];
gl_Position = gl_in[i].gl_Position;
EmitVertex();
}
EndPrimitive();
}

View File

@ -1,30 +0,0 @@
uniform int layer;
uniform mat4 ModelMatrix;
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 3) in vec2 Texcoord;
#else
in vec3 Position;
in vec2 Texcoord;
#endif
#ifdef VSLayer
out vec2 uv;
#else
out vec2 tc;
out int layerId;
#endif
void main(void)
{
#ifdef VSLayer
gl_Layer = layer;
uv = Texcoord;
gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * vec4(Position, 1.);
#else
layerId = layer;
tc = Texcoord;
gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * vec4(Position, 1.);
#endif
}

View File

@ -1,37 +0,0 @@
uniform int layer;
uniform mat4 ModelMatrix;
uniform vec3 windDir;
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 2) in vec4 Color;
layout(location = 3) in vec2 Texcoord;
#else
in vec3 Position;
in vec4 Color;
in vec2 Texcoord;
#endif
#ifdef VSLayer
out vec2 uv;
#else
out vec2 tc;
out int layerId;
#endif
void main(void)
{
vec3 test = sin(windDir * (Position.y* 0.5)) * 0.5;
test += cos(windDir) * 0.7;
#ifdef VSLayer
gl_Layer = layer;
uv = Texcoord;
gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * vec4(Position + test * Color.r, 1.);
#else
layerId = layer;
tc = Texcoord;
gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * vec4(Position + test * Color.r, 1.);
#endif
}

View File

@ -1,52 +0,0 @@
uniform mat4 SunCamMatrix;
layout (local_size_x = 4) in;
struct CascadeBoundingBox
{
int xmin;
int xmax;
int ymin;
int ymax;
int zmin;
int zmax;
};
layout (std430) buffer BoundingBoxes
{
CascadeBoundingBox BB[4];
};
layout (std140) buffer NewMatrixData
{
mat4 ShadowMatrixes[4];
};
mat4 buildProjectionMatrixOrthoLH(float left, float right, float up, float down, float zNear, float zFar)
{
mat4 M;
M[0] = vec4(2. / (right - left), 0., 0., 0.);
M[1] = vec4(0., 2. / (up - down), 0., 0.);
M[2] = vec4(0., 0., 1. / (zFar - zNear), 0.);
M[3].x = - (right + left) / (right - left);
M[3].y = - (up + down) / (up - down);
M[3].z = zNear / (zNear - zFar);
M[3].w = 1.;
return M;
}
void main()
{
if (gl_LocalInvocationIndex > 3)
return;
ShadowMatrixes[gl_LocalInvocationIndex] = buildProjectionMatrixOrthoLH(
BB[gl_LocalInvocationIndex].xmin / 4. - 1., BB[gl_LocalInvocationIndex].xmax / 4. + 1.,
BB[gl_LocalInvocationIndex].ymax / 4. + 1., BB[gl_LocalInvocationIndex].ymin / 4. - 1.,
BB[gl_LocalInvocationIndex].zmin / 4. - 100., BB[gl_LocalInvocationIndex].zmax / 4. + 1.) * SunCamMatrix;
}

View File

@ -1,16 +0,0 @@
#ifdef Use_Bindless_Texture
layout(bindless_sampler) uniform sampler2D tex;
#else
uniform sampler2D tex;
#endif
in vec2 uv;
in vec4 color;
out vec4 FragColor;
void main(void)
{
vec4 col = texture(tex, uv);
if (col.a < 0.5) discard;
FragColor = vec4(exp(32. * (2. * gl_FragCoord.z - 1.) / gl_FragCoord.w));
}

View File

@ -10,11 +10,11 @@ out vec4 FragColor;
void main(void)
{
vec2 xy = gl_FragCoord.xy / screen;
vec2 xy = gl_FragCoord.xy / u_screen;
float FragZ = gl_FragCoord.z;
vec4 FragmentPos = getPosFromUVDepth(vec3(xy, FragZ), InverseProjectionMatrix);
vec4 FragmentPos = getPosFromUVDepth(vec3(xy, FragZ), u_inverse_projection_matrix);
float EnvZ = texture(dtex, xy).x;
vec4 EnvPos = getPosFromUVDepth(vec3(xy, EnvZ), InverseProjectionMatrix);
vec4 EnvPos = getPosFromUVDepth(vec3(xy, EnvZ), u_inverse_projection_matrix);
float alpha = clamp((EnvPos.z - FragmentPos.z) * 0.3, 0., 1.);
float billboard_alpha = mix(1.0, texture(tex, tc).a, billboard_mix);
FragColor = texture(tex, tc) * billboard_alpha * pc * alpha;

View File

@ -44,7 +44,7 @@ void main(void)
vec4 particle_color = vec4(color_lifetime.zyx, 1.0) * alpha;
tc = Texcoord;
#if !defined(sRGB_Framebuffer_Usable) && !defined(Advanced_Lighting_Enabled)
#if !defined(Advanced_Lighting_Enabled)
particle_color.rgb = pow(particle_color.rgb, vec3(1.0 / 2.2));
#endif
pc = particle_color;
@ -59,12 +59,12 @@ void main(void)
vec3 newquadcorner = vec3(size * quadcorner, 0.0);
newquadcorner = newquadcorner + 2.0 * cross(cross(newquadcorner,
quat.xyz) + quat.w * newquadcorner, quat.xyz);
viewpos = ViewMatrix * vec4(Position + newquadcorner, 1.0);
viewpos = u_view_matrix * vec4(Position + newquadcorner, 1.0);
}
else
{
viewpos = ViewMatrix * vec4(Position, 1.0);
viewpos = u_view_matrix * vec4(Position, 1.0);
viewpos += vec4(size * quadcorner, 0.0, 0.0);
}
gl_Position = ProjectionMatrix * viewpos;
gl_Position = u_projection_matrix * viewpos;
}

View File

@ -1,93 +0,0 @@
#ifdef GL_ES
uniform mat4 ModelMatrix;
uniform mat4 InverseModelMatrix;
uniform vec2 texture_trans;
#else
uniform mat4 ModelMatrix =
mat4(1., 0., 0., 0.,
0., 1., 0., 0.,
0., 0., 1., 0.,
0., 0., 0., 1.);
uniform mat4 InverseModelMatrix =
mat4(1., 0., 0., 0.,
0., 1., 0., 0.,
0., 0., 1., 0.,
0., 0., 0., 1.);
uniform vec2 texture_trans = vec2(0., 0.);
#endif
uniform int skinning_offset;
#ifdef GL_ES
uniform sampler2D skinning_tex;
#else
uniform samplerBuffer skinning_tex;
#endif
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 2) in vec4 Color;
layout(location = 3) in vec4 Data1;
layout(location = 4) in vec4 Data2;
layout(location = 5) in ivec4 Joint;
layout(location = 6) in vec4 Weight;
#else
in vec3 Position;
in vec3 Normal;
in vec4 Color;
in vec4 Data1;
in vec4 Data2;
in ivec4 Joint;
in vec4 Weight;
#endif
out vec3 nor;
out vec3 tangent;
out vec3 bitangent;
out vec2 uv;
out vec4 color;
#stk_include "utils/getworldmatrix.vert"
void main(void)
{
mat4 TransposeInverseModelView = transpose(InverseModelMatrix * InverseViewMatrix);
vec4 idle_position = vec4(Position, 1.);
vec4 idle_normal = vec4(Normal, 0.);
vec4 idle_tangent = vec4(Data1.z, Data1.w, Data2.x, 0.);
vec4 idle_bitangent = vec4(Data2.y, Data2.z, Data2.w, 0.);
vec4 skinned_position = vec4(0.);
vec4 skinned_normal = vec4(0.);
vec4 skinned_tangent = vec4(0.);
vec4 skinned_bitangent = vec4(0.);
for (int i = 0; i < 4; i++)
{
#ifdef GL_ES
mat4 joint_matrix = mat4(
texelFetch(skinning_tex, ivec2(0, clamp(Joint[i] + skinning_offset, 0, MAX_BONES)), 0),
texelFetch(skinning_tex, ivec2(1, clamp(Joint[i] + skinning_offset, 0, MAX_BONES)), 0),
texelFetch(skinning_tex, ivec2(2, clamp(Joint[i] + skinning_offset, 0, MAX_BONES)), 0),
texelFetch(skinning_tex, ivec2(3, clamp(Joint[i] + skinning_offset, 0, MAX_BONES)), 0));
#else
mat4 joint_matrix = mat4(
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4),
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 1),
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 2),
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 3));
#endif
skinned_position += Weight[i] * joint_matrix * idle_position;
skinned_normal += Weight[i] * joint_matrix * idle_normal;
skinned_tangent += Weight[i] * joint_matrix * idle_tangent;
skinned_bitangent += Weight[i] * joint_matrix * idle_bitangent;
}
gl_Position = ProjectionViewMatrix * ModelMatrix * skinned_position;
// Keep orthogonality
nor = (TransposeInverseModelView * skinned_normal).xyz;
// Keep direction
tangent = (ViewMatrix * ModelMatrix * skinned_tangent).xyz;
bitangent = (ViewMatrix * ModelMatrix * skinned_bitangent).xyz;
uv = vec2(Data1.x + texture_trans.x, Data1.y + texture_trans.y);
color = Color.zyxw;
}

View File

@ -1,61 +0,0 @@
uniform mat4 ModelMatrix;
uniform int skinning_offset;
uniform int layer;
#ifdef GL_ES
uniform sampler2D skinning_tex;
#else
uniform samplerBuffer skinning_tex;
#endif
#ifdef Explicit_Attrib_Location_Usable
layout(location = 0) in vec3 Position;
layout(location = 3) in vec4 Data1;
layout(location = 5) in ivec4 Joint;
layout(location = 6) in vec4 Weight;
#else
in vec3 Position;
in vec4 Data1;
in ivec4 Joint;
in vec4 Weight;
#endif
#ifdef VSLayer
out vec2 uv;
#else
out vec2 tc;
out int layerId;
#endif
void main(void)
{
vec4 idle_position = vec4(Position, 1.);
vec4 skinned_position = vec4(0.);
for (int i = 0; i < 4; i++)
{
#ifdef GL_ES
mat4 joint_matrix = mat4(
texelFetch(skinning_tex, ivec2(0, clamp(Joint[i] + skinning_offset, 0, MAX_BONES)), 0),
texelFetch(skinning_tex, ivec2(1, clamp(Joint[i] + skinning_offset, 0, MAX_BONES)), 0),
texelFetch(skinning_tex, ivec2(2, clamp(Joint[i] + skinning_offset, 0, MAX_BONES)), 0),
texelFetch(skinning_tex, ivec2(3, clamp(Joint[i] + skinning_offset, 0, MAX_BONES)), 0));
#else
mat4 joint_matrix = mat4(
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4),
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 1),
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 2),
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 3));
#endif
skinned_position += Weight[i] * joint_matrix * idle_position;
}
#ifdef VSLayer
gl_Layer = layer;
uv = Data1.xy;
gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * skinned_position;
#else
layerId = layer;
tc = Data1.xy;
gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * skinned_position;
#endif
}

View File

@ -4,11 +4,11 @@ out vec4 FragColor;
void main(void)
{
vec3 eyedir = vec3(mod(gl_FragCoord.xy, screen) / screen, 1.);
vec3 eyedir = vec3(mod(gl_FragCoord.xy, u_screen) / u_screen, 1.);
eyedir = 2.0 * eyedir - 1.0;
vec4 tmp = (InverseProjectionMatrix * vec4(eyedir, 1.));
vec4 tmp = (u_inverse_projection_matrix * vec4(eyedir, 1.));
tmp /= tmp.w;
eyedir = (InverseViewMatrix * vec4(tmp.xyz, 0.)).xyz;
eyedir = (u_inverse_view_matrix * vec4(tmp.xyz, 0.)).xyz;
vec4 color = texture(tex, eyedir);
FragColor = vec4(color.xyz, 1.);
}

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