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/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..845462746 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,8 +1197,11 @@ 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); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } TU_tex = 3; glUseProgram(Program); @@ -1319,8 +1359,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 +1402,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 +1428,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 +1715,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 +1933,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 +2139,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 +2209,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 +2248,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 +2350,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 +2440,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 +2529,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 +2594,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);