Fix texture matrix handling in our shaders

This commit is contained in:
sfan5 2024-09-06 10:32:05 +02:00 committed by SmallJoker
parent 4e3b8db2b9
commit e27757fa3a
3 changed files with 9 additions and 5 deletions

@ -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;

@ -1125,9 +1125,12 @@ void COpenGL3DriverBase::setMaterial(const SMaterial &material)
OverrideMaterial.apply(Material);
for (u32 i = 0; i < Feature.MaxTextureUnits; ++i) {
CacheHandler->getTextureCache().set(i, material.getTexture(i));
auto *texture = material.getTexture(i);
CacheHandler->getTextureCache().set(i, texture);
if (texture) {
setTransform((E_TRANSFORMATION_STATE)(ETS_TEXTURE_0 + i), material.getTextureMatrix(i));
}
}
}
//! prints error if an error happened.

@ -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;