diff --git a/.appveyor.yml b/.appveyor.yml index 2240fa4b8..63adb70c2 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -47,7 +47,7 @@ install: #Get-ChildItem $env:ASSETS_DIR | Measure-Object -property length -sum before_build: - - ps: Copy-Item "${env:DEPS_DIR}\windows_64bit\dependencies" c:\projects\stk-code\dependencies –Recurse + - ps: Copy-Item "${env:DEPS_DIR}\windows_64bit\dependencies" c:\projects\stk-code\dependencies-64bit –Recurse - cmd: | md build cd build diff --git a/CHANGELOG.md b/CHANGELOG.md index 713fffdb4..b529b2f1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ * Code refactoring of both render pipeline by Benau and Elderme * New kart Wilber and Hexley by Jymis * New kart Kiki by Benau -* New tracks Cornfield Crossing and Candela City by samuncle +* New tracks Candela City, Cornfield Crossing and Las Dunas Arena by samuncle * Physics improvements and various physics bugfixes by hiker * Kart GFX improvements (exhaust and headlight) * In-game screen recording powered by libopenglrecorder diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e142e1fb..33ceb3a28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,13 @@ endif() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") include(CMakeDependentOption) +set(DEPENDENCIES "dependencies") +# In case of 64-bit windows, use a different path for dependencies +# so that both dependencies can be installed next to each other +if ( WIN32 AND (CMAKE_SIZEOF_VOID_P EQUAL 8 ) ) + set(DEPENDENCIES "dependencies-64bit") +endif() + include(BuildTypeSTKRelease) if (NOT CMAKE_BUILD_TYPE) message(STATUS "No build type selected, default to STKRelease") @@ -62,15 +69,16 @@ set(STK_INSTALL_DATA_DIR "share/supertuxkart" CACHE # These variables enable MSVC to find libraries located in "dependencies" if(WIN32) - set(ENV{PATH} "$ENV{PATH};${PROJECT_SOURCE_DIR}/dependencies/include") - set(ENV{LIB} ${PROJECT_SOURCE_DIR}/dependencies/lib) - set(ENV{OPENALDIR} ${PROJECT_SOURCE_DIR}/dependencies) + set(ENV{PATH} "$ENV{PATH};${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/include") + set(ENV{LIB} ${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib) + set(ENV{OPENALDIR} ${PROJECT_SOURCE_DIR}/${DEPENDENCIES}) add_definitions(-D_IRR_STATIC_LIB_) add_definitions(-DNO_IRR_COMPILE_WITH_X11_) endif() if(USE_GLES2) add_definitions(-DUSE_GLES2) + add_definitions(-D_IRR_COMPILE_WITH_OGLES2_ -DNO_IRR_COMPILE_WITH_OPENGL_) endif() if(SERVER_ONLY) @@ -78,9 +86,9 @@ if(SERVER_ONLY) add_definitions(-DNO_IRR_COMPILE_WITH_X11_) endif() -if(DISABLE_VPX) - add_definitions(-DNO_VPX) -endif() +#if(DISABLE_VPX) +# add_definitions(-DNO_VPX) +#endif() # Build the Bullet physics library add_subdirectory("${PROJECT_SOURCE_DIR}/lib/bullet") @@ -352,7 +360,7 @@ else() elseif(MINGW) set(PTHREAD_NAMES "winpthread-1" "libwinpthread-1" "pthreadGC2") endif() - find_library(PTHREAD_LIBRARY NAMES pthread ${PTHREAD_NAMES} PATHS ${PROJECT_SOURCE_DIR}/dependencies/lib) + find_library(PTHREAD_LIBRARY NAMES pthread ${PTHREAD_NAMES} PATHS ${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib) mark_as_advanced(PTHREAD_LIBRARY) # Set data dir (absolute or relative to CMAKE_INSTALL_PREFIX) @@ -374,9 +382,9 @@ endif() # CURL if(MSVC) - target_link_libraries(supertuxkart ${PROJECT_SOURCE_DIR}/dependencies/lib/libcurl.lib) + target_link_libraries(supertuxkart ${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib/libcurl.lib) elseif(MINGW) - target_link_libraries(supertuxkart ${PROJECT_SOURCE_DIR}/dependencies/lib/libcurldll.a) + target_link_libraries(supertuxkart ${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib/libcurldll.a) else() find_package(CURL REQUIRED) include_directories(${CURL_INCLUDE_DIRS}) @@ -396,7 +404,7 @@ target_link_libraries(supertuxkart ${FREETYPE_LIBRARIES} ${JPEG_LIBRARIES} ${TURBOJPEG_LIBRARY} - ${VPX_LIBRARIES} + #${VPX_LIBRARIES} ) if(NOT SERVER_ONLY) @@ -451,7 +459,7 @@ if(USE_WIIUSE) if(WIIUSE_BUILD) target_link_libraries(supertuxkart wiiuse) else() - target_link_libraries(supertuxkart ${PROJECT_SOURCE_DIR}/dependencies/lib/wiiuse.lib) + target_link_libraries(supertuxkart ${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib/wiiuse.lib) endif() else() target_link_libraries(supertuxkart wiiuse bluetooth) @@ -464,7 +472,7 @@ if(MSVC OR MINGW) target_link_libraries(supertuxkart iphlpapi.lib) add_custom_command(TARGET supertuxkart POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory - "${PROJECT_SOURCE_DIR}/dependencies/dll" + "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/dll" $) add_custom_target(stkshaders SOURCES ${STK_SHADERS}) endif() diff --git a/README.md b/README.md index 03804f03c..8f50b2fd0 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ To Build SuperTuxKart on Windows, follow these instructions: 2. Download the SuperTuxKart source package from either [SuperTuxKart download area - SourceForge.net](https://sourceforge.net/projects/supertuxkart/files/SuperTuxKart/0.9.2) or [SuperTuxKart.net - Source Control](https://supertuxkart.net/Source_control), and unpack it. *Note: If you downloaded the source package from here: [SuperTuxKart.net - Source Control](https://supertuxkart.net/Source_control), then both `stk-code` and `stk-assets` **must** be in the same directory, otherwise the build can result in failure* 3. Download the Windows dependencies package from either [SuperTuxKart download area: Dependecies - SourceForge.net](https://sourceforge.net/projects/supertuxkart/files/SuperTuxKart%20Dependencies/Windows/) -or [SuperTuxKart on GitHub - Dependencies](https://github.com/supertuxkart/dependencies), and unpack it; then, copy the `dependencies` directory from either the `windows` or the `windows_64bit` directories into the `stk-code` directory +or [SuperTuxKart on GitHub - Dependencies](https://github.com/supertuxkart/dependencies), and unpack it; then, copy the `dependencies` directory from either the `windows` or the `windows_64bit` directories into the `stk-code` directory, rename it to `dependencies-64bit` if you want to compile a 64bit build. 4. Download CMake from here: [CMake - download page](https://cmake.org/download/), install it; once CMake is installed, double click on the CMake icon on your desktop, and point it towards your `stk-code` directory in the 'Where is the source code' field, and point it to a directory called `build` or `bld` inside the stk-code directory. 5. Press 'Configure'; CMake will ask you if it is OK to create the aformentioned directory, press `Yes`. CMake will then ask you about your version of Visual Studio. Confirm your selection; *Please look at the table below to avoid confusion between version numbers and releases of Visual Studio*; diff --git a/android/generate_assets.sh b/android/generate_assets.sh index d3b61a5c4..e759724d7 100755 --- a/android/generate_assets.sh +++ b/android/generate_assets.sh @@ -20,10 +20,11 @@ ################################################################################ export KARTS="all" -export TRACKS="battleisland cornfield_crossing featunlocked gplose gpwin \ - hacienda introcutscene introcutscene2 lighthouse olivermath \ - overworld sandtrack scotland snowmountain snowtuxpeak \ - soccer_field tutorial" +export TRACKS="abyss battleisland cave cornfield_crossing endcutscene \ + featunlocked fortmagma gplose gpwin hacienda icy_soccer_field \ + introcutscene introcutscene2 lighthouse mines olivermath \ + overworld sandtrack scotland snowmountain snowtuxpeak \ + soccer_field stadium tutorial zengarden" export ASSETS_PATHS="../data \ ../../stk-assets \ diff --git a/android/make.sh b/android/make.sh index 401c3aefc..95a905d3d 100755 --- a/android/make.sh +++ b/android/make.sh @@ -342,6 +342,10 @@ check_error # Build apk echo "Building APK" +sed -i "s/minSdkVersion=\".*\"/minSdkVersion=\"$SDK_VERSION\"/g" \ + "$DIRNAME/AndroidManifest.xml" + + if [ "$BUILD_TOOL" = "gradle" ]; then export ANDROID_HOME="$SDK_PATH" gradle -Psdk_version=$SDK_VERSION \ diff --git a/cmake/FindFreetype.cmake b/cmake/FindFreetype.cmake index 7d27a2102..3e15de92e 100644 --- a/cmake/FindFreetype.cmake +++ b/cmake/FindFreetype.cmake @@ -10,8 +10,8 @@ # Freetype library list if(WIN32) - find_path(FREETYPE_INCLUDE_DIRS NAMES freetype/freetype.h PATHS "${PROJECT_SOURCE_DIR}/dependencies/include") - find_library(FREETYPE_LIBRARY NAMES freetype PATHS "${PROJECT_SOURCE_DIR}/dependencies/lib") + find_path(FREETYPE_INCLUDE_DIRS NAMES freetype/freetype.h PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/include") + find_library(FREETYPE_LIBRARY NAMES freetype PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib") set(FREETYPE_FOUND 1) set(FREETYPE_LIBRARIES ${FREETYPE_LIBRARY}) elseif(APPLE) diff --git a/cmake/FindFribidi.cmake b/cmake/FindFribidi.cmake index 5d772f041..c31f4bfe3 100644 --- a/cmake/FindFribidi.cmake +++ b/cmake/FindFribidi.cmake @@ -24,8 +24,8 @@ else() endif() if(NOT FRIBIDI_FOUND) - find_path(FRIBIDI_INCLUDE_DIR NAMES fribidi/fribidi.h PATHS /Library/Frameworks/fribidi.framework/Headers "${PROJECT_SOURCE_DIR}/dependencies/include") - find_library(FRIBIDI_LIBRARY NAMES fribidi PATHS /Library/Frameworks/fribidi.framework "${PROJECT_SOURCE_DIR}/dependencies/lib") + find_path(FRIBIDI_INCLUDE_DIR NAMES fribidi/fribidi.h PATHS /Library/Frameworks/fribidi.framework/Headers "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/include") + find_library(FRIBIDI_LIBRARY NAMES fribidi PATHS /Library/Frameworks/fribidi.framework "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib") include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Fribidi DEFAULT_MSG FRIBIDI_INCLUDE_DIR FRIBIDI_LIBRARY) diff --git a/cmake/FindOggVorbis.cmake b/cmake/FindOggVorbis.cmake index 387861c42..7f16d7e66 100644 --- a/cmake/FindOggVorbis.cmake +++ b/cmake/FindOggVorbis.cmake @@ -10,12 +10,12 @@ # OggVorbis library list -find_path(OGGVORBIS_OGG_INCLUDE_DIR NAMES ogg/ogg.h PATHS "${PROJECT_SOURCE_DIR}/dependencies/include") -find_path(OGGVORBIS_VORBIS_INCLUDE_DIR NAMES vorbis/vorbisfile.h PATHS "${PROJECT_SOURCE_DIR}/dependencies/include") -find_library(OGGVORBIS_OGG_LIBRARY NAMES ogg Ogg libogg PATHS "${PROJECT_SOURCE_DIR}/dependencies/lib") -find_library(OGGVORBIS_VORBIS_LIBRARY NAMES vorbis Vorbis libvorbis PATHS "${PROJECT_SOURCE_DIR}/dependencies/lib") -find_library(OGGVORBIS_VORBISFILE_LIBRARY NAMES vorbisfile libvorbisfile PATHS "${PROJECT_SOURCE_DIR}/dependencies/lib") -find_library(OGGVORBIS_VORBISENC_LIBRARY NAMES vorbisenc libvorbisenc PATHS "${PROJECT_SOURCE_DIR}/dependencies/lib") +find_path(OGGVORBIS_OGG_INCLUDE_DIR NAMES ogg/ogg.h PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/include") +find_path(OGGVORBIS_VORBIS_INCLUDE_DIR NAMES vorbis/vorbisfile.h PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/include") +find_library(OGGVORBIS_OGG_LIBRARY NAMES ogg Ogg libogg PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib") +find_library(OGGVORBIS_VORBIS_LIBRARY NAMES vorbis Vorbis libvorbis PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib") +find_library(OGGVORBIS_VORBISFILE_LIBRARY NAMES vorbisfile libvorbisfile PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib") +find_library(OGGVORBIS_VORBISENC_LIBRARY NAMES vorbisenc libvorbisenc PATHS "${PROJECT_SOURCE_DIR}/${DEPENDENCIES}/lib") if (APPLE) set(OGGVORBIS_OGG_INCLUDE_DIR "/Library/Frameworks/Ogg.framework/Headers/") diff --git a/data/gfx/explosion_low.xml b/data/gfx/explosion_low.xml new file mode 100644 index 000000000..d534eb557 --- /dev/null +++ b/data/gfx/explosion_low.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/data/graphical_restrictions.xml b/data/graphical_restrictions.xml index b0ecf177d..596fd1d5a 100644 --- a/data/graphical_restrictions.xml +++ b/data/graphical_restrictions.xml @@ -38,4 +38,5 @@ + diff --git a/data/shaders/alphatest_particle.vert b/data/shaders/alphatest_particle.vert index 420e40ec7..2cdd479ab 100644 --- a/data/shaders/alphatest_particle.vert +++ b/data/shaders/alphatest_particle.vert @@ -36,12 +36,13 @@ void main(void) } float lifetime = color_lifetime.w; - pc = vec4(color_lifetime.zyx, 1.0); + vec4 particle_color = vec4(color_lifetime.zyx, 1.0); tc = Texcoord; #if !defined(sRGB_Framebuffer_Usable) && !defined(Advanced_Lighting_Enabled) - pc.rgb = pow(pc.rgb, vec3(1.0 / 2.2)); + particle_color.rgb = pow(particle_color.rgb, vec3(1.0 / 2.2)); #endif + pc = particle_color; vec4 viewpos = vec4(0.); if (flips == 1) diff --git a/data/shaders/header.txt b/data/shaders/header.txt index c5d5326b7..158a55612 100644 --- a/data/shaders/header.txt +++ b/data/shaders/header.txt @@ -64,10 +64,12 @@ layout (std140) uniform LightingData float rL22; }; -layout (std140) uniform SkinningData +#ifdef SSBO_SKINNING +layout (std140, binding = 0) readonly buffer SkinningData { mat4 joint_matrices[MAX_BONES]; }; +#endif #endif #endif // HEADER_TXT diff --git a/data/shaders/instanced_objectref_pass2.frag b/data/shaders/instanced_objectref_pass2.frag index c2b3cd5e7..9fd9588c4 100644 --- a/data/shaders/instanced_objectref_pass2.frag +++ b/data/shaders/instanced_objectref_pass2.frag @@ -22,6 +22,7 @@ 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)); diff --git a/data/shaders/instanced_skinning.vert b/data/shaders/instanced_skinning.vert index 607bfc4f9..ee4d12638 100644 --- a/data/shaders/instanced_skinning.vert +++ b/data/shaders/instanced_skinning.vert @@ -49,6 +49,8 @@ flat out sampler2D fourthhandle; #stk_include "utils/getworldmatrix.vert" +uniform samplerBuffer skinning_tex; + void main(void) { mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale); @@ -61,18 +63,35 @@ void main(void) vec4 skinned_normal = vec4(0.); vec4 skinned_tangent = vec4(0.); vec4 skinned_bitangent = vec4(0.); - // Note : For normal we assume no scale factor in bone (otherwise we'll have to compute inversematrix for each bones...) - for (int i = 0; i < 4; i++) + if (Weight[0] < 0.01) { - vec4 single_bone_influenced_position = joint_matrices[clamp(Joint[i] + skinning_offset, 0, MAX_BONES)] * idle_position; - single_bone_influenced_position /= single_bone_influenced_position.w; - vec4 single_bone_influenced_normal = joint_matrices[clamp(Joint[i] + skinning_offset, 0, MAX_BONES)] * idle_normal; - vec4 single_bone_influenced_tangent = joint_matrices[clamp(Joint[i] + skinning_offset, 0, MAX_BONES)] * idle_tangent; - vec4 single_bone_influenced_bitangent = joint_matrices[clamp(Joint[i] + skinning_offset, 0, MAX_BONES)] * idle_bitangent; - skinned_position += Weight[i] * single_bone_influenced_position; - skinned_normal += Weight[i] * single_bone_influenced_normal; - skinned_tangent += Weight[i] * single_bone_influenced_tangent; - skinned_bitangent += Weight[i] * single_bone_influenced_bitangent; + skinned_position = idle_position; + skinned_normal = idle_normal; + skinned_tangent = idle_tangent; + skinned_bitangent = idle_bitangent; + } + else + { + for (int i = 0; i < 4; i++) + { + if (Weight[i] < 0.01) + { + break; + } +#ifdef SSBO_SKINNING + mat4 joint_matrix = joint_matrices[Joint[i] + skinning_offset]; +#else + mat4 joint_matrix = mat4( + texelFetch(skinning_tex, (Joint[i] + skinning_offset) * 4), + texelFetch(skinning_tex, (Joint[i] + skinning_offset) * 4 + 1), + texelFetch(skinning_tex, (Joint[i] + skinning_offset) * 4 + 2), + texelFetch(skinning_tex, (Joint[i] + skinning_offset) * 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; diff --git a/data/shaders/instanced_skinning_shadow.vert b/data/shaders/instanced_skinning_shadow.vert index 7f72e56fb..2fc326218 100644 --- a/data/shaders/instanced_skinning_shadow.vert +++ b/data/shaders/instanced_skinning_shadow.vert @@ -38,16 +38,36 @@ flat out uvec2 hdle; #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++) + if (Weight[0] < 0.01) { - vec4 single_bone_influenced_position = joint_matrices[clamp(Joint[i] + skinning_offset, 0, MAX_BONES)] * idle_position; - single_bone_influenced_position /= single_bone_influenced_position.w; - skinned_position += Weight[i] * single_bone_influenced_position; + skinned_position = idle_position; + } + else + { + for (int i = 0; i < 4; i++) + { + if (Weight[i] < 0.01) + { + break; + } +#ifdef SSBO_SKINNING + mat4 joint_matrix = joint_matrices[Joint[i] + skinning_offset]; +#else + mat4 joint_matrix = mat4( + texelFetch(skinning_tex, (Joint[i] + skinning_offset) * 4), + texelFetch(skinning_tex, (Joint[i] + skinning_offset) * 4 + 1), + texelFetch(skinning_tex, (Joint[i] + skinning_offset) * 4 + 2), + texelFetch(skinning_tex, (Joint[i] + skinning_offset) * 4 + 3)); +#endif + skinned_position += Weight[i] * joint_matrix * idle_position; + } } #ifdef VSLayer diff --git a/data/shaders/simple_particle.vert b/data/shaders/simple_particle.vert index 3f993b955..41cf4ca58 100644 --- a/data/shaders/simple_particle.vert +++ b/data/shaders/simple_particle.vert @@ -41,12 +41,13 @@ void main(void) float lifetime = color_lifetime.w; float alpha = mix(smoothstep(1.0, 0.8, lifetime), lifetime, billboard); billboard_mix = billboard; - pc = vec4(color_lifetime.zyx, 1.0) * alpha; + vec4 particle_color = vec4(color_lifetime.zyx, 1.0) * alpha; tc = Texcoord; #if !defined(sRGB_Framebuffer_Usable) && !defined(Advanced_Lighting_Enabled) - pc.rgb = pow(pc.rgb, vec3(1.0 / 2.2)); + particle_color.rgb = pow(particle_color.rgb, vec3(1.0 / 2.2)); #endif + pc = particle_color; vec4 viewpos = vec4(0.); if (flips == 1) diff --git a/data/shaders/skinning.vert b/data/shaders/skinning.vert index 192f4247f..d1496f4f8 100644 --- a/data/shaders/skinning.vert +++ b/data/shaders/skinning.vert @@ -17,6 +17,11 @@ uniform mat4 InverseModelMatrix = 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; @@ -55,18 +60,41 @@ void main(void) vec4 skinned_normal = vec4(0.); vec4 skinned_tangent = vec4(0.); vec4 skinned_bitangent = vec4(0.); - // Note : For normal we assume no scale factor in bone (otherwise we'll have to compute inversematrix for each bones...) - for (int i = 0; i < 4; i++) + if (Weight[0] < 0.01) { - vec4 single_bone_influenced_position = joint_matrices[clamp(Joint[i] + skinning_offset, 0, MAX_BONES)] * idle_position; - single_bone_influenced_position /= single_bone_influenced_position.w; - vec4 single_bone_influenced_normal = joint_matrices[clamp(Joint[i] + skinning_offset, 0, MAX_BONES)] * idle_normal; - vec4 single_bone_influenced_tangent = joint_matrices[clamp(Joint[i] + skinning_offset, 0, MAX_BONES)] * idle_tangent; - vec4 single_bone_influenced_bitangent = joint_matrices[clamp(Joint[i] + skinning_offset, 0, MAX_BONES)] * idle_bitangent; - skinned_position += Weight[i] * single_bone_influenced_position; - skinned_normal += Weight[i] * single_bone_influenced_normal; - skinned_tangent += Weight[i] * single_bone_influenced_tangent; - skinned_bitangent += Weight[i] * single_bone_influenced_bitangent; + skinned_position = idle_position; + skinned_normal = idle_normal; + skinned_tangent = idle_tangent; + skinned_bitangent = idle_bitangent; + } + else + { + for (int i = 0; i < 4; i++) + { + if (Weight[i] < 0.01) + { + break; + } +#ifdef SSBO_SKINNING + mat4 joint_matrix = joint_matrices[Joint[i] + skinning_offset]; +#elif defined(GL_ES) + mat4 joint_matrix = mat4( + texelFetch(skinning_tex, ivec2(0, skinning_offset + Joint[i]), 0), + texelFetch(skinning_tex, ivec2(1, skinning_offset + Joint[i]), 0), + texelFetch(skinning_tex, ivec2(2, skinning_offset + Joint[i]), 0), + texelFetch(skinning_tex, ivec2(3, skinning_offset + Joint[i]), 0)); +#else + mat4 joint_matrix = mat4( + texelFetch(skinning_tex, (Joint[i] + skinning_offset) * 4), + texelFetch(skinning_tex, (Joint[i] + skinning_offset) * 4 + 1), + texelFetch(skinning_tex, (Joint[i] + skinning_offset) * 4 + 2), + texelFetch(skinning_tex, (Joint[i] + skinning_offset) * 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; diff --git a/data/shaders/skinning_shadow.vert b/data/shaders/skinning_shadow.vert index eca18ec1a..71af0b9ae 100644 --- a/data/shaders/skinning_shadow.vert +++ b/data/shaders/skinning_shadow.vert @@ -1,6 +1,7 @@ uniform mat4 ModelMatrix; uniform int skinning_offset; uniform int layer; +uniform samplerBuffer skinning_tex; #ifdef Explicit_Attrib_Location_Usable layout(location = 0) in vec3 Position; @@ -25,11 +26,35 @@ void main(void) { vec4 idle_position = vec4(Position, 1.); vec4 skinned_position = vec4(0.); - for (int i = 0; i < 4; i++) + if (Weight[0] < 0.01) { - vec4 single_bone_influenced_position = joint_matrices[clamp(Joint[i] + skinning_offset, 0, MAX_BONES)] * idle_position; - single_bone_influenced_position /= single_bone_influenced_position.w; - skinned_position += Weight[i] * single_bone_influenced_position; + skinned_position = idle_position; + } + else + { + for (int i = 0; i < 4; i++) + { + if (Weight[i] < 0.01) + { + break; + } +#ifdef SSBO_SKINNING + mat4 joint_matrix = joint_matrices[Joint[i] + skinning_offset]; +#elif defined(GL_ES) + mat4 joint_matrix = mat4( + texelFetch(skinning_tex, ivec2(0, skinning_offset + Joint[i]), 0), + texelFetch(skinning_tex, ivec2(1, skinning_offset + Joint[i]), 0), + texelFetch(skinning_tex, ivec2(2, skinning_offset + Joint[i]), 0), + texelFetch(skinning_tex, ivec2(3, skinning_offset + Joint[i]), 0)); +#else + mat4 joint_matrix = mat4( + texelFetch(skinning_tex, (Joint[i] + skinning_offset) * 4), + texelFetch(skinning_tex, (Joint[i] + skinning_offset) * 4 + 1), + texelFetch(skinning_tex, (Joint[i] + skinning_offset) * 4 + 2), + texelFetch(skinning_tex, (Joint[i] + skinning_offset) * 4 + 3)); +#endif + skinned_position += Weight[i] * joint_matrix * idle_position; + } } #ifdef VSLayer diff --git a/data/stk_config.xml b/data/stk_config.xml index fb73a6b6f..fdfa07ca9 100644 --- a/data/stk_config.xml +++ b/data/stk_config.xml @@ -461,4 +461,10 @@ + + + diff --git a/lib/bullet/src/LinearMath/btSerializer.h b/lib/bullet/src/LinearMath/btSerializer.h index 689449a73..0b2dc1087 100644 --- a/lib/bullet/src/LinearMath/btSerializer.h +++ b/lib/bullet/src/LinearMath/btSerializer.h @@ -213,7 +213,7 @@ protected: int *intPtr=0; short *shtPtr=0; -#ifdef __MINGW64__ +#if defined(__MINGW64__) || defined(_WIN64) char *cp = 0;int dataLen =0;intptr_t nr=0; #else char *cp = 0;int dataLen =0;long nr=0; @@ -251,7 +251,7 @@ protected: cp++; } { -#ifdef __MINGW64__ +#if defined(__MINGW64__) || defined(_WIN64) nr= (intptr_t)cp; #else nr= (long)cp; @@ -290,7 +290,7 @@ protected: } { -#ifdef __MINGW64__ +#if defined(__MINGW64__) || defined(_WIN64) nr= (intptr_t)cp; #else nr= (long)cp; diff --git a/lib/irrlicht/include/S3DVertex.h b/lib/irrlicht/include/S3DVertex.h index 3d12edde6..ce3fe91a0 100644 --- a/lib/irrlicht/include/S3DVertex.h +++ b/lib/irrlicht/include/S3DVertex.h @@ -255,14 +255,8 @@ struct S3DVertexTangents : public S3DVertex struct S3DVertexSkinnedMesh : public S3DVertexTangents { - s32 m_joint_idx1; - s32 m_joint_idx2; - s32 m_joint_idx3; - s32 m_joint_idx4; - f32 m_weight1; - f32 m_weight2; - f32 m_weight3; - f32 m_weight4; + s16 m_joint_idx[4]; + s16 m_weight[4]; E_VERTEX_TYPE getType() const { diff --git a/lib/irrlicht/include/SSkinMeshBuffer.h b/lib/irrlicht/include/SSkinMeshBuffer.h index c12a2aa43..659d5a186 100644 --- a/lib/irrlicht/include/SSkinMeshBuffer.h +++ b/lib/irrlicht/include/SSkinMeshBuffer.h @@ -243,14 +243,14 @@ struct SSkinMeshBuffer : public IMeshBuffer Vertex.TCoords=Vertices_Standard[n].TCoords; Vertex.Tangent=core::vector3df(0.0f, 0.0f, 0.0f); Vertex.Binormal=core::vector3df(0.0f, 0.0f, 0.0f); - Vertex.m_joint_idx1 = 0; - Vertex.m_joint_idx2 = 0; - Vertex.m_joint_idx3 = 0; - Vertex.m_joint_idx4 = 0; - Vertex.m_weight1 = 0; - Vertex.m_weight2 = 0; - Vertex.m_weight3 = 0; - Vertex.m_weight4 = 0; + Vertex.m_joint_idx[0] = 0; + Vertex.m_joint_idx[1] = 0; + Vertex.m_joint_idx[2] = 0; + Vertex.m_joint_idx[3] = 0; + Vertex.m_weight[0] = 0; + Vertex.m_weight[1] = 0; + Vertex.m_weight[2] = 0; + Vertex.m_weight[3] = 0; Vertices_SkinnedMesh.push_back(Vertex); } } @@ -265,14 +265,14 @@ struct SSkinMeshBuffer : public IMeshBuffer Vertex.TCoords=Vertices_Tangents[n].TCoords; Vertex.Tangent=Vertices_Tangents[n].Tangent; Vertex.Binormal=Vertices_Tangents[n].Binormal; - Vertex.m_joint_idx1 = 0; - Vertex.m_joint_idx2 = 0; - Vertex.m_joint_idx3 = 0; - Vertex.m_joint_idx4 = 0; - Vertex.m_weight1 = 0; - Vertex.m_weight2 = 0; - Vertex.m_weight3 = 0; - Vertex.m_weight4 = 0; + Vertex.m_joint_idx[0] = 0; + Vertex.m_joint_idx[1] = 0; + Vertex.m_joint_idx[2] = 0; + Vertex.m_joint_idx[3] = 0; + Vertex.m_weight[0] = 0; + Vertex.m_weight[1] = 0; + Vertex.m_weight[2] = 0; + Vertex.m_weight[3] = 0; Vertices_SkinnedMesh.push_back(Vertex); } } diff --git a/lib/irrlicht/source/Irrlicht/CAnimatedMeshSceneNode.cpp b/lib/irrlicht/source/Irrlicht/CAnimatedMeshSceneNode.cpp index 030b107e2..52c9b5636 100644 --- a/lib/irrlicht/source/Irrlicht/CAnimatedMeshSceneNode.cpp +++ b/lib/irrlicht/source/Irrlicht/CAnimatedMeshSceneNode.cpp @@ -101,12 +101,12 @@ void CAnimatedMeshSceneNode::buildFrameNr(u32 timeMs) if (FramesPerSecond > 0.f) //forwards... { if (CurrentFrameNr > EndFrame) - CurrentFrameNr = StartFrame + fmod(CurrentFrameNr - StartFrame, (f32)(EndFrame-StartFrame)); + CurrentFrameNr = StartFrame + fmodf(CurrentFrameNr - StartFrame, (f32)(EndFrame-StartFrame)); } else //backwards... { if (CurrentFrameNr < StartFrame) - CurrentFrameNr = EndFrame - fmod(EndFrame - CurrentFrameNr, (f32)(EndFrame-StartFrame)); + CurrentFrameNr = EndFrame - fmodf(EndFrame - CurrentFrameNr, (f32)(EndFrame-StartFrame)); } } else diff --git a/lib/irrlicht/source/Irrlicht/CSkinnedMesh.cpp b/lib/irrlicht/source/Irrlicht/CSkinnedMesh.cpp index 411ba1077..4144d5b9e 100644 --- a/lib/irrlicht/source/Irrlicht/CSkinnedMesh.cpp +++ b/lib/irrlicht/source/Irrlicht/CSkinnedMesh.cpp @@ -11,6 +11,55 @@ #include "os.h" #include "irrMap.h" +inline irr::s16 float_16(irr::f32 in) +{ + irr::s32 i; + memcpy(&i, &in, 4); + irr::s32 s = (i >> 16) & 0x00008000; + irr::s32 e = ((i >> 23) & 0x000000ff) - (127 - 15); + irr::s32 m = i & 0x007fffff; + if (e <= 0) + { + if (e < -10) + { + return irr::s16(s); + } + m = (m | 0x00800000) >> (1 - e); + if (m & 0x00001000) + m += 0x00002000; + return irr::s16(s | (m >> 13)); + } + else if (e == 0xff - (127 - 15)) + { + if (m == 0) + { + return irr::s16(s | 0x7c00); + } + else + { + m >>= 13; + return irr::s16(s | 0x7c00 | m | (m == 0)); + } + } + else + { + if (m & 0x00001000) + { + m += 0x00002000; + if (m & 0x00800000) + { + m = 0; // overflow in significand, + e += 1; // adjust exponent + } + } + if (e > 30) + { + return irr::s16(s | 0x7c00); + } + return irr::s16(s | (e << 10) | (m >> 13)); + } +} + namespace irr { namespace scene @@ -1450,28 +1499,34 @@ void CSkinnedMesh::convertForSkinning() core::array this_influence; core::array reported_weight = wi[b][i]; reported_weight.sort(sortJointInfluenceFunc); - float remaining_weight = 1.0f; for (u32 j = 0; j < 4; j++) { JointInfluence influence; - if (reported_weight.size() > j) - influence = reported_weight[j]; - else - { - influence.joint_idx = -100000; - influence.weight = remaining_weight; - } - remaining_weight -= influence.weight; + influence.joint_idx = -100000; + influence.weight = 0.0f; this_influence.push_back(influence); } - LocalBuffers[b]->Vertices_SkinnedMesh[i].m_joint_idx1 = this_influence[0].joint_idx; - LocalBuffers[b]->Vertices_SkinnedMesh[i].m_joint_idx2 = this_influence[1].joint_idx; - LocalBuffers[b]->Vertices_SkinnedMesh[i].m_joint_idx3 = this_influence[2].joint_idx; - LocalBuffers[b]->Vertices_SkinnedMesh[i].m_joint_idx4 = this_influence[3].joint_idx; - LocalBuffers[b]->Vertices_SkinnedMesh[i].m_weight1 = this_influence[0].weight; - LocalBuffers[b]->Vertices_SkinnedMesh[i].m_weight2 = this_influence[1].weight; - LocalBuffers[b]->Vertices_SkinnedMesh[i].m_weight3 = this_influence[2].weight; - LocalBuffers[b]->Vertices_SkinnedMesh[i].m_weight4 = this_influence[3].weight; + float total_weight = 0.0f; + for (u32 j = 0; j < reported_weight.size(); j++) + { + total_weight += reported_weight[j].weight; + this_influence[j].joint_idx = reported_weight[j].joint_idx; + this_influence[j].weight = reported_weight[j].weight; + } + if (!reported_weight.empty()) + { + for (u32 j = 0; j < reported_weight.size(); j++) + { + this_influence[j].weight = + this_influence[j].weight / total_weight; + } + } + for (int j = 0; j < 4; j++) + { + LocalBuffers[b]->Vertices_SkinnedMesh[i].m_joint_idx[j] = (s16)this_influence[j].joint_idx; + LocalBuffers[b]->Vertices_SkinnedMesh[i].m_weight[j] = float_16 + (this_influence[j].weight); + } } } } @@ -1488,7 +1543,7 @@ void CSkinnedMesh::computeWeightInfluence(SJoint *joint, size_t &index, WeightIn { SWeight& weight = joint->Weights[i]; JointInfluence tmp; - tmp.joint_idx = index; + tmp.joint_idx = (int)index; tmp.weight = weight.strength; wi[weight.buffer_id][weight.vertex_id].push_back(tmp); } diff --git a/src/audio/sfx_manager.cpp b/src/audio/sfx_manager.cpp index 9cecda9dc..a49eae713 100644 --- a/src/audio/sfx_manager.cpp +++ b/src/audio/sfx_manager.cpp @@ -529,7 +529,7 @@ void SFXManager::loadSfx() delete root; // Now load them in parallel - const int max = m_all_sfx_types.size(); + const int max = (int)m_all_sfx_types.size(); SFXBuffer **array = new SFXBuffer *[max]; i = 0; diff --git a/src/config/saved_grand_prix.cpp b/src/config/saved_grand_prix.cpp index 5ee5b5371..7a2d5cbad 100644 --- a/src/config/saved_grand_prix.cpp +++ b/src/config/saved_grand_prix.cpp @@ -172,7 +172,7 @@ void SavedGrandPrix::loadKarts(std::vector & kart_list) else { // Get correct player - for(unsigned int x = kart_list.size()-m_player_karts; + for(unsigned int x = (unsigned int)kart_list.size()-m_player_karts; x < kart_list.size(); x++) { if(kart_list[x].m_local_player_id == m_karts[i].m_local_player_id) diff --git a/src/config/stk_config.cpp b/src/config/stk_config.cpp index add75014f..5bb1a5c1c 100644 --- a/src/config/stk_config.cpp +++ b/src/config/stk_config.cpp @@ -181,6 +181,7 @@ void STKConfig::init_defaults() m_disable_steer_while_unskid = false; m_camera_follow_skid = false; m_cutscene_fov = 0.61f; + m_max_skinning_bones = 1024; m_score_increase.clear(); m_leader_intervals.clear(); @@ -364,6 +365,11 @@ void STKConfig::getAllData(const XMLNode * root) fonts_list->get("digit-ttf", &m_digit_ttf ); } + if (const XMLNode *skinning = root->getNode("skinning")) + { + skinning->get("max-bones", &m_max_skinning_bones); + } + // Get the default KartProperties // ------------------------------ const XMLNode *node = root -> getNode("general-kart-defaults"); diff --git a/src/config/stk_config.hpp b/src/config/stk_config.hpp index b29d91891..761c8b56d 100644 --- a/src/config/stk_config.hpp +++ b/src/config/stk_config.hpp @@ -152,6 +152,8 @@ public: float m_cutscene_fov; + unsigned m_max_skinning_bones; + /** Lists of TTF files used in STK. */ std::vector m_normal_ttf; std::vector m_digit_ttf; diff --git a/src/config/user_config.cpp b/src/config/user_config.cpp index 95f013d91..c4aa910ab 100644 --- a/src/config/user_config.cpp +++ b/src/config/user_config.cpp @@ -122,7 +122,7 @@ void GroupUserConfigParam::writeInner(std::ofstream& stream, int level) const { std::string tab(level * 4,' '); for(int i = 0; i < level; i++) tab =+ " "; - const int children_amount = m_attributes.size(); + const int children_amount = (int)m_attributes.size(); stream << " " << tab.c_str() << "<" << m_param_name.c_str() << "\n"; @@ -144,7 +144,7 @@ void GroupUserConfigParam::findYourDataInAChildOf(const XMLNode* node) return; } - const int attributes_amount = m_attributes.size(); + const int attributes_amount = (int)m_attributes.size(); for (int n=0; nfindYourDataInAnAttributeOf(child); @@ -246,7 +246,7 @@ ListUserConfigParam::ListUserConfigParam(const char* param_name, template void ListUserConfigParam::write(std::ofstream& stream) const { - const int elts_amount = m_elements.size(); + const int elts_amount = (int)m_elements.size(); // comment if(m_comment.size() > 0) stream << "