diff --git a/client/shaders/object_shader/opengl_vertex.glsl b/client/shaders/object_shader/opengl_vertex.glsl index d5a434da5..65acba92a 100644 --- a/client/shaders/object_shader/opengl_vertex.glsl +++ b/client/shaders/object_shader/opengl_vertex.glsl @@ -91,7 +91,7 @@ float directional_ambient(vec3 normal) void main(void) { - varTexCoord = (mTexture * inTexCoord0).st; + varTexCoord = (mTexture * vec4(inTexCoord0.xy, 1.0, 1.0)).st; gl_Position = mWorldViewProj * inVertexPosition; vPosition = gl_Position.xyz; diff --git a/irr/src/OpenGL/Driver.cpp b/irr/src/OpenGL/Driver.cpp index 0dd6ea1bb..cb45c45c8 100644 --- a/irr/src/OpenGL/Driver.cpp +++ b/irr/src/OpenGL/Driver.cpp @@ -1125,8 +1125,11 @@ void COpenGL3DriverBase::setMaterial(const SMaterial &material) OverrideMaterial.apply(Material); for (u32 i = 0; i < Feature.MaxTextureUnits; ++i) { - CacheHandler->getTextureCache().set(i, material.getTexture(i)); - setTransform((E_TRANSFORMATION_STATE)(ETS_TEXTURE_0 + i), material.getTextureMatrix(i)); + auto *texture = material.getTexture(i); + CacheHandler->getTextureCache().set(i, texture); + if (texture) { + setTransform((E_TRANSFORMATION_STATE)(ETS_TEXTURE_0 + i), material.getTextureMatrix(i)); + } } } diff --git a/src/client/shader.cpp b/src/client/shader.cpp index dae53ff96..242fda81c 100644 --- a/src/client/shader.cpp +++ b/src/client/shader.cpp @@ -249,7 +249,7 @@ public: m_world_view_proj.set(worldViewProj, services); if (driver->getDriverType() == video::EDT_OGLES2 || driver->getDriverType() == video::EDT_OPENGL3) { - core::matrix4 texture = driver->getTransform(video::ETS_TEXTURE_0); + auto &texture = driver->getTransform(video::ETS_TEXTURE_0); m_world_view.set(worldView, services); m_texture.set(texture, services); } @@ -573,6 +573,7 @@ ShaderInfo ShaderSource::generateShader(const std::string &name, } else { shaders_header << "#version 100\n"; } + // cf. EVertexAttributes.h for the predefined ones vertex_header = R"( precision mediump float; @@ -582,7 +583,7 @@ ShaderInfo ShaderSource::generateShader(const std::string &name, attribute highp vec4 inVertexPosition; attribute lowp vec4 inVertexColor; - attribute mediump vec4 inTexCoord0; + attribute mediump vec2 inTexCoord0; attribute mediump vec3 inVertexNormal; attribute mediump vec4 inVertexTangent; attribute mediump vec4 inVertexBinormal;