diff --git a/data/gfx/gfx_fallingLeaf_a.xml b/data/gfx/gfx_fallingLeaf_a.xml new file mode 100644 index 000000000..35f5215f4 --- /dev/null +++ b/data/gfx/gfx_fallingLeaf_a.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/models/materials.xml b/data/models/materials.xml index 82039a0dc..4a7f9bf9e 100644 --- a/data/models/materials.xml +++ b/data/models/materials.xml @@ -2,34 +2,22 @@ - - - - + + + + - + - - - + + + - - + + - - - - - - - - - - - - - + diff --git a/data/shaders/grass_pass2.frag b/data/shaders/grass_pass2.frag index ef1da358a..0ad58609a 100644 --- a/data/shaders/grass_pass2.frag +++ b/data/shaders/grass_pass2.frag @@ -29,6 +29,6 @@ void main(void) vec4 color = texture(Albedo, uv); if (color.a < 0.5) discard; - vec3 LightFactor = scattering + getLightFactor(1.); + vec3 LightFactor = (scattering * 0.3) + getLightFactor(1.); FragColor = vec4(color.xyz * LightFactor, 1.); } diff --git a/data/shaders/objectpass_spheremap.frag b/data/shaders/objectpass_spheremap.frag index 86f4c05b0..d8c35f4d1 100644 --- a/data/shaders/objectpass_spheremap.frag +++ b/data/shaders/objectpass_spheremap.frag @@ -5,6 +5,7 @@ uniform mat4 ViewMatrix; uniform mat4 ProjectionMatrix; uniform mat4 InverseViewMatrix; uniform mat4 InverseProjectionMatrix; +uniform vec2 screen; #else layout (std140) uniform MatrixesData { diff --git a/data/shaders/pointlight.frag b/data/shaders/pointlight.frag index a4d37c0bc..532aa115c 100644 --- a/data/shaders/pointlight.frag +++ b/data/shaders/pointlight.frag @@ -7,6 +7,7 @@ uniform mat4 ViewMatrix; uniform mat4 ProjectionMatrix; uniform mat4 InverseViewMatrix; uniform mat4 InverseProjectionMatrix; +uniform vec2 screen; #else layout (std140) uniform MatrixesData { diff --git a/data/shaders/sky.frag b/data/shaders/sky.frag index 7eec67e35..f941a2a48 100644 --- a/data/shaders/sky.frag +++ b/data/shaders/sky.frag @@ -3,6 +3,7 @@ uniform mat4 ViewMatrix; uniform mat4 ProjectionMatrix; uniform mat4 InverseViewMatrix; uniform mat4 InverseProjectionMatrix; +uniform vec2 screen; #else layout (std140) uniform MatrixesData { diff --git a/data/shaders/ssao.frag b/data/shaders/ssao.frag index 8d7040445..22c68a620 100644 --- a/data/shaders/ssao.frag +++ b/data/shaders/ssao.frag @@ -9,6 +9,7 @@ uniform mat4 ViewMatrix; uniform mat4 ProjectionMatrix; uniform mat4 InverseViewMatrix; uniform mat4 InverseProjectionMatrix; +uniform vec2 screen; #else layout (std140) uniform MatrixesData { diff --git a/src/graphics/glwrap.cpp b/src/graphics/glwrap.cpp index 0b474a666..1f7292d11 100644 --- a/src/graphics/glwrap.cpp +++ b/src/graphics/glwrap.cpp @@ -87,7 +87,7 @@ static void CALLBACK #endif debugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, - const GLchar* msg, const void *userparam) + const GLchar* msg, const void *userparam) { switch(source) { @@ -153,58 +153,58 @@ debugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei le void initGL() { - if (is_gl_init) - return; - is_gl_init = true; + if (is_gl_init) + return; + is_gl_init = true; #ifdef _IRR_WINDOWS_API_ - glGenTransformFeedbacks = (PFNGLGENTRANSFORMFEEDBACKSPROC)IRR_OGL_LOAD_EXTENSION("glGenTransformFeedbacks"); - glBindTransformFeedback = (PFNGLBINDTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glBindTransformFeedback"); - glDrawTransformFeedback = (PFNGLDRAWTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glDrawTransformFeedback"); - glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glBeginTransformFeedback"); - glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glEndTransformFeedback"); - glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)IRR_OGL_LOAD_EXTENSION("glBindBufferBase"); - glGenBuffers = (PFNGLGENBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glGenBuffers"); - glBindBuffer = (PFNGLBINDBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glBindBuffer"); - glBufferData = (PFNGLBUFFERDATAPROC)IRR_OGL_LOAD_EXTENSION("glBufferData"); - glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribPointer"); - glCreateShader = (PFNGLCREATESHADERPROC)IRR_OGL_LOAD_EXTENSION("glCreateShader"); - glCompileShader = (PFNGLCOMPILESHADERPROC)IRR_OGL_LOAD_EXTENSION("glCompileShader"); - glShaderSource = (PFNGLSHADERSOURCEPROC)IRR_OGL_LOAD_EXTENSION("glShaderSource"); - glCreateProgram = (PFNGLCREATEPROGRAMPROC)IRR_OGL_LOAD_EXTENSION("glCreateProgram"); - glAttachShader = (PFNGLATTACHSHADERPROC)IRR_OGL_LOAD_EXTENSION("glAttachShader"); - glLinkProgram = (PFNGLLINKPROGRAMPROC)IRR_OGL_LOAD_EXTENSION("glLinkProgram"); - glUseProgram = (PFNGLUSEPROGRAMPROC)IRR_OGL_LOAD_EXTENSION("glUseProgram"); - glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)IRR_OGL_LOAD_EXTENSION("glEnableVertexAttribArray"); - glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)IRR_OGL_LOAD_EXTENSION("glGetUniformLocation"); - glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)IRR_OGL_LOAD_EXTENSION("glUniformMatrix4fv"); - glUniform1f = (PFNGLUNIFORM1FPROC)IRR_OGL_LOAD_EXTENSION("glUniform1f"); - glUniform3f = (PFNGLUNIFORM3FPROC)IRR_OGL_LOAD_EXTENSION("glUniform3f"); - glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)IRR_OGL_LOAD_EXTENSION("glDisableVertexAttribArray"); - glDeleteShader = (PFNGLDELETESHADERPROC)IRR_OGL_LOAD_EXTENSION("glDeleteShader"); - glGetShaderiv = (PFNGLGETSHADERIVPROC)IRR_OGL_LOAD_EXTENSION("glGetShaderiv"); - glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)IRR_OGL_LOAD_EXTENSION("glGetShaderInfoLog"); - glActiveTexture = (PFNGLACTIVETEXTUREPROC)IRR_OGL_LOAD_EXTENSION("glActiveTexture"); - glUniform2f = (PFNGLUNIFORM2FPROC)IRR_OGL_LOAD_EXTENSION("glUniform2f"); - glUniform4i = (PFNGLUNIFORM4IPROC)IRR_OGL_LOAD_EXTENSION("glUniform4i"); - glUniform3i = (PFNGLUNIFORM3IPROC)IRR_OGL_LOAD_EXTENSION("glUniform3i"); - glUniform1i = (PFNGLUNIFORM1IPROC)IRR_OGL_LOAD_EXTENSION("glUniform1i"); - glGetProgramiv = (PFNGLGETPROGRAMIVPROC)IRR_OGL_LOAD_EXTENSION("glGetProgramiv"); - glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)IRR_OGL_LOAD_EXTENSION("glGetProgramInfoLog"); - glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)IRR_OGL_LOAD_EXTENSION("glTransformFeedbackVaryings"); - glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)IRR_OGL_LOAD_EXTENSION("glGetAttribLocation"); - glBlendEquation = (PFNGLBLENDEQUATIONPROC)IRR_OGL_LOAD_EXTENSION("glBlendEquation"); - glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribDivisor"); - glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)IRR_OGL_LOAD_EXTENSION("glDrawArraysInstanced"); + glGenTransformFeedbacks = (PFNGLGENTRANSFORMFEEDBACKSPROC)IRR_OGL_LOAD_EXTENSION("glGenTransformFeedbacks"); + glBindTransformFeedback = (PFNGLBINDTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glBindTransformFeedback"); + glDrawTransformFeedback = (PFNGLDRAWTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glDrawTransformFeedback"); + glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glBeginTransformFeedback"); + glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)IRR_OGL_LOAD_EXTENSION("glEndTransformFeedback"); + glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)IRR_OGL_LOAD_EXTENSION("glBindBufferBase"); + glGenBuffers = (PFNGLGENBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glGenBuffers"); + glBindBuffer = (PFNGLBINDBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glBindBuffer"); + glBufferData = (PFNGLBUFFERDATAPROC)IRR_OGL_LOAD_EXTENSION("glBufferData"); + glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribPointer"); + glCreateShader = (PFNGLCREATESHADERPROC)IRR_OGL_LOAD_EXTENSION("glCreateShader"); + glCompileShader = (PFNGLCOMPILESHADERPROC)IRR_OGL_LOAD_EXTENSION("glCompileShader"); + glShaderSource = (PFNGLSHADERSOURCEPROC)IRR_OGL_LOAD_EXTENSION("glShaderSource"); + glCreateProgram = (PFNGLCREATEPROGRAMPROC)IRR_OGL_LOAD_EXTENSION("glCreateProgram"); + glAttachShader = (PFNGLATTACHSHADERPROC)IRR_OGL_LOAD_EXTENSION("glAttachShader"); + glLinkProgram = (PFNGLLINKPROGRAMPROC)IRR_OGL_LOAD_EXTENSION("glLinkProgram"); + glUseProgram = (PFNGLUSEPROGRAMPROC)IRR_OGL_LOAD_EXTENSION("glUseProgram"); + glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)IRR_OGL_LOAD_EXTENSION("glEnableVertexAttribArray"); + glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)IRR_OGL_LOAD_EXTENSION("glGetUniformLocation"); + glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)IRR_OGL_LOAD_EXTENSION("glUniformMatrix4fv"); + glUniform1f = (PFNGLUNIFORM1FPROC)IRR_OGL_LOAD_EXTENSION("glUniform1f"); + glUniform3f = (PFNGLUNIFORM3FPROC)IRR_OGL_LOAD_EXTENSION("glUniform3f"); + glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)IRR_OGL_LOAD_EXTENSION("glDisableVertexAttribArray"); + glDeleteShader = (PFNGLDELETESHADERPROC)IRR_OGL_LOAD_EXTENSION("glDeleteShader"); + glGetShaderiv = (PFNGLGETSHADERIVPROC)IRR_OGL_LOAD_EXTENSION("glGetShaderiv"); + glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)IRR_OGL_LOAD_EXTENSION("glGetShaderInfoLog"); + glActiveTexture = (PFNGLACTIVETEXTUREPROC)IRR_OGL_LOAD_EXTENSION("glActiveTexture"); + glUniform2f = (PFNGLUNIFORM2FPROC)IRR_OGL_LOAD_EXTENSION("glUniform2f"); + glUniform4i = (PFNGLUNIFORM4IPROC)IRR_OGL_LOAD_EXTENSION("glUniform4i"); + glUniform3i = (PFNGLUNIFORM3IPROC)IRR_OGL_LOAD_EXTENSION("glUniform3i"); + glUniform1i = (PFNGLUNIFORM1IPROC)IRR_OGL_LOAD_EXTENSION("glUniform1i"); + glGetProgramiv = (PFNGLGETPROGRAMIVPROC)IRR_OGL_LOAD_EXTENSION("glGetProgramiv"); + glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)IRR_OGL_LOAD_EXTENSION("glGetProgramInfoLog"); + glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)IRR_OGL_LOAD_EXTENSION("glTransformFeedbackVaryings"); + glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)IRR_OGL_LOAD_EXTENSION("glGetAttribLocation"); + glBlendEquation = (PFNGLBLENDEQUATIONPROC)IRR_OGL_LOAD_EXTENSION("glBlendEquation"); + glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribDivisor"); + glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)IRR_OGL_LOAD_EXTENSION("glDrawArraysInstanced"); glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC)IRR_OGL_LOAD_EXTENSION("glDrawElementsInstanced"); - glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glDeleteBuffers"); - glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)IRR_OGL_LOAD_EXTENSION("glGenVertexArrays"); - glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)IRR_OGL_LOAD_EXTENSION("glBindVertexArray"); - glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)IRR_OGL_LOAD_EXTENSION("glDeleteVertexArrays"); - glTexBuffer = (PFNGLTEXBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glTexBuffer"); - glUniform1fv = (PFNGLUNIFORM1FVPROC)IRR_OGL_LOAD_EXTENSION("glUniform1fv"); - glUniform4fv = (PFNGLUNIFORM4FVPROC)IRR_OGL_LOAD_EXTENSION("glUniform4fv"); - glBufferSubData = (PFNGLBUFFERSUBDATAPROC)IRR_OGL_LOAD_EXTENSION("glBufferSubData"); - glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribIPointer"); + glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glDeleteBuffers"); + glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)IRR_OGL_LOAD_EXTENSION("glGenVertexArrays"); + glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)IRR_OGL_LOAD_EXTENSION("glBindVertexArray"); + glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)IRR_OGL_LOAD_EXTENSION("glDeleteVertexArrays"); + glTexBuffer = (PFNGLTEXBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glTexBuffer"); + glUniform1fv = (PFNGLUNIFORM1FVPROC)IRR_OGL_LOAD_EXTENSION("glUniform1fv"); + glUniform4fv = (PFNGLUNIFORM4FVPROC)IRR_OGL_LOAD_EXTENSION("glUniform4fv"); + glBufferSubData = (PFNGLBUFFERSUBDATAPROC)IRR_OGL_LOAD_EXTENSION("glBufferSubData"); + glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)IRR_OGL_LOAD_EXTENSION("glVertexAttribIPointer"); glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glGenFramebuffers"); glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)IRR_OGL_LOAD_EXTENSION("glDeleteFramebuffers"); glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)IRR_OGL_LOAD_EXTENSION("glBindFramebuffer"); @@ -221,7 +221,7 @@ void initGL() glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)IRR_OGL_LOAD_EXTENSION("glCompressedTexImage2D"); glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC)IRR_OGL_LOAD_EXTENSION("glGetCompressedTexImage"); #ifdef DEBUG - glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)IRR_OGL_LOAD_EXTENSION("glDebugMessageCallbackARB"); + glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)IRR_OGL_LOAD_EXTENSION("glDebugMessageCallbackARB"); #endif #endif #ifdef ARB_DEBUG_OUTPUT @@ -233,69 +233,69 @@ void initGL() // Mostly from shader tutorial GLuint LoadShader(const char * file, unsigned type) { - GLuint Id = glCreateShader(type); + GLuint Id = glCreateShader(type); char versionString[20]; sprintf(versionString, "#version %d\n", irr_driver->getGLSLVersion()); std::string Code = versionString; - std::ifstream Stream(file, std::ios::in); + std::ifstream Stream(file, std::ios::in); Code += "//" + std::string(file) + "\n"; if (UserConfigParams::m_ubo_disabled) Code += "#define UBO_DISABLED\n"; if (irr_driver->hasVSLayerExtension()) Code += "#define VSLayer\n"; - if (Stream.is_open()) - { - std::string Line = ""; - while (getline(Stream, Line)) - Code += "\n" + Line; - Stream.close(); - } - GLint Result = GL_FALSE; - int InfoLogLength; - Log::info("GLWrap", "Compiling shader : %s", file); - char const * SourcePointer = Code.c_str(); - int length = strlen(SourcePointer); - glShaderSource(Id, 1, &SourcePointer, &length); - glCompileShader(Id); + if (Stream.is_open()) + { + std::string Line = ""; + while (getline(Stream, Line)) + Code += "\n" + Line; + Stream.close(); + } + GLint Result = GL_FALSE; + int InfoLogLength; + Log::info("GLWrap", "Compiling shader : %s", file); + char const * SourcePointer = Code.c_str(); + int length = strlen(SourcePointer); + glShaderSource(Id, 1, &SourcePointer, &length); + glCompileShader(Id); - glGetShaderiv(Id, GL_COMPILE_STATUS, &Result); - if (Result == GL_FALSE) + glGetShaderiv(Id, GL_COMPILE_STATUS, &Result); + if (Result == GL_FALSE) { Log::error("GLWrap", "Error in shader %s", file); - glGetShaderiv(Id, GL_INFO_LOG_LENGTH, &InfoLogLength); - char *ErrorMessage = new char[InfoLogLength]; - glGetShaderInfoLog(Id, InfoLogLength, NULL, ErrorMessage); + glGetShaderiv(Id, GL_INFO_LOG_LENGTH, &InfoLogLength); + char *ErrorMessage = new char[InfoLogLength]; + glGetShaderInfoLog(Id, InfoLogLength, NULL, ErrorMessage); Log::error("GLWrap", ErrorMessage); - delete[] ErrorMessage; - } + delete[] ErrorMessage; + } glGetError(); - return Id; + return Id; } GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsigned varyingscount) { - GLuint Program = glCreateProgram(); + GLuint Program = glCreateProgram(); loadAndAttach(Program, GL_VERTEX_SHADER, vertex_file_path); - glTransformFeedbackVaryings(Program, varyingscount, varyings, GL_INTERLEAVED_ATTRIBS); - glLinkProgram(Program); + glTransformFeedbackVaryings(Program, varyingscount, varyings, GL_INTERLEAVED_ATTRIBS); + glLinkProgram(Program); - GLint Result = GL_FALSE; - int InfoLogLength; - glGetProgramiv(Program, GL_LINK_STATUS, &Result); - if (Result == GL_FALSE) + GLint Result = GL_FALSE; + int InfoLogLength; + glGetProgramiv(Program, GL_LINK_STATUS, &Result); + if (Result == GL_FALSE) { - glGetProgramiv(Program, GL_INFO_LOG_LENGTH, &InfoLogLength); - char *ErrorMessage = new char[InfoLogLength]; - glGetProgramInfoLog(Program, InfoLogLength, NULL, ErrorMessage); - printf(ErrorMessage); - delete[] ErrorMessage; - } + glGetProgramiv(Program, GL_INFO_LOG_LENGTH, &InfoLogLength); + char *ErrorMessage = new char[InfoLogLength]; + glGetProgramInfoLog(Program, InfoLogLength, NULL, ErrorMessage); + printf(ErrorMessage); + delete[] ErrorMessage; + } glGetError(); - return Program; + return Program; } GLuint getTextureGLuint(irr::video::ITexture *tex) @@ -387,11 +387,11 @@ void compressTexture(irr::video::ITexture *tex, bool srgb, bool premul_alpha) //----------------------------------------------------------------------------- /** Try to load a compressed texture from the given file name. -* Data in the specified file need to have a specific format. See the -* saveCompressedTexture() function for a description of the format. -* \return true if the loading succeeded, false otherwise. -* \see saveCompressedTexture -*/ + * Data in the specified file need to have a specific format. See the + * saveCompressedTexture() function for a description of the format. + * \return true if the loading succeeded, false otherwise. + * \see saveCompressedTexture + */ bool loadCompressedTexture(const std::string& compressed_tex) { std::ifstream ifs(compressed_tex.c_str(), std::ios::in | std::ios::binary); @@ -414,7 +414,7 @@ bool loadCompressedTexture(const std::string& compressed_tex) if (!ifs.fail()) { glCompressedTexImage2D(GL_TEXTURE_2D, 0, internal_format, - w, h, 0, size, (GLvoid*)data); + w, h, 0, size, (GLvoid*)data); glGenerateMipmap(GL_TEXTURE_2D); delete[] data; ifs.close(); @@ -426,14 +426,14 @@ bool loadCompressedTexture(const std::string& compressed_tex) //----------------------------------------------------------------------------- /** Try to save the last texture sent to glTexImage2D in a file of the given -* file name. This function should only be used for textures sent to -* glTexImage2D with a compressed internal format as argument.
-* \note The following format is used to save the compressed texture:
-*
-* The first four elements are integers and the last one is stored -* on \c size bytes. -* \see loadCompressedTexture -*/ + * file name. This function should only be used for textures sent to + * glTexImage2D with a compressed internal format as argument.
+ * \note The following format is used to save the compressed texture:
+ *
+ * The first four elements are integers and the last one is stored + * on \c size bytes. + * \see loadCompressedTexture + */ void saveCompressedTexture(const std::string& compressed_tex) { int internal_format, width, height, size, compressionSuccessful; @@ -462,12 +462,12 @@ void saveCompressedTexture(const std::string& compressed_tex) void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum MinFilter, bool allowAF) { - glActiveTexture(GL_TEXTURE0 + TextureUnit); - glBindTexture(GL_TEXTURE_2D, TextureId); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, MagFilter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, MinFilter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glActiveTexture(GL_TEXTURE0 + TextureUnit); + glBindTexture(GL_TEXTURE_2D, TextureId); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, MagFilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, MinFilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); int aniso = UserConfigParams::m_anisotropic; if (aniso == 0) aniso = 1; @@ -584,7 +584,7 @@ void FrameBuffer::BlitToDefault(size_t x0, size_t y0, size_t x1, size_t y1) void draw3DLine(const core::vector3df& start, - const core::vector3df& end, irr::video::SColor color) + const core::vector3df& end, irr::video::SColor color) { if (!irr_driver->isGLSL()) { irr_driver->getVideoDriver()->draw3DLine(start, end, color); @@ -608,8 +608,8 @@ void draw3DLine(const core::vector3df& start, } static void drawTexColoredQuad(const video::ITexture *texture, const video::SColor *col, float width, float height, - float center_pos_x, float center_pos_y, float tex_center_pos_x, float tex_center_pos_y, - float tex_width, float tex_height) + float center_pos_x, float center_pos_y, float tex_center_pos_x, float tex_center_pos_y, + float tex_width, float tex_height) { unsigned colors[] = { col[0].getRed(), col[0].getGreen(), col[0].getBlue(), col[0].getAlpha(), @@ -635,8 +635,8 @@ static void drawTexColoredQuad(const video::ITexture *texture, const video::SCol } void drawTexQuad(const video::ITexture *texture, float width, float height, - float center_pos_x, float center_pos_y, float tex_center_pos_x, float tex_center_pos_y, - float tex_width, float tex_height) + float center_pos_x, float center_pos_y, float tex_center_pos_x, float tex_center_pos_y, + float tex_width, float tex_height) { glUseProgram(UIShader::TextureRectShader::Program); glBindVertexArray(UIShader::TextureRectShader::vao); @@ -653,12 +653,12 @@ void drawTexQuad(const video::ITexture *texture, float width, float height, static void getSize(const video::ITexture* texture, const core::rect& destRect, -const core::rect& sourceRect, -float &width, float &height, -float ¢er_pos_x, float ¢er_pos_y, -float &tex_width, float &tex_height, -float &tex_center_pos_x, float &tex_center_pos_y -) + const core::rect& sourceRect, + float &width, float &height, + float ¢er_pos_x, float ¢er_pos_y, + float &tex_width, float &tex_height, + float &tex_center_pos_x, float &tex_center_pos_y + ) { core::dimension2d frame_size = irr_driver->getVideoDriver()->getCurrentRenderTargetSize(); @@ -700,8 +700,8 @@ float &tex_center_pos_x, float &tex_center_pos_y } void draw2DImage(const video::ITexture* texture, const core::rect& destRect, - const core::rect& sourceRect, const core::rect* clipRect, - const video::SColor &colors, bool useAlphaChannelOfTexture) + const core::rect& sourceRect, const core::rect* clipRect, + const video::SColor &colors, bool useAlphaChannelOfTexture) { if (!irr_driver->isGLSL()) { video::SColor duplicatedArray[4] = { @@ -717,7 +717,7 @@ void draw2DImage(const video::ITexture* texture, const core::rect& destRect tex_center_pos_x, tex_center_pos_y; getSize(texture, destRect, sourceRect, width, height, center_pos_x, center_pos_y, - tex_width, tex_height, tex_center_pos_x, tex_center_pos_y); + tex_width, tex_height, tex_center_pos_x, tex_center_pos_y); if (useAlphaChannelOfTexture) { @@ -736,7 +736,7 @@ void draw2DImage(const video::ITexture* texture, const core::rect& destRect glEnable(GL_SCISSOR_TEST); const core::dimension2d& renderTargetSize = irr_driver->getVideoDriver()->getCurrentRenderTargetSize(); glScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height - clipRect->LowerRightCorner.Y, - clipRect->getWidth(), clipRect->getHeight()); + clipRect->getWidth(), clipRect->getHeight()); } glUseProgram(UIShader::UniformColoredTextureRectShader::Program); @@ -756,14 +756,14 @@ void draw2DImage(const video::ITexture* texture, const core::rect& destRect } void draw2DImage(const video::ITexture* texture, const core::rect& destRect, - const core::rect& sourceRect, const core::rect* clipRect, - const video::SColor* const colors, bool useAlphaChannelOfTexture) + const core::rect& sourceRect, const core::rect* clipRect, + const video::SColor* const colors, bool useAlphaChannelOfTexture) { - if (!irr_driver->isGLSL()) - { - irr_driver->getVideoDriver()->draw2DImage(texture, destRect, sourceRect, clipRect, colors, useAlphaChannelOfTexture); - return; - } + if (!irr_driver->isGLSL()) + { + irr_driver->getVideoDriver()->draw2DImage(texture, destRect, sourceRect, clipRect, colors, useAlphaChannelOfTexture); + return; + } float width, height, center_pos_x, center_pos_y, @@ -771,17 +771,17 @@ void draw2DImage(const video::ITexture* texture, const core::rect& destRect tex_center_pos_x, tex_center_pos_y; getSize(texture, destRect, sourceRect, width, height, center_pos_x, center_pos_y, - tex_width, tex_height, tex_center_pos_x, tex_center_pos_y); + tex_width, tex_height, tex_center_pos_x, tex_center_pos_y); - if (useAlphaChannelOfTexture) - { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - else - { - glDisable(GL_BLEND); - } + if (useAlphaChannelOfTexture) + { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + else + { + glDisable(GL_BLEND); + } if (clipRect) { if (!clipRect->isValid()) @@ -790,55 +790,55 @@ void draw2DImage(const video::ITexture* texture, const core::rect& destRect glEnable(GL_SCISSOR_TEST); const core::dimension2d& renderTargetSize = irr_driver->getVideoDriver()->getCurrentRenderTargetSize(); glScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height - clipRect->LowerRightCorner.Y, - clipRect->getWidth(), clipRect->getHeight()); + clipRect->getWidth(), clipRect->getHeight()); } - if (colors) - drawTexColoredQuad(texture, colors, width, height, center_pos_x, center_pos_y, - tex_center_pos_x, tex_center_pos_y, tex_width, tex_height); - else - drawTexQuad(texture, width, height, center_pos_x, center_pos_y, - tex_center_pos_x, tex_center_pos_y, tex_width, tex_height); + if (colors) + drawTexColoredQuad(texture, colors, width, height, center_pos_x, center_pos_y, + tex_center_pos_x, tex_center_pos_y, tex_width, tex_height); + else + drawTexQuad(texture, width, height, center_pos_x, center_pos_y, + tex_center_pos_x, tex_center_pos_y, tex_width, tex_height); if (clipRect) glDisable(GL_SCISSOR_TEST); - glUseProgram(0); + glUseProgram(0); glGetError(); } void GL32_draw2DRectangle(video::SColor color, const core::rect& position, - const core::rect* clip) + const core::rect* clip) { - if (!irr_driver->isGLSL()) - { - irr_driver->getVideoDriver()->draw2DRectangle(color, position, clip); - return; - } + if (!irr_driver->isGLSL()) + { + irr_driver->getVideoDriver()->draw2DRectangle(color, position, clip); + return; + } - core::dimension2d frame_size = - irr_driver->getVideoDriver()->getCurrentRenderTargetSize(); - const int screen_w = frame_size.Width; - const int screen_h = frame_size.Height; - float center_pos_x = float(position.UpperLeftCorner.X + position.LowerRightCorner.X); - center_pos_x /= screen_w; - center_pos_x -= 1; - float center_pos_y = float(position.UpperLeftCorner.Y + position.LowerRightCorner.Y); - center_pos_y /= screen_h; - center_pos_y = 1 - center_pos_y; - float width = float(position.LowerRightCorner.X - position.UpperLeftCorner.X); - width /= screen_w; - float height = float(position.LowerRightCorner.Y - position.UpperLeftCorner.Y); - height /= screen_h; + core::dimension2d frame_size = + irr_driver->getVideoDriver()->getCurrentRenderTargetSize(); + const int screen_w = frame_size.Width; + const int screen_h = frame_size.Height; + float center_pos_x = float(position.UpperLeftCorner.X + position.LowerRightCorner.X); + center_pos_x /= screen_w; + center_pos_x -= 1; + float center_pos_y = float(position.UpperLeftCorner.Y + position.LowerRightCorner.Y); + center_pos_y /= screen_h; + center_pos_y = 1 - center_pos_y; + float width = float(position.LowerRightCorner.X - position.UpperLeftCorner.X); + width /= screen_w; + float height = float(position.LowerRightCorner.Y - position.UpperLeftCorner.Y); + height /= screen_h; - if (color.getAlpha() < 255) - { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - else - { - glDisable(GL_BLEND); - } + if (color.getAlpha() < 255) + { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + else + { + glDisable(GL_BLEND); + } if (clip) { @@ -848,19 +848,19 @@ void GL32_draw2DRectangle(video::SColor color, const core::rect& position, glEnable(GL_SCISSOR_TEST); const core::dimension2d& renderTargetSize = irr_driver->getVideoDriver()->getCurrentRenderTargetSize(); glScissor(clip->UpperLeftCorner.X, renderTargetSize.Height - clip->LowerRightCorner.Y, - clip->getWidth(), clip->getHeight()); + clip->getWidth(), clip->getHeight()); } - glUseProgram(UIShader::ColoredRectShader::Program); - glBindVertexArray(UIShader::ColoredRectShader::vao); - UIShader::ColoredRectShader::setUniforms(center_pos_x, center_pos_y, width, height, color); + glUseProgram(UIShader::ColoredRectShader::Program); + glBindVertexArray(UIShader::ColoredRectShader::vao); + UIShader::ColoredRectShader::setUniforms(center_pos_x, center_pos_y, width, height, color); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindVertexArray(0); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindVertexArray(0); if (clip) glDisable(GL_SCISSOR_TEST); - glUseProgram(0); + glUseProgram(0); glGetError(); } diff --git a/src/graphics/material.cpp b/src/graphics/material.cpp index 39bdc8bb6..0b9a2a321 100644 --- a/src/graphics/material.cpp +++ b/src/graphics/material.cpp @@ -54,6 +54,7 @@ const unsigned int VCLAMP = 2; */ Material::Material(const XMLNode *node, int index, bool deprecated) { + m_shader_type = SHADERTYPE_SOLID; m_deprecated = deprecated; node->get("name", &m_texname); @@ -73,26 +74,20 @@ Material::Material(const XMLNode *node, int index, bool deprecated) node->get("clampv", &b); if (b) m_clamp_tex |= VCLAMP; //blender 2.4 style node->get("clampV", &b); if (b) m_clamp_tex |= VCLAMP; //blender 2.5 style - node->get("transparency", &m_alpha_testing ); - node->get("lightmap", &m_lightmap ); - node->get("additive-lightmap",&m_additive_lightmap ); - + std::string s; - node->get("adjust-image", &s ); - if(s=="premultiply") - m_adjust_image = ADJ_PREMUL; - else if (s=="divide") - m_adjust_image = ADJ_DIV; - else if (s=="" || s=="none") - m_adjust_image = ADJ_NONE; - else - Log::warn("material", - "Incorrect adjust-image specification: '%s' - ignored.", - s.c_str()); - node->get("alpha", &m_alpha_blending ); - node->get("light", &m_lighting ); + //node->get("adjust-image", &s ); + //if(s=="premultiply") + // m_adjust_image = ADJ_PREMUL; + //else if (s=="divide") + // m_adjust_image = ADJ_DIV; + //else if (s=="" || s=="none") + // m_adjust_image = ADJ_NONE; + //else + // Log::warn("material", + // "Incorrect adjust-image specification: '%s' - ignored.", + // s.c_str()); - node->get("smooth-reflection",&m_smooth_reflection_shader); node->get("high-adhesion", &m_high_tire_adhesion); node->get("reset", &m_drive_reset ); @@ -135,7 +130,6 @@ Material::Material(const XMLNode *node, int index, bool deprecated) node->get("surface", &m_surface ); node->get("ignore", &m_ignore ); - node->get("additive", &m_add ); node->get("max-speed", &m_max_speed_fraction); node->get("slowdown-time", &m_slowdown_time ); node->get("backface-culling", &m_backface_culling ); @@ -160,152 +154,203 @@ Material::Material(const XMLNode *node, int index, bool deprecated) } - s=""; - node->get("graphical-effect", &s); - - if (s == "water") + s = ""; + if (node->get("shader", &s)) { - // For backwards compatibility only, eventually remove - m_water_splash = true; - } - else if (s == "bubble") - { - m_graphical_effect = GE_BUBBLE; - } - else if (s == "grass") - { - m_graphical_effect = GE_GRASS; - m_grass_speed = 1.5f; - m_grass_amplitude = 0.25f; - node->get("grass-speed", &m_grass_speed); - node->get("grass-amplitude", &m_grass_amplitude); - } - else if (s == "water_shader") - { - m_graphical_effect = GE_WATER_SHADER; - node->get("water-shader-speed-1", &m_water_shader_speed_1); - node->get("water-shader-speed-2", &m_water_shader_speed_2); - } - else if (s == "normal_map") - { - m_graphical_effect = GE_NORMAL_MAP; - node->get("normal-map", &m_normal_map_tex); - node->get("normal-light-map", &m_normal_map_shader_lightmap); - - // TODO: add support for parallax and height maps? - /* - else if (node->get("normal-heightmap", &m_normal_map_tex)) + if (s == "solid") { - m_is_heightmap = true; - m_normal_map = true; + m_shader_type = SHADERTYPE_SOLID; } - else if (node->get("parallax-map", &m_normal_map_tex)) + else if (s == "unlit") { - m_parallax_map = true; - m_parallax_height = 0.2f; - node->get("parallax-height", &m_parallax_height); + m_shader_type = SHADERTYPE_SOLID_UNLIT; } - else if (node->get("parallax-heightmap", &m_normal_map_tex)) + else if (s == "additive") { - m_is_heightmap = true; - m_parallax_map = true; - m_parallax_height = 0.2f; - node->get("parallax-height", &m_parallax_height); + m_shader_type = SHADERTYPE_ADDITIVE; } - */ - } - else if (s == "spheremap") - { - m_graphical_effect = GE_SPHERE_MAP; - } - else if (s == "skybox") - { - m_graphical_effect = GE_SKYBOX; - } - else if (s == "splatting") - { - m_graphical_effect = GE_SPLATTING; - node->get("splatting-texture-1", &m_splatting_texture_1); - node->get("splatting-texture-2", &m_splatting_texture_2); - node->get("splatting-texture-3", &m_splatting_texture_3); - node->get("splatting-texture-4", &m_splatting_texture_4); - } - else if (s == "caustics") - { - m_graphical_effect = GE_CAUSTICS; - } - else if (s == "none") - { - } - else if (s != "") - { - Log::warn("material", - "Invalid graphical effect specification: '%s' - ignored.", - s.c_str()); - } - else - { - m_graphical_effect = GE_NONE; - } - - - // BACKWARDS COMPATIBILITY, remove eventually - bool use_normal_map = false; - node->get("use-normal-map", &use_normal_map); - - if (use_normal_map) - { - if (node->get("normal-map", &m_normal_map_tex)) + else if (s == "alphatest") { - m_graphical_effect = GE_NORMAL_MAP; + m_shader_type = SHADERTYPE_ALPHA_TEST; + } + else if (s == "alphablend") + { + m_shader_type = SHADERTYPE_ALPHA_BLEND; + } + else if (s == "spheremap") + { + m_shader_type = SHADERTYPE_SPHERE_MAP; + } + else if (s == "water_shader") + { + m_shader_type = SHADERTYPE_WATER; + node->get("water-shader-speed-1", &m_water_shader_speed_1); + node->get("water-shader-speed-2", &m_water_shader_speed_2); + } + else if (s == "grass") + { + m_shader_type = SHADERTYPE_VEGETATION; + m_grass_speed = 1.5f; + m_grass_amplitude = 0.25f; + node->get("grass-speed", &m_grass_speed); + node->get("grass-amplitude", &m_grass_amplitude); + } + else if (s == "splatting") + { + m_shader_type = SHADERTYPE_SPLATTING; + node->get("splatting-texture-1", &m_splatting_texture_1); + node->get("splatting-texture-2", &m_splatting_texture_2); + node->get("splatting-texture-3", &m_splatting_texture_3); + node->get("splatting-texture-4", &m_splatting_texture_4); + } + else if (s == "bubble") + { + m_shader_type = SHADERTYPE_BUBBLE; } else { - Log::warn("material", - "Could not find normal map image in materials.xml"); + Log::warn("Material", "Unknown shader type <%s> for <%s>", s.c_str(), m_texname.c_str()); + } + } + else + { + // BACKWARS COMPATIBILITY, EVENTUALLY REMOVE + + bool b = false; + node->get("additive", &b); + if (b) + m_shader_type = SHADERTYPE_ADDITIVE; + + b = false; + node->get("transparency", &b); + if (b) + m_shader_type = SHADERTYPE_ALPHA_TEST; + + //node->get("lightmap", &m_lightmap); + + b = false; + node->get("alpha", &b); + if (b) + m_shader_type = SHADERTYPE_ALPHA_BLEND; + + b = true; + node->get("light", &b); + if (!b) + m_shader_type = SHADERTYPE_SOLID_UNLIT; + + b = false; + node->get("smooth-reflection", &b); + if (b) + m_shader_type = SHADERTYPE_SPHERE_MAP; + + + if (node->get("compositing", &s)) + { + if (s == "blend") m_shader_type = SHADERTYPE_ALPHA_BLEND; + else if (s == "test") m_shader_type = SHADERTYPE_ALPHA_TEST; + else if (s == "additive") m_shader_type = SHADERTYPE_ADDITIVE; + else if (s == "coverage") m_shader_type = SHADERTYPE_ALPHA_TEST; + else if (s != "none") + Log::warn("material", "Unknown compositing mode '%s'", s.c_str()); } - node->get("normal-light-map", &m_normal_map_shader_lightmap); + s = ""; + node->get("graphical-effect", &s); + + if (s == "water") + { + m_water_splash = true; + } + else if (s == "bubble") + { + m_shader_type = SHADERTYPE_BUBBLE; + } + else if (s == "grass") + { + m_shader_type = SHADERTYPE_VEGETATION; + m_grass_speed = 1.5f; + m_grass_amplitude = 0.25f; + node->get("grass-speed", &m_grass_speed); + node->get("grass-amplitude", &m_grass_amplitude); + } + else if (s == "water_shader") + { + m_shader_type = SHADERTYPE_WATER; + node->get("water-shader-speed-1", &m_water_shader_speed_1); + node->get("water-shader-speed-2", &m_water_shader_speed_2); + } + else if (s == "normal_map") + { + m_shader_type = SHADERTYPE_SOLID; + node->get("normal-map", &m_normal_map_tex); + } + else if (s == "spheremap") + { + m_shader_type = SHADERTYPE_SPHERE_MAP; + } + else if (s == "splatting") + { + m_shader_type = SHADERTYPE_SPLATTING; + node->get("splatting-texture-1", &m_splatting_texture_1); + node->get("splatting-texture-2", &m_splatting_texture_2); + node->get("splatting-texture-3", &m_splatting_texture_3); + node->get("splatting-texture-4", &m_splatting_texture_4); + } + else if (s == "none") + { + } + else if (s != "") + { + Log::warn("material", + "Invalid graphical effect specification: '%s' - ignored.", + s.c_str()); + } + else + { + m_shader_type = SHADERTYPE_SOLID; + } + + bool use_normal_map = false; + node->get("use-normal-map", &use_normal_map); + + if (use_normal_map) + { + if (node->get("normal-map", &m_normal_map_tex)) + { + //m_graphical_effect = GE_NORMAL_MAP; + } + else + { + Log::warn("material", + "Could not find normal map image in materials.xml"); + } + } + + bool sphere_map = false; + node->get("sphere", &sphere_map); + if (sphere_map) + { + m_shader_type = SHADERTYPE_SPHERE_MAP; + } + + bool water_shader = false; + node->get("water-shader", &water_shader); + if (water_shader) + { + m_shader_type = SHADERTYPE_WATER; + node->get("water-shader-speed-1", &m_water_shader_speed_1); + node->get("water-shader-speed-2", &m_water_shader_speed_2); + } + + // ---- End backwards compatibility } - - // BACKWARDS COMPATIBILITY, remove eventually - bool sphere_map = false; - node->get("sphere", &sphere_map ); - if (sphere_map) + if (m_disable_z_write && m_shader_type != SHADERTYPE_ALPHA_BLEND && m_shader_type != SHADERTYPE_ADDITIVE) { - m_graphical_effect = GE_SPHERE_MAP; - } - - - if (node->get("compositing", &s)) - { - if (s == "blend") m_alpha_blending = true; - else if (s == "test") m_alpha_testing = true; - else if (s == "additive") m_add = true; - // backwards compatibility only, no longer supported - else if (s == "coverage") m_alpha_testing = true; - else if (s != "none") - Log::warn("material", "Unknown compositing mode '%s'", - s.c_str()); - } - - if (m_disable_z_write && !m_alpha_blending && !m_add) - { - Log::warn("material", "Disabling writes to z buffer only makes sense when compositing is blending or additive (for %s)", m_texname.c_str()); + Log::debug("material", "Disabling writes to z buffer only makes sense when compositing is blending or additive (for %s)", m_texname.c_str()); m_disable_z_write = false; } - bool water_shader = false; - node->get("water-shader", &water_shader); - if (water_shader) - { - // BACKWARDS COMPATIBILITY, eventually remove - m_graphical_effect = GE_WATER_SHADER; - node->get("water-shader-speed-1", &m_water_shader_speed_1); - node->get("water-shader-speed-2", &m_water_shader_speed_2); - } - // Terrain-specifc sound effect const unsigned int children_count = node->getNumNodes(); for (unsigned int i=0; igetTexture(full_path, - isPreMul(), - isPreDiv(), + false, //isPreMul(), + false, //isPreDiv(), complain_if_not_found); } @@ -659,36 +696,35 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m } - int modes = 0; - - if (!m_lighting && irr_driver->isGLSL() && !m_alpha_blending && !m_add) + if (m_shader_type == SHADERTYPE_SOLID_UNLIT) { m->MaterialType = irr_driver->getShader(ES_OBJECT_UNLIT); - modes++; + + m->AmbientColor = video::SColor(255, 255, 255, 255); + m->DiffuseColor = video::SColor(255, 255, 255, 255); + m->EmissiveColor = video::SColor(255, 255, 255, 255); + m->SpecularColor = video::SColor(255, 255, 255, 255); } - if (m_alpha_testing) + if (m_shader_type == SHADERTYPE_ALPHA_TEST) { m->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; - modes++; } - if (m_alpha_blending) - { - //m->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; - // EMT_TRANSPARENT_ALPHA_CHANNEL does include vertex color alpha into + if (m_shader_type == SHADERTYPE_ALPHA_BLEND) + { + // EMT_TRANSPARENT_ALPHA_CHANNEL doesn't include vertex color alpha into // account, which messes up fading in/out effects. So we use the more // customizable EMT_ONETEXTURE_BLEND instead. - m->MaterialType = video::EMT_ONETEXTURE_BLEND ; + m->MaterialType = video::EMT_ONETEXTURE_BLEND; m->MaterialTypeParam = pack_textureBlendFunc(video::EBF_SRC_ALPHA, video::EBF_ONE_MINUS_SRC_ALPHA, video::EMFN_MODULATE_1X, video::EAS_TEXTURE | video::EAS_VERTEX_COLOR); - - modes++; } - if (m_smooth_reflection_shader) + + if (m_shader_type == SHADERTYPE_SPHERE_MAP) { if (irr_driver->isGLSL()) { @@ -697,58 +733,17 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m else { m->MaterialType = video::EMT_SPHERE_MAP; - - // sphere map + alpha blending is a supported combination so in - // this case don't increase mode count - if (m_alpha_blending) - { - m->BlendOperation = video::EBO_ADD; - } - else - { - modes++; - } - } - } - if (m_graphical_effect == GE_SPHERE_MAP) - { - if (irr_driver->isGLSL()) - { - m->MaterialType = irr_driver->getShader(ES_SPHERE_MAP); - } - else - { - m->MaterialType = video::EMT_SPHERE_MAP; - - // sphere map + alpha blending is a supported combination so in - // this case don't increase mode count - if (m_alpha_blending) - { - m->BlendOperation = video::EBO_ADD; - } - else - { - modes++; - } } } - if (m_lightmap) - { - m->MaterialType = video::EMT_LIGHTMAP; - modes++; - } - if (m_additive_lightmap) - { - m->MaterialType = video::EMT_LIGHTMAP_ADD; - modes++; - } + //if (m_lightmap) + //{ + // m->MaterialType = video::EMT_LIGHTMAP; + //} - if (m_add) + if (m_shader_type == SHADERTYPE_ADDITIVE) { - //m->MaterialType = video::EMT_TRANSPARENT_ADD_COLOR; - - // EMT_TRANSPARENT_ADD_COLOR does include vertex color alpha into + // EMT_TRANSPARENT_ADD_COLOR doesn't include vertex color alpha into // account, which messes up fading in/out effects. So we use the // more customizable EMT_ONETEXTURE_BLEND instead m->MaterialType = video::EMT_ONETEXTURE_BLEND ; @@ -757,39 +752,39 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m video::EMFN_MODULATE_1X, video::EAS_TEXTURE | video::EAS_VERTEX_COLOR); - modes++; } - if (m_graphical_effect == GE_NORMAL_MAP) + + if (m_shader_type == SHADERTYPE_SOLID && m_normal_map_tex.size() > 0) { IVideoDriver* video_driver = irr_driver->getVideoDriver(); if (irr_driver->isGLSL()) { if (mb->getVertexType() != video::EVT_TANGENTS) - Log::error("material", "Requiring normal map without tangent enabled mesh"); - ITexture* tex = irr_driver->getTexture(m_normal_map_tex); - if (m_is_heightmap) { - video_driver->makeNormalMapTexture( tex ); + Log::warn("material", "Requiring normal map without tangent enabled mesh for <%s>", + m_texname.c_str()); } - m->setTexture(1, tex); - - bool with_lightmap = false; - - if (m_normal_map_shader_lightmap.size() > 0) + else { - ITexture* lm_tex = irr_driver->getTexture(m_normal_map_shader_lightmap); - m->setTexture(2, lm_tex); - with_lightmap = true; + ITexture* tex = irr_driver->getTexture(m_normal_map_tex); + m->setTexture(1, tex); + + bool with_lightmap = false; + + //if (m_normal_map_shader_lightmap.size() > 0) + //{ + // ITexture* lm_tex = irr_driver->getTexture(m_normal_map_shader_lightmap); + // m->setTexture(2, lm_tex); + // with_lightmap = true; + //} + + // Material and shaders + m->MaterialType = irr_driver->getShader( + with_lightmap ? ES_NORMAL_MAP_LIGHTMAP : ES_NORMAL_MAP); + m->Lighting = false; + m->ZWriteEnable = true; } - - // Material and shaders - m->MaterialType = irr_driver->getShader( - with_lightmap ? ES_NORMAL_MAP_LIGHTMAP : ES_NORMAL_MAP ); - m->Lighting = false; - m->ZWriteEnable = true; - - modes++; } else { @@ -797,29 +792,30 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m m->setTexture(1, NULL); } } - if (m_parallax_map) - { - video::ITexture* tex = irr_driver->getTexture(m_normal_map_tex); - if (m_is_heightmap) - { - irr_driver->getVideoDriver()->makeNormalMapTexture( tex ); - } - m->setTexture(1, tex); - m->MaterialType = video::EMT_PARALLAX_MAP_SOLID; - m->MaterialTypeParam = m_parallax_height; - m->SpecularColor.set(0,0,0,0); - modes++; - } + //if (m_parallax_map) + //{ + // video::ITexture* tex = irr_driver->getTexture(m_normal_map_tex); + // if (m_is_heightmap) + // { + // irr_driver->getVideoDriver()->makeNormalMapTexture( tex ); + // } + // m->setTexture(1, tex); + // m->MaterialType = video::EMT_PARALLAX_MAP_SOLID; + // m->MaterialTypeParam = m_parallax_height; + // m->SpecularColor.set(0,0,0,0); + // modes++; + //} - if(m_graphical_effect == GE_SKYBOX && irr_driver->isGLSL()) - { - ITexture* tex = irr_driver->getTexture("cloud_mask.png"); - m->setTexture(1, tex); + //if(m_graphical_effect == GE_SKYBOX && irr_driver->isGLSL()) + //{ + // ITexture* tex = irr_driver->getTexture("cloud_mask.png"); + // m->setTexture(1, tex); + // + // + // m->MaterialType = irr_driver->getShader(ES_SKYBOX); + //} - - m->MaterialType = irr_driver->getShader(ES_SKYBOX); - } - if (m_graphical_effect == GE_SPLATTING) + if (m_shader_type == SHADERTYPE_SPLATTING) { if (irr_driver->supportsSplatting()) { @@ -846,12 +842,12 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m // Material and shaders m->MaterialType = irr_driver->getShader(ES_SPLATTING); - } - else - { - m->MaterialType = video::EMT_SOLID; - } } + else + { + m->MaterialType = video::EMT_SOLID; + } + } // Modify lightmap materials so that vertex colors are taken into account. @@ -866,7 +862,7 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m m->SpecularColor = video::SColor(255, 255, 255, 255); } - if (m_graphical_effect == GE_BUBBLE && mb != NULL) + if (m_shader_type == SHADERTYPE_BUBBLE && mb != NULL) { if (irr_driver->isGLSL()) { @@ -876,18 +872,11 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m m->MaterialType = irr_driver->getShader(ES_BUBBLES); m->BlendOperation = video::EBO_ADD; - - // alpha blending and bubble shading can work together so when both are enabled - // don't increment the 'modes' counter to not get the 'too many modes' warning - if (!m_alpha_blending) - { - modes++; - } } } - if (m_graphical_effect == GE_WATER_SHADER) + if (m_shader_type == SHADERTYPE_WATER) { if (irr_driver->isGLSL()) { @@ -901,10 +890,9 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m m->MaterialType = irr_driver->getShader(ES_WATER); } - modes++; } - if (m_graphical_effect == GE_GRASS) + if (m_shader_type == SHADERTYPE_VEGETATION) { if (UserConfigParams::m_weather_effects && irr_driver->isGLSL()) @@ -916,22 +904,20 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m setAmplitude(m_grass_amplitude); // Material and shaders - if (m_alpha_testing) - { + //if (m_alpha_testing) + //{ m->MaterialType = irr_driver->getShader(ES_GRASS_REF); - } - else { - m->MaterialType = irr_driver->getShader(ES_GRASS); - m->BlendOperation = video::EBO_ADD; - } - + //} + //else + //{ + // m->MaterialType = irr_driver->getShader(ES_GRASS); + // m->BlendOperation = video::EBO_ADD; + //} + } + else + { + m->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; } - } - - if (modes > 1) - { - std::cerr << "[Material::setMaterialProperties] More than one main " - "mode set for " << m_texname.c_str() << "\n"; } if (m_disable_z_write) @@ -939,15 +925,6 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m m->ZWriteEnable = false; } - if (!m_lighting) - { - //m->setFlag( video::EMF_LIGHTING, false ); - m->AmbientColor = video::SColor(255, 255, 255, 255); - m->DiffuseColor = video::SColor(255, 255, 255, 255); - m->EmissiveColor = video::SColor(255, 255, 255, 255); - m->SpecularColor = video::SColor(255, 255, 255, 255); - } - #ifdef DEBUG if(UserConfigParams::m_rendering_debug) { @@ -1024,7 +1001,7 @@ void Material::adjustForFog(scene::ISceneNode* parent, video::SMaterial *m, // to disable fog in the new pipeline, we slightly abuse the steps : // moving an object into the transparent pass will make it rendered // above fog and thus unaffected by it - if (use_fog && !m_fog && !m_alpha_blending && !m_add) + if (use_fog && !m_fog && m_shader_type != SHADERTYPE_ALPHA_BLEND && m_shader_type != SHADERTYPE_ADDITIVE) { m->ZWriteEnable = true; m->MaterialType = video::EMT_ONETEXTURE_BLEND; diff --git a/src/graphics/material.hpp b/src/graphics/material.hpp index 7d3e86373..ab1ec0a17 100644 --- a/src/graphics/material.hpp +++ b/src/graphics/material.hpp @@ -46,17 +46,21 @@ class ParticleKind; class Material : public NoCopy { public: - enum GraphicalEffect {GE_NONE, - /** Effect where the UV texture is moved in a wave pattern */ - GE_BUBBLE, - /** Effect that makes grass wave as in the wind */ - GE_GRASS, - GE_WATER_SHADER, - GE_SPHERE_MAP, - GE_SPLATTING, - GE_SKYBOX, - GE_NORMAL_MAP, - GE_CAUSTICS}; + enum ShaderType + { + SHADERTYPE_SOLID, + SHADERTYPE_ALPHA_TEST, + SHADERTYPE_ALPHA_BLEND, + SHADERTYPE_ADDITIVE, + SHADERTYPE_SOLID_UNLIT, + /** Effect where the UV texture is moved in a wave pattern */ + SHADERTYPE_BUBBLE, + /** Effect that makes grass wave as in the wind */ + SHADERTYPE_VEGETATION, + SHADERTYPE_WATER, + SHADERTYPE_SPHERE_MAP, + SHADERTYPE_SPLATTING + }; enum ParticleConditions { @@ -82,7 +86,9 @@ private: /** 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; - GraphicalEffect m_graphical_effect; + + ShaderType m_shader_type; + /** Set if being on this surface means being under some other mesh. * This is used to simulate that a kart is in water: the ground under * the water is marked as 'm_below_surface', which will then trigger a raycast @@ -117,11 +123,11 @@ private: bool m_has_gravity; /** Speed of the 'main' wave in the water shader. Only used if - m_graphical_effect == WATER_SHADER */ + m_shader_type == SHDERTYPE_WATER */ float m_water_shader_speed_1; /** Speed of the 'secondary' waves in the water shader. Only used if - m_graphical_effect == WATER_SHADER */ + m_shader_type == SHADERTYPE_WATER */ float m_water_shader_speed_2; /** If a kart is rescued when crashing into this surface. */ @@ -130,13 +136,13 @@ private: /** Particles to show on touch */ std::string m_collision_particles; + /** If m_shader_type == SHADERTYPE_VEGETATION */ float m_grass_speed; float m_grass_amplitude; /** If the property should be ignored in the physics. Example would be * plants that a kart can just drive through. */ bool m_ignore; - bool m_add; bool m_fog; @@ -144,21 +150,10 @@ private: /** For normal maps */ std::string m_normal_map_tex; - std::string m_normal_map_shader_lightmap; - - //bool m_normal_map_uv2; //!< Whether to use a second UV layer for normal map - bool m_is_heightmap; - bool m_parallax_map; - float m_parallax_height; /** Texture clamp bitmask */ unsigned int m_clamp_tex; - bool m_lighting; - bool m_smooth_reflection_shader; - bool m_alpha_testing; - bool m_alpha_blending; - /** True if backface culliing should be enabled. */ bool m_backface_culling; @@ -167,18 +162,21 @@ private: /** Some textures need to be pre-multiplied, some divided to give * the intended effect. */ - enum {ADJ_NONE, ADJ_PREMUL, ADJ_DIV} - m_adjust_image; - /** True if (blending) lightmapping is enabled for this material. */ - bool m_lightmap; - /** True if (additive) lightmapping is enabled for this material. */ - bool m_additive_lightmap; + //enum {ADJ_NONE, ADJ_PREMUL, ADJ_DIV} + // m_adjust_image; + /** True if lightmapping is enabled for this material. */ + //bool m_lightmap; + + /** True if the material shouldn't be "slippy" at an angle */ bool m_high_tire_adhesion; + /** How much the top speed is reduced per second. */ float m_slowdown_time; + /** Maximum speed at which no more slow down occurs. */ float m_max_speed_fraction; + /** Minimum speed on this terrain. This is used for zippers on a ramp to * guarantee the right jump distance. A negative value indicates no * minimum speed. */ @@ -211,7 +209,7 @@ private: float m_zipper_fade_out_time; /** Additional engine force. */ float m_zipper_engine_force; - + std::string m_mask; /** If m_splatting is true, indicates the first splatting texture */ @@ -249,7 +247,6 @@ public: bool isIgnore () const { return m_ignore; } /** Returns true if this material is a zipper. */ bool isZipper () const { return m_zipper; } - bool isSphereMap () const { return m_graphical_effect == GE_SPHERE_MAP; } /** Returns if this material should trigger a rescue if a kart * is driving on it. */ bool isDriveReset () const { return m_drive_reset; } @@ -264,14 +261,19 @@ public: getTexFname () const { return m_texname; } int getIndex () const { return m_index; } - bool isTransparent () const { return m_alpha_testing || m_alpha_blending || m_add; } + bool isTransparent () const + { + return m_shader_type == SHADERTYPE_ADDITIVE || + m_shader_type == SHADERTYPE_ALPHA_BLEND || + 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; } + //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; } + //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; } @@ -281,9 +283,6 @@ public: * karts. So a short time will slowdown a kart much faster. */ float getSlowDownTime() const { return m_slowdown_time; } // ------------------------------------------------------------------------ - /** Returns true if this material should have smoke effect. */ - //bool hasSmoke () const { return m_graphical_effect==GE_SMOKE;} - // ------------------------------------------------------------------------ /** Returns true if this material is under some other mesh and therefore * requires another raycast to find the surface it is under (used for * gfx, e.g. driving under water to find where the water splash should @@ -341,14 +340,11 @@ public: * on lower speeds. A negative value indicates no minimum speed. */ float getZipperMinSpeed() const { return m_zipper_min_speed; } // ------------------------------------------------------------------------ - bool isNormalMap() const { return m_graphical_effect == GE_NORMAL_MAP; } - + ShaderType getShaderType() const { return m_shader_type; } + // ------------------------------------------------------------------------ void onMadeVisible(scene::IMeshBuffer* who); void onHidden(scene::IMeshBuffer* who); void isInitiallyHidden(scene::IMeshBuffer* who); - /** For particle system : specify if the particle should be additively blended - */ - bool isAlphaAdditive() const { return !m_alpha_blending; } } ; diff --git a/src/graphics/particle_emitter.cpp b/src/graphics/particle_emitter.cpp index 561a1cb7d..bfc66d6b3 100644 --- a/src/graphics/particle_emitter.cpp +++ b/src/graphics/particle_emitter.cpp @@ -453,7 +453,10 @@ void ParticleEmitter::setParticleType(const ParticleKind* type) m_node = irr_driver->addParticleNode(); if (m_is_glsl) - static_cast(m_node)->setAlphaAdditive(type->getMaterial()->isAlphaAdditive()); + { + bool additive = (type->getMaterial()->getShaderType() == Material::SHADERTYPE_ADDITIVE); + static_cast(m_node)->setAlphaAdditive(additive); + } } if (m_parent != NULL) diff --git a/src/graphics/rtts.cpp b/src/graphics/rtts.cpp index b77a61a3e..4c958d762 100644 --- a/src/graphics/rtts.cpp +++ b/src/graphics/rtts.cpp @@ -53,6 +53,7 @@ static GLuint generateFBO(GLuint ColorAttachement, GLuint DepthAttachement) RTT::RTT(size_t width, size_t height) { + m_shadow_FBO = NULL; initGL(); using namespace video; using namespace core; @@ -197,14 +198,14 @@ RTT::RTT(size_t width, size_t height) somevector.clear(); somevector.push_back(shadowColorTex); - shadowFBO = new FrameBuffer(somevector, shadowDepthTex, 1024, 1024, true); + m_shadow_FBO = new FrameBuffer(somevector, shadowDepthTex, 1024, 1024, true); } glBindFramebuffer(GL_FRAMEBUFFER, 0); } RTT::~RTT() { - delete shadowFBO; + delete m_shadow_FBO; glDeleteTextures(RTT_COUNT, RenderTargetTextures); glDeleteTextures(1, &DepthStencilTexture); if (irr_driver->getGLSLVersion() >= 150) diff --git a/src/graphics/rtts.hpp b/src/graphics/rtts.hpp index 96127b3f2..bd5b7bca8 100644 --- a/src/graphics/rtts.hpp +++ b/src/graphics/rtts.hpp @@ -37,7 +37,7 @@ public: RTT(size_t width, size_t height); ~RTT(); - FrameBuffer &getShadowFBO() { return *shadowFBO; } + FrameBuffer &getShadowFBO() { return *m_shadow_FBO; } unsigned getShadowDepthTex() const { return shadowDepthTex; } unsigned getDepthStencilTexture() const { return DepthStencilTexture; } @@ -49,7 +49,7 @@ private: unsigned DepthStencilTexture; unsigned shadowColorTex, shadowDepthTex; - FrameBuffer* shadowFBO; + FrameBuffer* m_shadow_FBO; LEAK_CHECK(); }; diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index 8cfbf43b4..96a0a757a 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -104,43 +104,43 @@ static void initCubeVBO() { // From CSkyBoxSceneNode float corners[] = - { - // top side - 1., 1., -1., - 1., 1., 1., - -1., 1., 1., - -1., 1., -1., + { + // top side + 1., 1., -1., + 1., 1., 1., + -1., 1., 1., + -1., 1., -1., - // Bottom side - 1., -1., 1., - 1., -1., -1., - -1., -1., -1., - -1., -1., 1., + // Bottom side + 1., -1., 1., + 1., -1., -1., + -1., -1., -1., + -1., -1., 1., - // right side - 1., -1, -1, - 1., -1, 1, - 1., 1., 1., - 1., 1., -1., + // right side + 1., -1, -1, + 1., -1, 1, + 1., 1., 1., + 1., 1., -1., - // left side - -1., -1., 1., - -1., -1., -1., - -1., 1., -1., - -1., 1., 1., + // left side + -1., -1., 1., + -1., -1., -1., + -1., 1., -1., + -1., 1., 1., - // back side - -1., -1., -1., - 1., -1, -1., - 1, 1, -1., - -1, 1, -1., + // back side + -1., -1., -1., + 1., -1, -1., + 1, 1, -1., + -1, 1, -1., - // front side - 1., -1., 1., - -1., -1., 1., - -1, 1., 1., - 1., 1., 1., - }; + // front side + 1., -1., 1., + -1., -1., 1., + -1, 1., 1., + 1., 1., 1., + }; int indices[] = { 0, 1, 2, 2, 3, 0, 4, 5, 6, 6, 7, 4, @@ -188,38 +188,38 @@ void Shaders::loadShaders() m_shaders[ES_NORMAL_MAP_LIGHTMAP] = glsl_noinput(dir + "pass.vert", dir + "pass.frag"); m_shaders[ES_SKYBOX] = glslmat(dir + "pass.vert", dir + "pass.frag", - m_callbacks[ES_SKYBOX], EMT_TRANSPARENT_ALPHA_CHANNEL); + m_callbacks[ES_SKYBOX], EMT_TRANSPARENT_ALPHA_CHANNEL); m_shaders[ES_SPLATTING] = glsl_noinput(dir + "pass.vert", dir + "pass.frag"); m_shaders[ES_WATER] = glslmat(dir + "pass.vert", dir + "pass.frag", - m_callbacks[ES_WATER], EMT_TRANSPARENT_ALPHA_CHANNEL); + m_callbacks[ES_WATER], EMT_TRANSPARENT_ALPHA_CHANNEL); m_shaders[ES_WATER_SURFACE] = glsl(dir + "pass.vert", dir + "pass.frag", - m_callbacks[ES_WATER]); + m_callbacks[ES_WATER]); m_shaders[ES_SPHERE_MAP] = glsl_noinput(dir + "pass.vert", dir + "pass.frag"); m_shaders[ES_GRASS] = glslmat(dir + "pass.vert", dir + "pass.frag", - m_callbacks[ES_GRASS], EMT_TRANSPARENT_ALPHA_CHANNEL); + m_callbacks[ES_GRASS], EMT_TRANSPARENT_ALPHA_CHANNEL); m_shaders[ES_GRASS_REF] = glslmat(dir + "pass.vert", dir + "pass.frag", - m_callbacks[ES_GRASS], EMT_TRANSPARENT_ALPHA_CHANNEL_REF); + m_callbacks[ES_GRASS], EMT_TRANSPARENT_ALPHA_CHANNEL_REF); m_shaders[ES_BUBBLES] = glslmat(dir + "pass.vert", dir + "pass.frag", - m_callbacks[ES_BUBBLES], EMT_TRANSPARENT_ALPHA_CHANNEL); + m_callbacks[ES_BUBBLES], EMT_TRANSPARENT_ALPHA_CHANNEL); m_shaders[ES_MOTIONBLUR] = glsl(dir + "pass.vert", dir + "pass.frag", - m_callbacks[ES_MOTIONBLUR]); + m_callbacks[ES_MOTIONBLUR]); m_shaders[ES_GAUSSIAN3H] = glslmat(dir + "pass.vert", dir + "pass.frag", - m_callbacks[ES_GAUSSIAN3H], EMT_SOLID); + m_callbacks[ES_GAUSSIAN3H], EMT_SOLID); m_shaders[ES_GAUSSIAN3V] = glslmat(dir + "pass.vert", dir + "pass.frag", - m_callbacks[ES_GAUSSIAN3V], EMT_SOLID); + m_callbacks[ES_GAUSSIAN3V], EMT_SOLID); m_shaders[ES_MIPVIZ] = glslmat(dir + "pass.vert", dir + "pass.frag", - m_callbacks[ES_MIPVIZ], EMT_SOLID); + m_callbacks[ES_MIPVIZ], EMT_SOLID); m_shaders[ES_COLORIZE] = glslmat(dir + "pass.vert", dir + "pass.frag", - m_callbacks[ES_COLORIZE], EMT_SOLID); + m_callbacks[ES_COLORIZE], EMT_SOLID); m_shaders[ES_OBJECTPASS] = glsl_noinput(dir + "pass.vert", dir + "pass.frag"); m_shaders[ES_OBJECT_UNLIT] = glsl_noinput(dir + "pass.vert", dir + "pass.frag"); @@ -229,10 +229,10 @@ void Shaders::loadShaders() m_shaders[ES_SUNLIGHT] = glsl_noinput(dir + "pass.vert", dir + "pass.frag"); m_shaders[ES_DISPLACE] = glsl(dir + "pass.vert", dir + "pass.frag", - m_callbacks[ES_DISPLACE]); + m_callbacks[ES_DISPLACE]); m_shaders[ES_PASSFAR] = glsl(dir + "pass.vert", dir + "pass.frag", - m_callbacks[ES_COLORIZE]); + m_callbacks[ES_COLORIZE]); // Check that all successfully loaded for (s32 i = 0; i < ES_COUNT; i++) { @@ -273,8 +273,6 @@ void Shaders::loadShaders() FullScreenShader::Gaussian17TapVShader::init(); FullScreenShader::Gaussian6HBlurShader::init(); FullScreenShader::Gaussian6VBlurShader::init(); - FullScreenShader::PenumbraHShader::init(); - FullScreenShader::PenumbraVShader::init(); FullScreenShader::GlowShader::init(); FullScreenShader::PassThroughShader::init(); FullScreenShader::LinearizeDepthShader::init(); @@ -357,7 +355,7 @@ void Shaders::check(const int num) const if (m_shaders[num] == -1) { Log::error("shaders", "Shader %s failed to load. Update your drivers, if the issue " - "persists, report a bug to us.", shader_names[num] + 3); + "persists, report a bug to us.", shader_names[num] + 3); } } @@ -394,8 +392,11 @@ namespace UtilShader glEnableVertexAttribArray(attrib_position); glVertexAttribPointer(attrib_position, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0); uniform_color = glGetUniformLocation(Program, "color"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } } void ColoredLine::setUniforms(const irr::video::SColor &col) @@ -429,8 +430,11 @@ namespace MeshShader uniform_MM = glGetUniformLocation(Program, "ModelMatrix"); uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix"); uniform_tex = glGetUniformLocation(Program, "tex"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } } void ObjectPass1Shader::setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &InverseModelMatrix, unsigned TU_tex) @@ -464,8 +468,11 @@ namespace MeshShader uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix"); uniform_TM = glGetUniformLocation(Program, "TextureMatrix"); uniform_tex = glGetUniformLocation(Program, "tex"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } } void ObjectRefPass1Shader::setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &InverseModelMatrix, const core::matrix4 &TextureMatrix, unsigned TU_tex) @@ -536,8 +543,11 @@ namespace MeshShader uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix"); uniform_normalMap = glGetUniformLocation(Program, "normalMap"); uniform_DiffuseForAlpha = glGetUniformLocation(Program, "DiffuseForAlpha"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } } void NormalMapShader::setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &InverseModelMatrix, unsigned TU_normalMap, unsigned TU_uniform_DiffuseForAlpha) @@ -573,8 +583,11 @@ namespace MeshShader attrib_normal = glGetAttribLocation(Program, "Normal"); attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); uniform_tex = glGetUniformLocation(Program, "tex"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } } void InstancedObjectPass1Shader::setUniforms(unsigned TU_tex) @@ -607,8 +620,11 @@ namespace MeshShader attrib_normal = glGetAttribLocation(Program, "Normal"); attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); uniform_tex = glGetUniformLocation(Program, "tex"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } } void InstancedObjectRefPass1Shader::setUniforms(unsigned TU_tex) @@ -645,8 +661,11 @@ namespace MeshShader attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); uniform_windDir = glGetUniformLocation(Program, "windDir"); uniform_tex = glGetUniformLocation(Program, "tex"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } } void InstancedGrassPass1Shader::setUniforms(const core::vector3df &windDir, unsigned TU_tex) @@ -682,8 +701,11 @@ namespace MeshShader GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap"); GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO"); uniform_ambient = glGetUniformLocation(Program, "ambient"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } TU_Albedo = 3; glUseProgram(Program); @@ -743,8 +765,11 @@ namespace MeshShader glUniform1i(uniform_Albedo, TU_Albedo); glUseProgram(0); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } } void InstancedObjectPass2Shader::setUniforms(const core::matrix4 &ViewProjectionMatrix, const core::matrix4 &TextureMatrix) @@ -873,8 +898,11 @@ namespace MeshShader attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); uniform_MM = glGetUniformLocation(Program, "ModelMatrix"); GLuint uniform_tex = glGetUniformLocation(Program, "tex"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } TU_tex = 3; glUseProgram(Program); @@ -916,8 +944,11 @@ namespace MeshShader GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO"); uniform_ambient = glGetUniformLocation(Program, "ambient"); GLuint uniform_tex = glGetUniformLocation(Program, "tex"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } TU_Albedo = 3; glUseProgram(Program); @@ -928,7 +959,7 @@ namespace MeshShader glUseProgram(0); } - void ObjectRimLimitShader::setUniforms(const core::matrix4 &ModelMatrix, + void ObjectRimLimitShader::setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &InverseModelMatrix, const core::matrix4 &TextureMatrix) { @@ -960,8 +991,11 @@ namespace MeshShader GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap"); GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO"); uniform_ambient = glGetUniformLocation(Program, "ambient"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } glUseProgram(Program); glUniform1i(uniform_DiffuseMap, 0); @@ -1004,8 +1038,11 @@ namespace MeshShader GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap"); GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO"); uniform_ambient = glGetUniformLocation(Program, "ambient"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } TU_Albedo = 3; glUseProgram(Program); @@ -1016,7 +1053,7 @@ namespace MeshShader glUseProgram(0); } - void ObjectRefPass2Shader::setUniforms(const core::matrix4 &ModelMatrix, + void ObjectRefPass2Shader::setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &TextureMatrix) { if (UserConfigParams::m_ubo_disabled) @@ -1062,7 +1099,7 @@ namespace MeshShader glUseProgram(0); } - void GrassPass2Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, + void GrassPass2Shader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::vector3df &windDirection) { glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); @@ -1160,11 +1197,21 @@ namespace MeshShader uniform_MM = glGetUniformLocation(Program, "ModelMatrix"); uniform_IMM = glGetUniformLocation(Program, "InverseModelMatrix"); GLuint uniform_tex = glGetUniformLocation(Program, "tex"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + GLuint uniform_Albedo = glGetUniformLocation(Program, "Albedo"); + GLuint uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap"); + GLuint uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap"); + GLuint uniform_SSAO = glGetUniformLocation(Program, "SSAO"); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } TU_tex = 3; glUseProgram(Program); + glUniform1i(uniform_DiffuseMap, 0); + glUniform1i(uniform_SpecularMap, 1); + glUniform1i(uniform_SSAO, 2); glUniform1i(uniform_tex, TU_tex); glUseProgram(0); } @@ -1319,8 +1366,11 @@ namespace MeshShader uniform_start = glGetUniformLocation(Program, "start"); uniform_end = glGetUniformLocation(Program, "end"); uniform_col = glGetUniformLocation(Program, "col"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } } void TransparentFogShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex) @@ -1359,9 +1409,9 @@ namespace MeshShader uniform_tex = glGetUniformLocation(Program, "tex"); } - void BillboardShader::setUniforms(const core::matrix4 &ModelViewMatrix, - const core::matrix4 &ProjectionMatrix, - const core::vector3df &Position, + void BillboardShader::setUniforms(const core::matrix4 &ModelViewMatrix, + const core::matrix4 &ProjectionMatrix, + const core::vector3df &Position, const core::dimension2d &size, unsigned TU_tex) { @@ -1385,8 +1435,11 @@ namespace MeshShader attrib_position = glGetAttribLocation(Program, "Position"); uniform_MM = glGetUniformLocation(Program, "ModelMatrix"); uniform_col = glGetUniformLocation(Program, "col"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } } void ColorizeShader::setUniforms(const core::matrix4 &ModelMatrix, float r, float g, float b) @@ -1669,8 +1722,11 @@ namespace MeshShader attrib_position = glGetAttribLocation(Program, "Position"); uniform_MM = glGetUniformLocation(Program, "ModelMatrix"); uniform_tex = glGetUniformLocation(Program, "tex"); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } glGenVertexArrays(1, &cubevao); glBindVertexArray(cubevao); @@ -1884,8 +1940,8 @@ namespace ParticleShader } void SimpleParticleRender::setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, - const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_dtex, - const ParticleSystemProxy* particle_system) + const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_dtex, + const ParticleSystemProxy* particle_system) { glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer()); glUniformMatrix4fv(uniform_matrix, 1, GL_FALSE, irr_driver->getProjMatrix().pointer()); @@ -2090,8 +2146,11 @@ namespace FullScreenShader uniform_direction = glGetUniformLocation(Program, "direction"); uniform_col = glGetUniformLocation(Program, "col"); vao = createVAO(Program); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } } void SunLightShader::setUniforms(const core::vector3df &direction, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex) @@ -2157,8 +2216,11 @@ namespace FullScreenShader uniform_direction = glGetUniformLocation(Program, "direction"); uniform_col = glGetUniformLocation(Program, "col"); vao = createVAO(Program); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } } void ShadowedSunLightShader::setUniforms(const core::vector3df &direction, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_shadowtex) @@ -2193,8 +2255,11 @@ namespace FullScreenShader uniform_direction = glGetUniformLocation(Program, "direction"); uniform_col = glGetUniformLocation(Program, "col"); vao = createVAO(Program); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } } void ShadowedSunLightDebugShader::setUniforms(const core::vector3df &direction, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex, unsigned TU_shadowtex) @@ -2292,46 +2357,6 @@ namespace FullScreenShader vao = createVAO(Program); } - GLuint PenumbraHShader::Program; - GLuint PenumbraHShader::uniform_tex; - GLuint PenumbraHShader::uniform_pixel; - GLuint PenumbraHShader::vao; - void PenumbraHShader::init() - { - Program = LoadProgram( - GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(), - GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/penumbrah.frag").c_str()); - uniform_tex = glGetUniformLocation(Program, "tex"); - uniform_pixel = glGetUniformLocation(Program, "pixel"); - vao = createVAO(Program); - } - - void PenumbraHShader::setUniforms(const core::vector2df &pixels, GLuint TU_tex) - { - glUniform2f(uniform_pixel, pixels.X, pixels.Y); - glUniform1i(uniform_tex, TU_tex); - } - - GLuint PenumbraVShader::Program; - GLuint PenumbraVShader::uniform_tex; - GLuint PenumbraVShader::uniform_pixel; - GLuint PenumbraVShader::vao; - void PenumbraVShader::init() - { - Program = LoadProgram( - GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(), - GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/penumbrav.frag").c_str()); - uniform_tex = glGetUniformLocation(Program, "tex"); - uniform_pixel = glGetUniformLocation(Program, "pixel"); - vao = createVAO(Program); - } - - void PenumbraVShader::setUniforms(const core::vector2df &pixels, GLuint TU_tex) - { - glUniform2f(uniform_pixel, pixels.X, pixels.Y); - glUniform1i(uniform_tex, TU_tex); - } - GLuint ShadowGenShader::Program; GLuint ShadowGenShader::uniform_halft; GLuint ShadowGenShader::uniform_quarter; @@ -2422,8 +2447,11 @@ namespace FullScreenShader uniform_noise_texture = glGetUniformLocation(Program, "noise_texture"); uniform_samplePoints = glGetUniformLocation(Program, "samplePoints[0]"); vao = createVAO(Program); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } // SSAOSamples[4 * i] and SSAOSamples[4 * i + 1] can be negative @@ -2508,35 +2536,35 @@ namespace FullScreenShader SSAOSamples[63] = 0.772942f; // Generate another random distribution, if needed - /* for (unsigned i = 0; i < 16; i++) { - // Use double to avoid denorm and get a true uniform distribution - // Generate z component between [0.1; 1] to avoid being too close from surface - double z = rand(); - z /= RAND_MAX; - z = 0.1 + 0.9 * z; + /* for (unsigned i = 0; i < 16; i++) { + // Use double to avoid denorm and get a true uniform distribution + // Generate z component between [0.1; 1] to avoid being too close from surface + double z = rand(); + z /= RAND_MAX; + z = 0.1 + 0.9 * z; - // Now generate x,y on the unit circle - double x = rand(); - x /= RAND_MAX; - x = 2 * x - 1; - double y = rand(); - y /= RAND_MAX; - y = 2 * y - 1; - double xynorm = sqrt(x * x + y * y); - x /= xynorm; - y /= xynorm; - // Now resize x,y so that norm(x,y,z) is one - x *= sqrt(1. - z * z); - y *= sqrt(1. - z * z); + // Now generate x,y on the unit circle + double x = rand(); + x /= RAND_MAX; + x = 2 * x - 1; + double y = rand(); + y /= RAND_MAX; + y = 2 * y - 1; + double xynorm = sqrt(x * x + y * y); + x /= xynorm; + y /= xynorm; + // Now resize x,y so that norm(x,y,z) is one + x *= sqrt(1. - z * z); + y *= sqrt(1. - z * z); - // Norm factor - double w = rand(); - w /= RAND_MAX; - SSAOSamples[4 * i] = (float)x; - SSAOSamples[4 * i + 1] = (float)y; - SSAOSamples[4 * i + 2] = (float)z; - SSAOSamples[4 * i + 3] = (float)w; - }*/ + // Norm factor + double w = rand(); + w /= RAND_MAX; + SSAOSamples[4 * i] = (float)x; + SSAOSamples[4 * i + 1] = (float)y; + SSAOSamples[4 * i + 2] = (float)z; + SSAOSamples[4 * i + 3] = (float)w; + }*/ } void SSAOShader::setUniforms(const core::vector2df &screen, unsigned TU_dtex, unsigned TU_noise) @@ -2573,8 +2601,11 @@ namespace FullScreenShader uniform_end = glGetUniformLocation(Program, "end"); uniform_col = glGetUniformLocation(Program, "col"); vao = createVAO(Program); - GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); - glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } } void FogShader::setUniforms(float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, unsigned TU_ntex) diff --git a/src/graphics/stkinstancedscenenode.cpp b/src/graphics/stkinstancedscenenode.cpp index 50a9cae9e..c10e5ca6b 100644 --- a/src/graphics/stkinstancedscenenode.cpp +++ b/src/graphics/stkinstancedscenenode.cpp @@ -283,6 +283,16 @@ static void drawSMDefault(GLMesh &mesh, const core::matrix4 &ModelViewProjection size_t count = mesh.IndexCount; setTexture(MeshShader::InstancedObjectPass2Shader::TU_Albedo, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true); + if (irr_driver->getLightViz()) + { + GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA }; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); + } + else + { + GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); + } MeshShader::InstancedObjectPass2Shader::setUniforms(ModelViewProjectionMatrix, core::matrix4::EM4CONST_IDENTITY); @@ -299,6 +309,16 @@ static void drawSMAlphaRefTexture(GLMesh &mesh, const core::matrix4 &ModelViewPr compressTexture(mesh.textures[0], true); setTexture(MeshShader::InstancedObjectRefPass2Shader::TU_Albedo, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true); + if (irr_driver->getLightViz()) + { + GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA }; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); + } + else + { + GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); + } MeshShader::InstancedObjectRefPass2Shader::setUniforms(ModelViewProjectionMatrix, core::matrix4::EM4CONST_IDENTITY); @@ -315,6 +335,16 @@ static void drawSMGrass(GLMesh &mesh, const core::matrix4 &ModelViewProjectionMa compressTexture(mesh.textures[0], true); setTexture(MeshShader::InstancedGrassPass2Shader::TU_Albedo, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true); + if (irr_driver->getLightViz()) + { + GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA }; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); + } + else + { + GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); + } setTexture(MeshShader::InstancedGrassPass2Shader::TU_dtex, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST); SunLightProvider * const cb = (SunLightProvider *)irr_driver->getCallback(ES_SUNLIGHT); diff --git a/src/graphics/stkmesh.cpp b/src/graphics/stkmesh.cpp index 588319ea6..639871c50 100644 --- a/src/graphics/stkmesh.cpp +++ b/src/graphics/stkmesh.cpp @@ -308,6 +308,16 @@ void drawSphereMap(const GLMesh &mesh, const core::matrix4 &ModelMatrix, const c size_t count = mesh.IndexCount; compressTexture(mesh.textures[0], true); + if (irr_driver->getLightViz()) + { + GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA }; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); + } + else + { + GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); + } setTexture(MeshShader::SphereMapShader::TU_tex, getTextureGLuint(mesh.textures[0]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true); MeshShader::SphereMapShader::setUniforms(ModelMatrix, InverseModelMatrix); diff --git a/src/states_screens/register_screen.cpp b/src/states_screens/register_screen.cpp index 88ba1bf80..fd7c91738 100644 --- a/src/states_screens/register_screen.cpp +++ b/src/states_screens/register_screen.cpp @@ -101,6 +101,12 @@ void RegisterScreen::doRegister() { m_info_widget->setText(_("Email has to be between 4 and 50 characters long!"), false); } + else if ( email.find(L"@")== -1 || email.find(L".")== -1 || + (email.findLast(L'.') - email.findLast(L'@') <= 2 ) || + email.findLast(L'@')==0 ) + { + m_info_widget->setText(_("Email is invalid!"), false); + } else { m_info_widget->setDefaultColor();