diff --git a/data/fonts/materials.xml b/data/fonts/materials.xml new file mode 100644 index 000000000..b33a66186 --- /dev/null +++ b/data/fonts/materials.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/gui/user_screen.stkgui b/data/gui/user_screen.stkgui index acb65467f..a9c54f543 100644 --- a/data/gui/user_screen.stkgui +++ b/data/gui/user_screen.stkgui @@ -13,25 +13,25 @@ square_items="true" child_width="128" child_height="128" /> -
+
-
-
-
@@ -54,8 +54,6 @@ I18N="Login dialog" text="Add user" label_location="bottom"/> - -
+
-
-
-
-
diff --git a/data/shaders/detailledobject_pass2.frag b/data/shaders/detailledobject_pass2.frag index a426b6935..5b19966cc 100644 --- a/data/shaders/detailledobject_pass2.frag +++ b/data/shaders/detailledobject_pass2.frag @@ -1,9 +1,11 @@ #ifdef GL_ARB_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 #if __VERSION__ >= 130 @@ -16,7 +18,7 @@ varying vec2 uv_bis; #define FragColor gl_FragColor #endif -vec3 getLightFactor(float specMapValue); +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue); void main(void) { @@ -28,6 +30,6 @@ void main(void) #endif vec4 detail = texture(Detail, uv_bis); color *= detail; - vec3 LightFactor = getLightFactor(1. - color.a); - FragColor = vec4(color.xyz * LightFactor, 1.); + float specmap = texture(SpecMap, uv).g; + FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap), 1.); } diff --git a/data/shaders/diffuseenvmap.frag b/data/shaders/diffuseenvmap.frag index c88478b23..2ded6b2b0 100644 --- a/data/shaders/diffuseenvmap.frag +++ b/data/shaders/diffuseenvmap.frag @@ -2,11 +2,15 @@ uniform float blueLmn[9]; uniform float greenLmn[9]; uniform float redLmn[9]; uniform sampler2D ntex; +uniform sampler2D dtex; +uniform samplerCube tex; uniform mat4 TransposeViewMatrix; out vec4 Diff; +out vec4 Spec; vec3 DecodeNormal(vec2 n); +vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix); mat4 getMatrix(float L[9]) { @@ -24,8 +28,9 @@ void main(void) { vec2 uv = gl_FragCoord.xy / screen; vec3 normal = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.)); + // Convert normal in world space (where SH coordinates were computed) - vec4 extendednormal = TransposeViewMatrix * vec4(normal, 1.); + vec4 extendednormal = TransposeViewMatrix * vec4(normal, 0.); extendednormal.w = 1.; mat4 rmat = getMatrix(redLmn); mat4 gmat = getMatrix(greenLmn); @@ -36,4 +41,16 @@ void main(void) float b = dot(extendednormal, bmat * extendednormal); Diff = max(0.25 * vec4(r, g, b, .1), vec4(0.)); + + float z = texture(dtex, uv).x; + + vec4 xpos = getPosFromUVDepth(vec3(uv, z), InverseProjectionMatrix); + vec3 eyedir = -normalize(xpos.xyz); + vec3 sampleDirection = reflect(-eyedir, normal); + sampleDirection = (InverseViewMatrix * vec4(sampleDirection, 0.)).xyz; + + float specval = texture(ntex, uv).z; + float lodval = 16 * (1. - ((log2(specval) - 1.) / 10.)); + vec4 specular = textureLod(tex, sampleDirection, lodval); + Spec = max(specular, vec4(0.)); } diff --git a/data/shaders/grass_pass2.frag b/data/shaders/grass_pass2.frag index 408e78365..6b677ceea 100644 --- a/data/shaders/grass_pass2.frag +++ b/data/shaders/grass_pass2.frag @@ -1,9 +1,11 @@ #ifdef GL_ARB_bindless_texture layout(bindless_sampler) uniform sampler2D Albedo; layout(bindless_sampler) uniform sampler2D dtex; +layout(bindless_sampler) uniform sampler2D SpecMap; #else uniform sampler2D Albedo; uniform sampler2D dtex; +uniform sampler2D SpecMap; #endif uniform vec3 SunDir; @@ -12,10 +14,18 @@ in vec3 nor; in vec2 uv; out vec4 FragColor; -vec3 getLightFactor(float specMapValue); +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue); void main(void) { + vec4 color = texture(Albedo, uv); +#ifdef GL_ARB_bindless_texture +#ifdef SRGBBindlessFix + color.xyz = pow(color.xyz, vec3(2.2)); +#endif +#endif + if (color.a < 0.5) discard; + vec2 texc = gl_FragCoord.xy / screen; float z = texture(dtex, texc).x; @@ -30,14 +40,8 @@ void main(void) float fLdotNBack = max(0., - dot(nor, SunDir) * 0.6 + 0.4); float scattering = mix(fPowEdotL, fLdotNBack, .5); + float specmap = texture(SpecMap, uv).g; - vec4 color = texture(Albedo, uv); -#ifdef GL_ARB_bindless_texture -#ifdef SRGBBindlessFix - color.xyz = pow(color.xyz, vec3(2.2)); -#endif -#endif - if (color.a < 0.5) discard; - vec3 LightFactor = (scattering * 0.3) + getLightFactor(1.); + vec3 LightFactor = color.xyz * (scattering * 0.3) + getLightFactor(color.xyz, vec3(1.), specmap); FragColor = vec4(color.xyz * LightFactor, 1.); } diff --git a/data/shaders/instanced_detailledobject_pass2.frag b/data/shaders/instanced_detailledobject_pass2.frag index c631fe3ef..927a6a845 100644 --- a/data/shaders/instanced_detailledobject_pass2.frag +++ b/data/shaders/instanced_detailledobject_pass2.frag @@ -1,22 +1,25 @@ #ifndef GL_ARB_bindless_texture uniform sampler2D Albedo; uniform sampler2D Detail; +uniform sampler2D SpecMap; #endif #ifdef GL_ARB_bindless_texture flat in sampler2D handle; +flat in sampler2D secondhandle; flat in sampler2D thirdhandle; #endif in vec2 uv; in vec2 uv_bis; out vec4 FragColor; -vec3 getLightFactor(float specMapValue); +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue); void main(void) { #ifdef GL_ARB_bindless_texture vec4 color = texture(handle, uv); + float specmap = texture(secondhandle, uv).g; #ifdef SRGBBindlessFix color.xyz = pow(color.xyz, vec3(2.2)); #endif @@ -24,8 +27,8 @@ void main(void) #else vec4 color = texture(Albedo, uv); vec4 detail = texture(Detail, uv_bis); + float specmap = texture(SpecMap, uv).g; #endif color *= detail; - vec3 LightFactor = getLightFactor(1. - color.a); - FragColor = vec4(color.xyz * LightFactor, 1.); + FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap), 1.); } diff --git a/data/shaders/instanced_grass_pass2.frag b/data/shaders/instanced_grass_pass2.frag index b297a4c88..0bd7f0dbe 100644 --- a/data/shaders/instanced_grass_pass2.frag +++ b/data/shaders/instanced_grass_pass2.frag @@ -2,6 +2,7 @@ layout(bindless_sampler) uniform sampler2D dtex; #else uniform sampler2D Albedo; +uniform sampler2D SpecMap; uniform sampler2D dtex; #endif @@ -9,15 +10,28 @@ uniform vec3 SunDir; #ifdef GL_ARB_bindless_texture flat in sampler2D handle; +flat in sampler2D secondhandle; #endif in vec3 nor; in vec2 uv; out vec4 FragColor; -vec3 getLightFactor(float specMapValue); +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue); void main(void) { +#ifdef GL_ARB_bindless_texture + vec4 color = texture(handle, uv); + float specmap = texture(secondhandle, uv).g; +#ifdef SRGBBindlessFix + color.xyz = pow(color.xyz, vec3(2.2)); +#endif +#else + vec4 color = texture(Albedo, uv); + float specmap = texture(SpecMap, uv).g; +#endif + if (color.a < 0.5) discard; + vec2 texc = gl_FragCoord.xy / screen; float z = texture(dtex, texc).x; @@ -33,15 +47,7 @@ void main(void) float fLdotNBack = max(0., - dot(nor, SunDir) * 0.6 + 0.4); float scattering = mix(fPowEdotL, fLdotNBack, .5); -#ifdef GL_ARB_bindless_texture - vec4 color = texture(handle, uv); -#ifdef SRGBBindlessFix - color.xyz = pow(color.xyz, vec3(2.2)); -#endif -#else - vec4 color = texture(Albedo, uv); -#endif - if (color.a < 0.5) discard; - vec3 LightFactor = (scattering * 0.3) + getLightFactor(1.); - FragColor = vec4(color.xyz * LightFactor, 1.); + + vec3 LightFactor = color.xyz * (scattering * 0.3) + getLightFactor(color.xyz, vec3(1.), specmap); + FragColor = vec4(LightFactor, 1.); } diff --git a/data/shaders/instanced_object_pass2.frag b/data/shaders/instanced_object_pass2.frag index 76176ba37..c260d7aab 100644 --- a/data/shaders/instanced_object_pass2.frag +++ b/data/shaders/instanced_object_pass2.frag @@ -1,27 +1,30 @@ #ifndef GL_ARB_bindless_texture uniform sampler2D Albedo; +uniform sampler2D SpecMap; #endif #ifdef GL_ARB_bindless_texture flat in sampler2D handle; +flat in sampler2D secondhandle; #endif in vec2 uv; in vec4 color; out vec4 FragColor; -vec3 getLightFactor(float specMapValue); +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue); void main(void) { #ifdef GL_ARB_bindless_texture vec4 col = texture(handle, uv); + float specmap = texture(secondhandle, uv).g; #ifdef SRGBBindlessFix col.xyz = pow(col.xyz, vec3(2.2)); #endif #else vec4 col = texture(Albedo, uv); + float specmap = texture(SpecMap, uv).g; #endif col.xyz *= pow(color.xyz, vec3(2.2)); - vec3 LightFactor = getLightFactor(1.); - FragColor = vec4(col.xyz * LightFactor, 1.); + FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap), 1.); } diff --git a/data/shaders/instanced_objectpass_spheremap.frag b/data/shaders/instanced_objectpass_spheremap.frag index 5365dd7ef..21414ee31 100644 --- a/data/shaders/instanced_objectpass_spheremap.frag +++ b/data/shaders/instanced_objectpass_spheremap.frag @@ -12,7 +12,7 @@ out vec4 FragColor; vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix); -vec3 getLightFactor(float specMapValue); +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue); void main() { vec3 texc = gl_FragCoord.xyz / vec3(screen, 1.); @@ -29,7 +29,6 @@ void main() { #else vec4 detail0 = texture(tex, r.xy / m + .5); #endif - vec3 LightFactor = getLightFactor(1.); - FragColor = vec4(detail0.xyz * LightFactor, 1.); + FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 0.), 1.); } diff --git a/data/shaders/instanced_objectref_pass2.frag b/data/shaders/instanced_objectref_pass2.frag index 201f610a1..41f3dc34f 100644 --- a/data/shaders/instanced_objectref_pass2.frag +++ b/data/shaders/instanced_objectref_pass2.frag @@ -1,28 +1,31 @@ #ifndef GL_ARB_bindless_texture uniform sampler2D Albedo; +uniform sampler2D SpecMap; #endif #ifdef GL_ARB_bindless_texture flat in sampler2D handle; +flat in sampler2D secondhandle; #endif in vec2 uv; in vec4 color; out vec4 FragColor; -vec3 getLightFactor(float specMapValue); +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue); void main(void) { #ifdef GL_ARB_bindless_texture vec4 col = texture(handle, uv); + float specmap = texture(secondhandle, uv).g; #ifdef SRGBBindlessFix col.xyz = pow(col.xyz, vec3(2.2)); #endif #else vec4 col = texture(Albedo, uv); + float specmap = texture(SpecMap, uv).g; #endif col.xyz *= pow(color.xyz, vec3(2.2)); if (col.a * color.a < 0.5) discard; - vec3 LightFactor = getLightFactor(1.); - FragColor = vec4(col.xyz * LightFactor, 1.); + FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap), 1.); } diff --git a/data/shaders/object_pass2.frag b/data/shaders/object_pass2.frag index 047f0a192..ba984f87d 100644 --- a/data/shaders/object_pass2.frag +++ b/data/shaders/object_pass2.frag @@ -1,14 +1,16 @@ #ifdef GL_ARB_bindless_texture layout(bindless_sampler) uniform sampler2D Albedo; +layout(bindless_sampler) uniform sampler2D SpecMap; #else uniform sampler2D Albedo; +uniform sampler2D SpecMap; #endif in vec2 uv; in vec4 color; out vec4 FragColor; -vec3 getLightFactor(float specMapValue); +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue); void main(void) { @@ -21,6 +23,6 @@ void main(void) vec4 col = texture(Albedo, uv); #endif col.xyz *= pow(color.xyz, vec3(2.2)); - vec3 LightFactor = getLightFactor(1.); - FragColor = vec4(col.xyz * LightFactor, 1.); + float specmap = texture(SpecMap, uv).g; + FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap), 1.); } diff --git a/data/shaders/objectpass_spheremap.frag b/data/shaders/objectpass_spheremap.frag index 8e4e0f4fc..e5ed033d1 100644 --- a/data/shaders/objectpass_spheremap.frag +++ b/data/shaders/objectpass_spheremap.frag @@ -15,7 +15,7 @@ varying vec3 nor; #endif vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix); -vec3 getLightFactor(float specMapValue); +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue); void main() { vec3 texc = gl_FragCoord.xyz / vec3(screen, 1.); @@ -30,7 +30,6 @@ void main() { detail0.xyz = pow(detail0.xyz, vec3(2.2)); #endif #endif - vec3 LightFactor = getLightFactor(1.); - FragColor = vec4(detail0.xyz * LightFactor, 1.); + FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 0.), 1.); } diff --git a/data/shaders/objectref_pass2.frag b/data/shaders/objectref_pass2.frag index 13ff676f8..a7fd08dca 100644 --- a/data/shaders/objectref_pass2.frag +++ b/data/shaders/objectref_pass2.frag @@ -1,14 +1,16 @@ #ifdef GL_ARB_bindless_texture layout(bindless_sampler) uniform sampler2D Albedo; +layout(bindless_sampler) uniform sampler2D SpecMap; #else uniform sampler2D Albedo; +uniform sampler2D SpecMap; #endif in vec2 uv; in vec4 color; out vec4 FragColor; -vec3 getLightFactor(float specMapValue); +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue); void main(void) { @@ -20,6 +22,6 @@ void main(void) #endif col.xyz *= pow(color.xyz, vec3(2.2)); if (col.a * color.a < 0.5) discard; - vec3 LightFactor = getLightFactor(1.); - FragColor = vec4(col.xyz * LightFactor, 1.); + float specmap = texture(SpecMap, uv).g; + FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap), 1.); } diff --git a/data/shaders/splatting.frag b/data/shaders/splatting.frag index d302908d2..acc6fabc3 100644 --- a/data/shaders/splatting.frag +++ b/data/shaders/splatting.frag @@ -22,7 +22,7 @@ varying vec2 uv_bis; #define FragColor gl_FragColor #endif -vec3 getLightFactor(float specMapValue); +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue); void main() { // Splatting part @@ -46,6 +46,5 @@ void main() { splatting.b * detail2 + max(0., (1.0 - splatting.r - splatting.g - splatting.b)) * detail3; - vec3 LightFactor = getLightFactor(1.); - FragColor = vec4(splatted.xyz * LightFactor, 1.); + FragColor = vec4(getLightFactor(splatted.xyz, vec3(1.), 0.), 1.); } diff --git a/data/shaders/utils/getLightFactor.frag b/data/shaders/utils/getLightFactor.frag index 9bf4cdf58..7d974d56d 100644 --- a/data/shaders/utils/getLightFactor.frag +++ b/data/shaders/utils/getLightFactor.frag @@ -8,12 +8,12 @@ uniform sampler2D SpecularMap; uniform sampler2D SSAO; #endif -vec3 getLightFactor(float specMapValue) +vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue) { vec2 tc = gl_FragCoord.xy / screen; vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz; vec3 SpecularComponent = texture(SpecularMap, tc).xyz; float ao = texture(SSAO, tc).x; - vec3 tmp = DiffuseComponent + SpecularComponent * specMapValue; + vec3 tmp = diffuseMatColor * DiffuseComponent * (1. - specMapValue) + specularMatColor * SpecularComponent * specMapValue; return tmp * ao; } \ No newline at end of file diff --git a/lib/irrlicht/source/Irrlicht/CGUIButton.cpp b/lib/irrlicht/source/Irrlicht/CGUIButton.cpp index d4e6d9a91..74c335a35 100644 --- a/lib/irrlicht/source/Irrlicht/CGUIButton.cpp +++ b/lib/irrlicht/source/Irrlicht/CGUIButton.cpp @@ -277,7 +277,7 @@ void CGUIButton::draw() pos.X += skin->getSize(EGDS_BUTTON_PRESSED_IMAGE_OFFSET_X); pos.Y += skin->getSize(EGDS_BUTTON_PRESSED_IMAGE_OFFSET_Y); } - driver->draw2DImage(PressedImage, + skin->draw2DImage(PressedImage, ScaleImage? AbsoluteRect : core::recti(pos, PressedImageRect.getSize()), PressedImageRect, &AbsoluteClippingRect, diff --git a/lib/irrlicht/source/Irrlicht/CGUIImage.cpp b/lib/irrlicht/source/Irrlicht/CGUIImage.cpp index 17d30e0ec..184a6e5cc 100644 --- a/lib/irrlicht/source/Irrlicht/CGUIImage.cpp +++ b/lib/irrlicht/source/Irrlicht/CGUIImage.cpp @@ -78,20 +78,20 @@ void CGUIImage::draw() if (Texture) { - if (ScaleImage) - { + //if (ScaleImage) + //{ const video::SColor Colors[] = {Color,Color,Color,Color}; - driver->draw2DImage(Texture, AbsoluteRect, + skin->draw2DImage(Texture, AbsoluteRect, core::rect(core::position2d(0,0), core::dimension2di(Texture->getOriginalSize())), &AbsoluteClippingRect, Colors, UseAlphaChannel); - } - else - { - driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner, - core::rect(core::position2d(0,0), core::dimension2di(Texture->getOriginalSize())), - &AbsoluteClippingRect, Color, UseAlphaChannel); - } + //} + //else + //{ + // driver->draw2DImage(Texture, AbsoluteRect.UpperLeftCorner, + // core::rect(core::position2d(0,0), core::dimension2di(Texture->getOriginalSize())), + // &AbsoluteClippingRect, Color, UseAlphaChannel); + //} } else { diff --git a/src/config/hardware_stats.cpp b/src/config/hardware_stats.cpp index 0770c2fe2..dd784e10c 100644 --- a/src/config/hardware_stats.cpp +++ b/src/config/hardware_stats.cpp @@ -23,15 +23,26 @@ #include "graphics/irr_driver.hpp" #include "online/http_request.hpp" #include "utils/random_generator.hpp" -#include "utils/string_utils.hpp" #ifdef __APPLE__ # include #endif +#include +#include +#include +#include + + namespace HardwareStats { + namespace Private + { + /** Stores the OS version, e.g. "Windows 7", or "Fedora 21". */ + static std::string m_os_version; + } // namespace Private + using namespace Private; // ---------------------------------------------------------------------------- /** Returns the amount of RAM in MB. @@ -102,6 +113,105 @@ int getNumProcessors() return 0; } // getNumProcessors +// ---------------------------------------------------------------------------- +/** Tries opening and parsing the specified release file in /etc to find + * information about the distro used. + * \param filename Full path of the file to open. + * \return True if file could be read and valid information was paresed, + * false otherwise. + */ +bool readEtcReleaseFile(const std::string &filename) +{ + std::ifstream in(filename); + std::string s, distro, version; + int bits = 0; + while( (distro.empty() || version.empty()) && + std::getline(in, s) ) + { + std::vector l = StringUtils::split(s, '='); + if(l.size()==0) continue; + if (l[0]=="NAME" ) distro = l[1]; + else if(l[0]=="VERSION_ID") version = l[1]; + } + if(!distro.empty() && !version.empty()) + { + m_os_version = distro + " " + version; + return true; + } + return false; +} // readEtcReleaseFile + +// ---------------------------------------------------------------------------- +/** Identify more details about the OS, e.g. on linux which distro + * and which verison; on windows the version number. + * \param json Json data structure to store the os info in. + */ +void determineOSVersion() +{ + std::string version, distro; + +#ifdef __linux__ + // First try the standard /etc/os-release. Then check for older versions + // e.g. /etc/fedora-release, /etc/SuSE-release, /etc/redhat-release + if(readEtcReleaseFile("/etc/os-release")) return; + + std::set file_list; + file_manager->listFiles(file_list, "./", true); + for(std::set::iterator i = file_list.begin(); + i != file_list.end(); i++) + { + // Only try reading /etc/*-release files + if(StringUtils::hasSuffix(*i, "-release")) + if (readEtcReleaseFile(*i)) return; + } +#endif +#ifdef WIN32 + // (C) 2014 by Wildfire Games (0 A.D.), ported by Joerg Henrichs. + + HKEY hKey; + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, + "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, + KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS) + { + m_os_version = "windows-unknown"; + return; + } + char windows_version_string[20]; + DWORD size = sizeof(windows_version_string); + RegQueryValueEx(hKey, "CurrentVersion", 0, 0, (LPBYTE)windows_version_string, &size); + unsigned major = 0, minor = 0; + const int ret = sscanf_s(windows_version_string, "%u.%u", &major, &minor); + int windows_version = (major << 8) | minor; + RegCloseKey(hKey); + + switch(windows_version) + { + case 0x0500: m_os_version="Windows 2000"; break; + case 0x0501: m_os_version="Windows XP"; break; + case 0x0502: m_os_version="Windows XP64"; break; + case 0x0600: m_os_version="Windows Vista"; break; + case 0x0601: m_os_version="Windows 7"; break; + case 0x0602: m_os_version="Windows 8"; break; + default: { + m_os_version = StringUtils::insertValues("Windows %d", + windows_version); + break; + } + } // switch + +#endif +} // determineOSVersion + +// ---------------------------------------------------------------------------- +/** Returns the OS version, e.g.: "Windows 7", or "Fedora 21". + */ +const std::string& getOSVersion() +{ + if(m_os_version.empty()) + determineOSVersion(); + return m_os_version; +} // getOSVersion + // ---------------------------------------------------------------------------- /** If the configuration of this installation has not been reported for the * current version, collect the hardware statistics and send it to STK's @@ -144,6 +254,8 @@ void reportHardwareStats() json.add("build_debug", 1); #endif + json.add("os_version", getOSVersion()); + unsigned int ogl_version = irr_driver->getGLSLVersion(); unsigned int major = ogl_version/100; unsigned int minor = ogl_version - 100*major; @@ -195,7 +307,7 @@ void reportHardwareStats() int m_version; public: HWReportRequest(int version) : Online::HTTPRequest(/*manage memory*/true, 1) - ,m_version(version) + , m_version(version) {} // -------------------------------------------------------------------- /** Callback after the request has been executed. diff --git a/src/config/hardware_stats.hpp b/src/config/hardware_stats.hpp index f49f73ce5..4c5ef321f 100644 --- a/src/config/hardware_stats.hpp +++ b/src/config/hardware_stats.hpp @@ -25,11 +25,14 @@ #include "utils/no_copy.hpp" #include "utils/string_utils.hpp" + namespace HardwareStats { + /** A class to manage json data. */ class Json : public NoCopy { private: + /** The accumulated json data. */ std::string m_data; public: /** Constructor. */ @@ -78,6 +81,7 @@ namespace HardwareStats // ======================================================================== void reportHardwareStats(); + const std::string& getOSVersion(); }; // HardwareStats #endif diff --git a/src/graphics/lod_node.cpp b/src/graphics/lod_node.cpp index 1fea813a6..31ab6d731 100644 --- a/src/graphics/lod_node.cpp +++ b/src/graphics/lod_node.cpp @@ -80,7 +80,11 @@ int LODNode::getLevel() if (camera == NULL) return (int)m_detail.size() - 1; AbstractKart* kart = camera->getKart(); - const Vec3 &pos = kart->getFrontXYZ(); + // use kart position and not camera position when a kart is available, + // because for some effects the camera will be moved to various locations + // (for instance shadows), so using camera position for LOD may result + // in objects being culled when they shouldn't + const Vec3 &pos = (kart != NULL ? kart->getFrontXYZ() : camera->getCameraSceneNode()->getAbsolutePosition()); const int dist = (int)((m_nodes[0]->getAbsolutePosition()).getDistanceFromSQ(pos.toIrrVector() )); diff --git a/src/graphics/material.cpp b/src/graphics/material.cpp index d633a8a3c..b9244c1a6 100644 --- a/src/graphics/material.cpp +++ b/src/graphics/material.cpp @@ -57,8 +57,7 @@ Material::Material(const XMLNode *node, bool deprecated) m_shader_type = SHADERTYPE_SOLID; m_deprecated = deprecated; - node->get("name", &m_texname); - + node->get("name", &m_texname); if (m_texname=="") { throw std::runtime_error("[Material] No texture name specified " @@ -66,6 +65,7 @@ Material::Material(const XMLNode *node, bool deprecated) } init(); + node->get("lazy-load", &m_lazy_load); bool b = false; node->get("clampu", &b); if (b) m_clamp_tex |= UCLAMP; //blender 2.4 style @@ -412,10 +412,10 @@ Material::Material(const std::string& fname, bool is_full_path, */ void Material::init() { + m_lazy_load = false; + m_texture = NULL; m_clamp_tex = 0; m_shader_type = SHADERTYPE_SOLID; - //m_lightmap = false; - //m_adjust_image = ADJ_NONE; m_backface_culling = true; m_high_tire_adhesion = false; m_below_surface = false; @@ -455,6 +455,9 @@ void Material::init() //----------------------------------------------------------------------------- void Material::install(bool is_full_path, bool complain_if_not_found) { + // Don't load a texture that is lazily loaded. + if(m_lazy_load) return; + const std::string &full_path = is_full_path ? m_texname : file_manager->searchTexture(m_texname); diff --git a/src/graphics/material.hpp b/src/graphics/material.hpp index 4e95e648b..934c3c433 100644 --- a/src/graphics/material.hpp +++ b/src/graphics/material.hpp @@ -22,13 +22,11 @@ #include "utils/no_copy.hpp" +#include #include #include #include -#include - - namespace irr { namespace video { class ITexture; class SMaterial; } @@ -81,9 +79,18 @@ public: private: + /** Pointer to the texture. */ video::ITexture *m_texture; - //unsigned int m_index; + + /** Name of the texture. */ std::string m_texname; + + /** If true, the texture will not automatically be loaded and bound + * at load time, it must be loaded elsewhere. This is used to store + * material settings for font textures, without loading fonts for + * languages that might not be needed at all. */ + bool m_lazy_load; + /** Name of a special sfx to play when a kart is on this terrain, or * "" if no special sfx exists. */ std::string m_sfx_name; @@ -114,7 +121,7 @@ private: /** If a kart is rescued when driving on this surface. */ bool m_drive_reset; - /** True if this is a texture that will start the jump animatoin when + /** True if this is a texture that will start the jump animation when * leaving it and being in the air. */ bool m_is_jump_texture; @@ -244,27 +251,45 @@ public: void setSFXSpeed(SFXBase *sfx, float speed, bool should_be_paused) const; void setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* mb); - void adjustForFog(scene::ISceneNode* parent, video::SMaterial *m, bool use_fog) const; + void adjustForFog(scene::ISceneNode* parent, video::SMaterial *m, + bool use_fog) const; + void onMadeVisible(scene::IMeshBuffer* who); + void onHidden(scene::IMeshBuffer* who); + void isInitiallyHidden(scene::IMeshBuffer* who); /** Returns the ITexture associated with this material. */ - video::ITexture *getTexture() const { return m_texture; } + video::ITexture *getTexture() const + { + // Note that atm lazy load means that the textures are not loaded + // via the material. So getTexture should only get called for non + // lazily loaded textures (used atm for font textures. + assert(!m_lazy_load); + return m_texture; + } // getTexture + // ------------------------------------------------------------------------ bool isIgnore () const { return m_ignore; } + // ------------------------------------------------------------------------ /** Returns true if this material is a zipper. */ bool isZipper () const { return m_zipper; } + // ------------------------------------------------------------------------ /** Returns if this material should trigger a rescue if a kart * is driving on it. */ bool isDriveReset () const { return m_drive_reset; } + // ------------------------------------------------------------------------ /** Returns if this material should trigger a rescue if a kart * crashes against it. */ CollisionReaction getCollisionReaction() const { return m_collision_reaction; } + // ------------------------------------------------------------------------ std::string getCrashResetParticles() const { return m_collision_particles; } + // ------------------------------------------------------------------------ bool highTireAdhesion () const { return m_high_tire_adhesion; } + // ------------------------------------------------------------------------ const std::string& getTexFname () const { return m_texname; } - //int getIndex () const { return m_index; } + // ------------------------------------------------------------------------ bool isTransparent () const { return m_shader_type == SHADERTYPE_ADDITIVE || @@ -272,12 +297,6 @@ public: m_shader_type == SHADERTYPE_ALPHA_TEST; } - // ------------------------------------------------------------------------ - /** Returns true if this materials need pre-multiply of alpha. */ - //bool isPreMul() const {return m_adjust_image==ADJ_PREMUL; } - // ------------------------------------------------------------------------ - /** Returns true if this materials need pre-division of alpha. */ - //bool isPreDiv() const {return m_adjust_image==ADJ_DIV; } // ------------------------------------------------------------------------ /** Returns the fraction of maximum speed on this material. */ float getMaxSpeedFraction() const { return m_max_speed_fraction; } @@ -300,17 +319,20 @@ public: // ------------------------------------------------------------------------ /** Returns the name of a special sfx to play while a kart is on this * terrain. The string will be "" if no special sfx exists. */ - const std::string & - getSFXName () const { return m_sfx_name; } + const std::string &getSFXName() const { return m_sfx_name; } + // ------------------------------------------------------------------------ + /** Returns if fog is enabled. */ bool isFogEnabled() const { return m_fog; } - /** - * \brief Get the kind of particles that are to be used on this material, in the given conditions - * \return The particles to use, or NULL if none - */ - const ParticleKind* getParticlesWhen(ParticleConditions cond) const { return m_particles_effects[cond]; } - + // ------------------------------------------------------------------------ + /** \brief Get the kind of particles that are to be used on this material, + * in the given conditions. + * \return The particles to use, or NULL if none. */ + const ParticleKind* getParticlesWhen(ParticleConditions cond) const + { + return m_particles_effects[cond]; + } // getParticlesWhen // ------------------------------------------------------------------------ /** Returns true if a kart falling over this kind of material triggers * the special falling camera. */ @@ -346,9 +368,6 @@ public: // ------------------------------------------------------------------------ ShaderType getShaderType() const { return m_shader_type; } // ------------------------------------------------------------------------ - void onMadeVisible(scene::IMeshBuffer* who); - void onHidden(scene::IMeshBuffer* who); - void isInitiallyHidden(scene::IMeshBuffer* who); } ; diff --git a/src/graphics/post_processing.cpp b/src/graphics/post_processing.cpp index dee6b68a4..3ac843d14 100644 --- a/src/graphics/post_processing.cpp +++ b/src/graphics/post_processing.cpp @@ -221,19 +221,19 @@ void renderBloom(GLuint in) DrawFullScreenEffect(); } -void PostProcessing::renderDiffuseEnvMap(const float *bSHCoeff, const float *gSHCoeff, const float *rSHCoeff) +void PostProcessing::renderEnvMap(const float *bSHCoeff, const float *gSHCoeff, const float *rSHCoeff, GLuint skybox) { glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendEquation(GL_FUNC_ADD); glBlendFunc(GL_ONE, GL_ONE); - glUseProgram(FullScreenShader::DiffuseEnvMapShader::getInstance()->Program); + glUseProgram(FullScreenShader::EnvMapShader::getInstance()->Program); glBindVertexArray(SharedObject::FullScreenQuadVAO); - FullScreenShader::DiffuseEnvMapShader::getInstance()->SetTextureUnits(createVector(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH))); + FullScreenShader::EnvMapShader::getInstance()->SetTextureUnits(createVector(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture(), skybox)); core::matrix4 TVM = irr_driver->getViewMatrix().getTransposed(); - FullScreenShader::DiffuseEnvMapShader::getInstance()->setUniforms(TVM, std::vector(bSHCoeff, bSHCoeff + 9), std::vector(gSHCoeff, gSHCoeff + 9), std::vector(rSHCoeff, rSHCoeff + 9)); + FullScreenShader::EnvMapShader::getInstance()->setUniforms(TVM, std::vector(bSHCoeff, bSHCoeff + 9), std::vector(gSHCoeff, gSHCoeff + 9), std::vector(rSHCoeff, rSHCoeff + 9)); glDrawArrays(GL_TRIANGLES, 0, 3); glBindVertexArray(0); @@ -662,7 +662,8 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode, boo // Blend glEnable(GL_BLEND); - glBlendFunc(GL_ONE, GL_ONE); + glBlendColor(0., 0., 0., track->getGodRaysOpacity()); + glBlendFunc(GL_CONSTANT_ALPHA, GL_ONE); glBlendEquation(GL_FUNC_ADD); in_fbo->Bind(); diff --git a/src/graphics/post_processing.hpp b/src/graphics/post_processing.hpp index a6b990432..e09a66451 100644 --- a/src/graphics/post_processing.hpp +++ b/src/graphics/post_processing.hpp @@ -81,7 +81,7 @@ public: void renderFog(); void renderSSAO(); - void renderDiffuseEnvMap(const float *bSHCoeff, const float *gSHCoeff, const float *rSHCoeff); + void renderEnvMap(const float *bSHCoeff, const float *gSHCoeff, const float *rSHCoeff, unsigned skycubemap); void renderRHDebug(unsigned SHR, unsigned SHG, unsigned SHB, const core::matrix4 &rh_matrix, const core::vector3df &rh_extend); void renderGI(const core::matrix4 &RHMatrix, const core::vector3df &rh_extend, unsigned shr, unsigned shg, unsigned shb); diff --git a/src/graphics/render_geometry.cpp b/src/graphics/render_geometry.cpp index b0421af7c..613c9c1e5 100644 --- a/src/graphics/render_geometry.cpp +++ b/src/graphics/render_geometry.cpp @@ -75,7 +75,7 @@ struct DefaultMaterial }; const std::vector DefaultMaterial::FirstPassTextures = { 1 }; -const std::vector DefaultMaterial::SecondPassTextures = { 0 }; +const std::vector DefaultMaterial::SecondPassTextures = { 0, 1 }; struct AlphaRef { @@ -93,7 +93,7 @@ struct AlphaRef }; const std::vector AlphaRef::FirstPassTextures = { 0, 1 }; -const std::vector AlphaRef::SecondPassTextures = { 0 }; +const std::vector AlphaRef::SecondPassTextures = { 0, 1 }; struct SphereMap { @@ -147,7 +147,7 @@ struct GrassMat }; const std::vector GrassMat::FirstPassTextures = { 0 }; -const std::vector GrassMat::SecondPassTextures = { 0 }; +const std::vector GrassMat::SecondPassTextures = { 0, 1 }; struct NormalMat { @@ -165,7 +165,7 @@ struct NormalMat }; const std::vector NormalMat::FirstPassTextures = { 2, 1 }; -const std::vector NormalMat::SecondPassTextures = { 0 }; +const std::vector NormalMat::SecondPassTextures = { 0, 1 }; struct DetailMat { @@ -183,7 +183,7 @@ struct DetailMat }; const std::vector DetailMat::FirstPassTextures = { 1 }; -const std::vector DetailMat::SecondPassTextures = { 0, 2 }; +const std::vector DetailMat::SecondPassTextures = { 0, 2, 1 }; struct SplattingMat { @@ -531,15 +531,15 @@ void IrrDriver::renderSolidSecondPass() if (UserConfigParams::m_azdo) { - multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0)); - multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0)); + multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0)); + multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0)); multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0)); multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0)); SunLightProvider * const cb = (SunLightProvider *)irr_driver->getCallback(ES_SUNLIGHT); - multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, DepthHandle, 0), windDir, cb->getPosition()); + multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, DepthHandle, 0, 0), windDir, cb->getPosition()); - multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0)); - multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0)); + multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0)); + multidraw2ndPass(createVector(DiffuseHandle, SpecularHandle, SSAOHandle, 0, 0, 0)); } else if (irr_driver->hasARB_draw_indirect()) { diff --git a/src/graphics/render_lighting.cpp b/src/graphics/render_lighting.cpp index 71b569abe..f1e3d08dc 100644 --- a/src/graphics/render_lighting.cpp +++ b/src/graphics/render_lighting.cpp @@ -152,13 +152,13 @@ void IrrDriver::renderLights(unsigned pointlightcount, bool hasShadow) m_post_processing->renderGI(rh_matrix, rh_extend, m_rtts->getRH().getRTT()[0], m_rtts->getRH().getRTT()[1], m_rtts->getRH().getRTT()[2]); } + m_rtts->getFBO(FBO_COMBINED_DIFFUSE_SPECULAR).Bind(); + { ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_ENVMAP)); - m_post_processing->renderDiffuseEnvMap(blueSHCoeff, greenSHCoeff, redSHCoeff); + m_post_processing->renderEnvMap(blueSHCoeff, greenSHCoeff, redSHCoeff, SkyboxCubeMap); } - m_rtts->getFBO(FBO_COMBINED_DIFFUSE_SPECULAR).Bind(); - // Render sunlight if and only if track supports shadow if (!World::getWorld() || World::getWorld()->getTrack()->hasShadows()) { diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index d18c1900a..4cdb4b051 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -854,7 +854,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass2.frag").c_str()); AssignUniforms("ModelMatrix", "TextureMatrix"); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo"); + AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap"); } InstancedObjectPass2Shader::InstancedObjectPass2Shader() @@ -865,7 +865,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/instanced_object_pass2.frag").c_str()); AssignUniforms(); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo"); + AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap"); } InstancedObjectRefPass2Shader::InstancedObjectRefPass2Shader() @@ -876,7 +876,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/instanced_objectref_pass2.frag").c_str()); AssignUniforms(); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo"); + AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap"); } DetailledObjectPass2Shader::DetailledObjectPass2Shader() @@ -886,7 +886,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/detailledobject_pass2.frag").c_str()); AssignUniforms("ModelMatrix"); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Detail"); + AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Detail", 5, "SpecMap"); } InstancedDetailledObjectPass2Shader::InstancedDetailledObjectPass2Shader() @@ -897,7 +897,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/instanced_detailledobject_pass2.frag").c_str()); AssignUniforms(); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Detail"); + AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "Detail", 5, "SpecMap"); } ObjectUnlitShader::ObjectUnlitShader() @@ -926,7 +926,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass2.frag").c_str()); AssignUniforms("ModelMatrix", "TextureMatrix"); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo"); + AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap"); } GrassPass2Shader::GrassPass2Shader() @@ -936,7 +936,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/grass_pass2.frag").c_str()); AssignUniforms("ModelMatrix", "windDir"); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo"); + AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "Albedo", 4, "SpecMap"); } InstancedGrassPass2Shader::InstancedGrassPass2Shader() @@ -947,7 +947,7 @@ namespace MeshShader GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/instanced_grass_pass2.frag").c_str()); AssignUniforms("windDir", "SunDir"); - AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "dtex", 4, "Albedo"); + AssignSamplerNames(Program, 0, "DiffuseMap", 1, "SpecularMap", 2, "SSAO", 3, "dtex", 4, "Albedo", 5, "SpecMap"); } SphereMapShader::SphereMapShader() @@ -1455,14 +1455,15 @@ namespace FullScreenShader AssignUniforms("direction", "col"); } - DiffuseEnvMapShader::DiffuseEnvMapShader() + EnvMapShader::EnvMapShader() { Program = LoadProgram(OBJECT, GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/decodeNormal.frag").c_str(), + GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getPosFromUVDepth.frag").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/diffuseenvmap.frag").c_str()); AssignUniforms("TransposeViewMatrix", "blueLmn[0]", "greenLmn[0]", "redLmn[0]"); - AssignSamplerNames(Program, 0, "ntex"); + AssignSamplerNames(Program, 0, "ntex", 1, "dtex", 2, "tex"); } ShadowedSunLightShader::ShadowedSunLightShader() diff --git a/src/graphics/shaders.hpp b/src/graphics/shaders.hpp index 9a0214731..0c7e42133 100644 --- a/src/graphics/shaders.hpp +++ b/src/graphics/shaders.hpp @@ -101,31 +101,31 @@ public: InstancedNormalMapShader(); }; -class ObjectPass2Shader : public ShaderHelperSingleton, public TextureRead +class ObjectPass2Shader : public ShaderHelperSingleton, public TextureRead { public: ObjectPass2Shader(); }; -class InstancedObjectPass2Shader : public ShaderHelperSingleton, public TextureRead +class InstancedObjectPass2Shader : public ShaderHelperSingleton, public TextureRead { public: InstancedObjectPass2Shader(); }; -class InstancedObjectRefPass2Shader : public ShaderHelperSingleton, public TextureRead +class InstancedObjectRefPass2Shader : public ShaderHelperSingleton, public TextureRead { public: InstancedObjectRefPass2Shader(); }; -class DetailledObjectPass2Shader : public ShaderHelperSingleton, public TextureRead +class DetailledObjectPass2Shader : public ShaderHelperSingleton, public TextureRead { public: DetailledObjectPass2Shader(); }; -class InstancedDetailledObjectPass2Shader : public ShaderHelperSingleton, public TextureRead +class InstancedDetailledObjectPass2Shader : public ShaderHelperSingleton, public TextureRead { public: InstancedDetailledObjectPass2Shader(); @@ -143,19 +143,19 @@ public: InstancedObjectUnlitShader(); }; -class ObjectRefPass2Shader : public ShaderHelperSingleton, public TextureRead +class ObjectRefPass2Shader : public ShaderHelperSingleton, public TextureRead { public: ObjectRefPass2Shader(); }; -class GrassPass2Shader : public ShaderHelperSingleton, public TextureRead +class GrassPass2Shader : public ShaderHelperSingleton, public TextureRead { public: GrassPass2Shader(); }; -class InstancedGrassPass2Shader : public ShaderHelperSingleton, public TextureRead +class InstancedGrassPass2Shader : public ShaderHelperSingleton, public TextureRead { public: InstancedGrassPass2Shader(); @@ -395,10 +395,10 @@ public: SunLightShader(); }; -class DiffuseEnvMapShader : public ShaderHelperSingleton, std::vector, std::vector >, public TextureRead +class EnvMapShader : public ShaderHelperSingleton, std::vector, std::vector >, public TextureRead { public: - DiffuseEnvMapShader(); + EnvMapShader(); }; class ShadowedSunLightShader : public ShaderHelperSingleton, public TextureRead diff --git a/src/graphics/stkmeshscenenode.cpp b/src/graphics/stkmeshscenenode.cpp index b23973b25..c5cb8dfc5 100644 --- a/src/graphics/stkmeshscenenode.cpp +++ b/src/graphics/stkmeshscenenode.cpp @@ -325,7 +325,8 @@ void STKMeshSceneNode::render() irr_driver->getRenderTargetTexture(RTT_DIFFUSE), irr_driver->getRenderTargetTexture(RTT_SPECULAR), irr_driver->getRenderTargetTexture(RTT_HALF1_R), - getTextureGLuint(mesh.textures[0]))); + getTextureGLuint(mesh.textures[0]), + getTextureGLuint(mesh.textures[1]))); MeshShader::ObjectPass2Shader::getInstance()->setUniforms(AbsoluteTransformation, mesh.TextureMatrix); assert(mesh.vao); glBindVertexArray(mesh.vao); diff --git a/src/graphics/stkscenemanager.cpp b/src/graphics/stkscenemanager.cpp index a5326473f..2ff2e33b6 100644 --- a/src/graphics/stkscenemanager.cpp +++ b/src/graphics/stkscenemanager.cpp @@ -167,7 +167,7 @@ bool isBoxInFrontOfPlane(const core::plane3df &plane, const core::vector3df edge } static -bool isCulledPrecise(const scene::ICameraSceneNode *cam, const scene::ISceneNode *node, bool aera_check) +bool isCulledPrecise(const scene::ICameraSceneNode *cam, const scene::ISceneNode *node) { if (!node->getAutomaticCulling()) return false; @@ -183,10 +183,6 @@ bool isCulledPrecise(const scene::ICameraSceneNode *cam, const scene::ISceneNode for (s32 i = 0; i < scene::SViewFrustum::VF_PLANE_COUNT; ++i) if (isBoxInFrontOfPlane(frust.planes[i], edges)) return true; - - float ratio = cam->getProjectionMatrix().pointer()[0] * cam->getProjectionMatrix().pointer()[5]; - if (aera_check && node->getBoundingBox().getArea() * ratio < 1.) - return true; return false; } @@ -439,14 +435,14 @@ parseSceneManager(core::list List, std::vector(*I)) { - if (!isCulledPrecise(cam, *I, false)) + if (!isCulledPrecise(cam, *I)) ParticlesList::getInstance()->push_back(node); continue; } if (STKBillboard *node = dynamic_cast(*I)) { - if (!isCulledPrecise(cam, *I, false)) + if (!isCulledPrecise(cam, *I)) BillBoardList::getInstance()->push_back(node); continue; } @@ -506,12 +502,12 @@ void IrrDriver::PrepareDrawCalls(scene::ICameraSceneNode *camnode) for (int i = 0; i < (int)DeferredUpdate.size(); i++) { scene::ISceneNode *node = dynamic_cast(DeferredUpdate[i]); - DeferredUpdate[i]->setCulledForPlayerCam(isCulledPrecise(camnode, node, false)); - DeferredUpdate[i]->setCulledForRSMCam(isCulledPrecise(m_suncam, node, true)); - DeferredUpdate[i]->setCulledForShadowCam(0, isCulledPrecise(m_shadow_camnodes[0], node, true)); - DeferredUpdate[i]->setCulledForShadowCam(1, isCulledPrecise(m_shadow_camnodes[1], node, true)); - DeferredUpdate[i]->setCulledForShadowCam(2, isCulledPrecise(m_shadow_camnodes[2], node, true)); - DeferredUpdate[i]->setCulledForShadowCam(3, isCulledPrecise(m_shadow_camnodes[3], node, true)); + DeferredUpdate[i]->setCulledForPlayerCam(isCulledPrecise(camnode, node)); + DeferredUpdate[i]->setCulledForRSMCam(isCulledPrecise(m_suncam, node)); + DeferredUpdate[i]->setCulledForShadowCam(0, isCulledPrecise(m_shadow_camnodes[0], node)); + DeferredUpdate[i]->setCulledForShadowCam(1, isCulledPrecise(m_shadow_camnodes[1], node)); + DeferredUpdate[i]->setCulledForShadowCam(2, isCulledPrecise(m_shadow_camnodes[2], node)); + DeferredUpdate[i]->setCulledForShadowCam(3, isCulledPrecise(m_shadow_camnodes[3], node)); } // Add a 1 s timeout diff --git a/src/guiengine/message_queue.cpp b/src/guiengine/message_queue.cpp index 8d43ff227..c953d34e5 100755 --- a/src/guiengine/message_queue.cpp +++ b/src/guiengine/message_queue.cpp @@ -95,7 +95,7 @@ std::priority_queue, float g_current_display_time = -1.0f; /** How long the current message should be displaed. */ -float g_max_display_time = -1.0f; +float g_max_display_time = 5.0f; /** The label widget used to show the current message. */ SkinWidgetContainer *g_container = NULL; diff --git a/src/guiengine/widgets/dynamic_ribbon_widget.cpp b/src/guiengine/widgets/dynamic_ribbon_widget.cpp index 34fdf011a..a00b2762b 100644 --- a/src/guiengine/widgets/dynamic_ribbon_widget.cpp +++ b/src/guiengine/widgets/dynamic_ribbon_widget.cpp @@ -37,6 +37,7 @@ DynamicRibbonWidget::DynamicRibbonWidget(const bool combo, const bool multi_row) m_needed_cols = 0; m_col_amount = 0; m_previous_item_count = 0; + m_max_label_length = 0; m_multi_row = multi_row; m_combo = combo; m_has_label = false; @@ -1158,8 +1159,8 @@ float DynamicRibbonWidget::getFontScale(int icon_width) const irr::core::stringw DynamicRibbonWidget::getUserName(const irr::core::stringw& user_name) const { - if (user_name.size() < MAX_LABEL_LENGTH) + if (m_max_label_length == 0 || user_name.size() < m_max_label_length) return user_name; else - return (user_name.subString(0, MAX_LABEL_LENGTH - 3) + L"..."); + return (user_name.subString(0, m_max_label_length - 3) + L"..."); } diff --git a/src/guiengine/widgets/dynamic_ribbon_widget.hpp b/src/guiengine/widgets/dynamic_ribbon_widget.hpp index 96d31af11..b3cdd1396 100644 --- a/src/guiengine/widgets/dynamic_ribbon_widget.hpp +++ b/src/guiengine/widgets/dynamic_ribbon_widget.hpp @@ -187,7 +187,7 @@ namespace GUIEngine int m_max_label_width; /** Max length of a label, in characters */ - static const int MAX_LABEL_LENGTH = 30; + int m_max_label_length; public: @@ -298,6 +298,9 @@ namespace GUIEngine /** Set approximately how many items are expected to be in this ribbon; will help the layout * algorithm next time add() is called */ void setItemCountHint(int hint) { m_item_count_hint = hint; } + + /** Set max length of displayed text. */ + void setMaxLabelLength(int length) { m_max_label_length = length; } }; } diff --git a/src/guiengine/widgets/icon_button_widget.cpp b/src/guiengine/widgets/icon_button_widget.cpp index 4255895a0..66342ebfc 100644 --- a/src/guiengine/widgets/icon_button_widget.cpp +++ b/src/guiengine/widgets/icon_button_widget.cpp @@ -189,6 +189,9 @@ void IconButtonWidget::add() m_id = m_element->getID(); if (m_tab_stop) m_element->setTabOrder(m_id); m_element->setTabGroup(false); + + if (!m_is_visible) + m_element->setVisible(false); } // ----------------------------------------------------------------------------- diff --git a/src/guiengine/widgets/ribbon_widget.cpp b/src/guiengine/widgets/ribbon_widget.cpp index 2300dbf91..78e2b95d1 100644 --- a/src/guiengine/widgets/ribbon_widget.cpp +++ b/src/guiengine/widgets/ribbon_widget.cpp @@ -141,14 +141,8 @@ void RibbonWidget::add() total_needed_space += m_active_children[i].m_w; } - int free_w_space = m_w - total_needed_space; - //int biggest_y = 0; const int button_y = 10; - float global_zoom = 1; - - const int min_free_space = 50; - global_zoom = (float)m_w / (float)( m_w - free_w_space + min_free_space ); const int one_button_space = int(roundf((float)m_w / (float)subbuttons_amount)); @@ -320,22 +314,10 @@ void RibbonWidget::add() float image_h = (float)image->getSize().Height; float image_w = image_h*imageRatio; - - // scale to fit (FIXME: calculate the right value directly...) - float zoom = global_zoom; - - if (button_y + image_h*zoom + needed_space_under_button > m_h) - { - // scale down - while (button_y + image_h*zoom + - needed_space_under_button > m_h) zoom -= 0.01f; - } - else - { - // scale up - while (button_y + image_h*zoom + - needed_space_under_button < m_h) zoom += 0.01f; - } + float zoom = (float) (m_h - button_y - needed_space_under_button) / image_h; + float zoom_x = (float) one_button_space / image_w; + if(zoom_x < zoom) + zoom = zoom_x; // ---- add bitmap button part // backup and restore position in case the same object is added diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index ee2ab1ac6..aee0d8b7c 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -2546,8 +2546,9 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz, float lean_height = tan(fabsf(m_current_lean)) * getKartWidth()*0.5f; float heading = m_skidding->getVisualSkidRotation(); + float xx = fabsf(m_speed)* getKartProperties()->getDownwardImpulseFactor()*0.0006f; Vec3 center_shift = Vec3(0, m_skidding->getGraphicalJumpOffset() - + lean_height +m_graphical_y_offset, 0); + + lean_height +m_graphical_y_offset+xx, 0); center_shift = getTrans().getBasis() * center_shift; Moveable::updateGraphics(dt, center_shift, diff --git a/src/karts/kart_model.cpp b/src/karts/kart_model.cpp index 464acb111..b3bc16b4a 100644 --- a/src/karts/kart_model.cpp +++ b/src/karts/kart_model.cpp @@ -441,7 +441,6 @@ scene::ISceneNode* KartModel::attachModel(bool animated_models, bool always_anim obj.m_node = irr_driver->addAnimatedMesh(obj.m_model, node); obj.m_node->grab(); - obj.m_node->setAnimationStrength(0.0f); obj.m_node->setFrameLoop(m_animation_frame[AF_SPEED_WEIGHTED_START], m_animation_frame[AF_SPEED_WEIGHTED_END]); #ifdef DEBUG @@ -826,7 +825,6 @@ void KartModel::update(float dt, float rotation_dt, float steer, float speed) strength = speed * strength_factor; btClamp(strength, 0.0f, 1.0f); } - obj.m_node->setAnimationStrength(strength); // Animation speed const float speed_factor = GET_VALUE(obj, m_speed_factor); diff --git a/src/main.cpp b/src/main.cpp index 50e80db02..54bd8b79e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1206,7 +1206,14 @@ int main(int argc, char *argv[] ) // Get into menu mode initially. input_manager->setMode(InputManager::MENU); main_loop = new MainLoop(); - material_manager -> loadMaterial (); + material_manager->loadMaterial(); + + // Load the font textures - they are all lazily loaded + // so no need to push a texture search path. They will actually + // be loaded from ScalableFont. + material_manager->addSharedMaterial( + file_manager->getAsset(FileManager::FONT,"materials.xml")); + GUIEngine::addLoadingIcon( irr_driver->getTexture(FileManager::GUI, "options_video.png")); kart_properties_manager -> loadAllKarts (); diff --git a/src/modes/world.cpp b/src/modes/world.cpp index 65fc1a2d0..5637925f4 100644 --- a/src/modes/world.cpp +++ b/src/modes/world.cpp @@ -1229,7 +1229,7 @@ void World::escapePressed() bool World::isFogEnabled() const { - return m_track != NULL && m_track->isFogEnabled(); + return !m_force_disable_fog && (m_track != NULL && m_track->isFogEnabled()); } /* EOF */ diff --git a/src/modes/world.hpp b/src/modes/world.hpp index 4d34dbfa6..765f833e3 100644 --- a/src/modes/world.hpp +++ b/src/modes/world.hpp @@ -92,6 +92,7 @@ protected: RandomGenerator m_random; Physics* m_physics; + bool m_force_disable_fog; AbstractKart* m_fastest_kart; /** Number of eliminated karts. */ int m_eliminated_karts; @@ -332,6 +333,8 @@ public: { m_clear_color = color; } + /** Override track fog value to force disabled */ + void forceFogDisabled(bool v) { m_force_disable_fog = v; } // ------------------------------------------------------------------------ /** Override if you want to know when a kart presses fire */ virtual void onFirePressed(Controller* who) {} diff --git a/src/states_screens/tracks_screen.cpp b/src/states_screens/tracks_screen.cpp index 9e25c46d4..793834c54 100644 --- a/src/states_screens/tracks_screen.cpp +++ b/src/states_screens/tracks_screen.cpp @@ -171,6 +171,7 @@ void TracksScreen::init() // Reset GP list everytime (accounts for locking changes, etc.) gps_widget->clearItems(); + gps_widget->setMaxLabelLength(30); // Ensure that no GP and no track is NULL grand_prix_manager->checkConsistency(); diff --git a/src/states_screens/user_screen.cpp b/src/states_screens/user_screen.cpp index 5029a90ad..787d6726a 100644 --- a/src/states_screens/user_screen.cpp +++ b/src/states_screens/user_screen.cpp @@ -282,7 +282,7 @@ void BaseUserScreen::eventCallback(Widget* widget, else if (button == "cancel") { StateManager::get()->popMenu(); - onEscapePressed(); + StateManager::get()->escapePressed(); } else if (button == "recover") { diff --git a/src/tracks/quad_graph.cpp b/src/tracks/quad_graph.cpp index 0ce062ea0..a8198cdd1 100644 --- a/src/tracks/quad_graph.cpp +++ b/src/tracks/quad_graph.cpp @@ -983,6 +983,7 @@ void QuadGraph::makeMiniMap(const core::dimension2du &dimension, { const SColor oldClearColor = World::getWorld()->getClearColor(); World::getWorld()->setClearbackBufferColor(SColor(0, 255, 255, 255)); + World::getWorld()->forceFogDisabled(true); *oldRttMinimap = NULL; *newRttMinimap = NULL; @@ -1102,6 +1103,7 @@ void QuadGraph::makeMiniMap(const core::dimension2du &dimension, *oldRttMinimap = texture; *newRttMinimap = frame_buffer; World::getWorld()->setClearbackBufferColor(oldClearColor); + World::getWorld()->forceFogDisabled(false); } // makeMiniMap //-----------------------------------------------------------------------------