One more fix for legacy pipeline in GLES renderer.

It looks that the second texture is not used at all and it may cause a crash, so just disable it.
This commit is contained in:
Deve 2017-02-27 00:26:36 +01:00
parent 6d395d4510
commit 40fe3585bb
4 changed files with 41 additions and 38 deletions

View File

@ -18,15 +18,15 @@ precision mediump float;
uniform int uMaterialType;
uniform bool uTextureUsage0;
uniform bool uTextureUsage1;
//uniform bool uTextureUsage1;
uniform sampler2D uTextureUnit0;
uniform sampler2D uTextureUnit1;
//uniform sampler2D uTextureUnit1;
/* Varyings */
varying vec2 varTexCoord0;
varying vec2 varTexCoord1;
//varying vec2 varTexCoord1;
varying vec4 varVertexColor;
varying float varEyeDist;
@ -47,9 +47,10 @@ vec4 render2LayerSolid()
float BlendFactor = varVertexColor.a;
vec4 Texel0 = texture2D(uTextureUnit0, varTexCoord0);
vec4 Texel1 = texture2D(uTextureUnit1, varTexCoord1);
//vec4 Texel1 = texture2D(uTextureUnit1, varTexCoord1);
vec4 Color = Texel0 * BlendFactor + Texel1 * (1.0 - BlendFactor);
vec4 Color = Texel0 * BlendFactor;
//vec4 Color += Texel1 * (1.0 - BlendFactor);
return Color;
}
@ -57,9 +58,10 @@ vec4 render2LayerSolid()
vec4 renderLightMap()
{
vec4 Texel0 = texture2D(uTextureUnit0, varTexCoord0);
vec4 Texel1 = texture2D(uTextureUnit1, varTexCoord1);
//vec4 Texel1 = texture2D(uTextureUnit1, varTexCoord1);
vec4 Color = Texel0 * Texel1 * 4.0;
vec4 Color = Texel0 * 4.0;
//Color *= Texel1;
Color.a = Texel0.a * Texel0.a;
return Color;
@ -68,10 +70,10 @@ vec4 renderLightMap()
vec4 renderDetailMap()
{
vec4 Texel0 = texture2D(uTextureUnit0, varTexCoord0);
vec4 Texel1 = texture2D(uTextureUnit1, varTexCoord1);
//vec4 Texel1 = texture2D(uTextureUnit1, varTexCoord1);
vec4 Color = Texel0;
Color += Texel1 - 0.5;
//Color += Texel1 - 0.5;
return Color;
}
@ -81,9 +83,10 @@ vec4 renderReflection2Layer()
vec4 Color = varVertexColor;
vec4 Texel0 = texture2D(uTextureUnit0, varTexCoord0);
vec4 Texel1 = texture2D(uTextureUnit1, varTexCoord1);
//vec4 Texel1 = texture2D(uTextureUnit1, varTexCoord1);
Color *= Texel0 * Texel1;
Color *= Texel0;
//Color *= Texel1;
return Color;
}

View File

@ -4,7 +4,7 @@ attribute vec3 inVertexPosition;
attribute vec3 inVertexNormal;
attribute vec4 inVertexColor;
attribute vec2 inTexCoord0;
attribute vec2 inTexCoord1;
//attribute vec2 inTexCoord1;
/* Uniforms */
@ -13,12 +13,12 @@ uniform int uMaterialType;
uniform mat4 uMvpMatrix;
uniform mat4 uTextureMatrix0;
uniform mat4 uTextureMatrix1;
//uniform mat4 uTextureMatrix1;
/* Varyings */
varying vec2 varTexCoord0;
varying vec2 varTexCoord1;
//varying vec2 varTexCoord1;
varying vec4 varVertexColor;
varying float varEyeDist;
@ -29,8 +29,8 @@ void main(void)
vec4 TexCoord0 = vec4(inTexCoord0.x, inTexCoord0.y, 0.0, 0.0);
varTexCoord0 = vec4(uTextureMatrix0 * TexCoord0).xy;
vec4 TexCoord1 = vec4(inTexCoord1.x, inTexCoord1.y, 0.0, 0.0);
varTexCoord1 = vec4(uTextureMatrix1 * TexCoord1).xy;
//vec4 TexCoord1 = vec4(inTexCoord1.x, inTexCoord1.y, 0.0, 0.0);
//varTexCoord1 = vec4(uTextureMatrix1 * TexCoord1).xy;
varVertexColor = inVertexColor.zyxw;
}

View File

@ -1107,18 +1107,18 @@ namespace video
glVertexAttribPointer(EVA_TCOORD0, 2, GL_FLOAT, false, sizeof(S3DVertex), buffer_offset(28));
}
if (CurrentTexture[1])
{
// There must be some optimisation here as it uses the same texture coord !
glEnableVertexAttribArray(EVA_TCOORD1);
if (vertices)
glVertexAttribPointer(EVA_TCOORD1, 2, GL_FLOAT, false, sizeof(S3DVertex), &(static_cast<const S3DVertex*>(vertices))[0].TCoords);
else
glVertexAttribPointer(EVA_TCOORD1, 2, GL_FLOAT, false, sizeof(S3DVertex), buffer_offset(28));
}
//if (CurrentTexture[1])
//{
// // There must be some optimisation here as it uses the same texture coord !
// glEnableVertexAttribArray(EVA_TCOORD1);
// if (vertices)
// glVertexAttribPointer(EVA_TCOORD1, 2, GL_FLOAT, false, sizeof(S3DVertex), &(static_cast<const S3DVertex*>(vertices))[0].TCoords);
// else
// glVertexAttribPointer(EVA_TCOORD1, 2, GL_FLOAT, false, sizeof(S3DVertex), buffer_offset(28));
//}
break;
case EVT_2TCOORDS:
glEnableVertexAttribArray(EVA_TCOORD1);
//glEnableVertexAttribArray(EVA_TCOORD1);
if (vertices)
{
glVertexAttribPointer(EVA_POSITION, (threed ? 3 : 2), GL_FLOAT, false, sizeof(S3DVertex2TCoords), &(static_cast<const S3DVertex2TCoords*>(vertices))[0].Pos);
@ -1126,7 +1126,7 @@ namespace video
glVertexAttribPointer(EVA_NORMAL, 3, GL_FLOAT, false, sizeof(S3DVertex2TCoords), &(static_cast<const S3DVertex2TCoords*>(vertices))[0].Normal);
glVertexAttribPointer(EVA_COLOR, 4, GL_UNSIGNED_BYTE, true, sizeof(S3DVertex2TCoords), &(static_cast<const S3DVertex2TCoords*>(vertices))[0].Color);
glVertexAttribPointer(EVA_TCOORD0, 2, GL_FLOAT, false, sizeof(S3DVertex2TCoords), &(static_cast<const S3DVertex2TCoords*>(vertices))[0].TCoords);
glVertexAttribPointer(EVA_TCOORD1, 2, GL_FLOAT, false, sizeof(S3DVertex2TCoords), &(static_cast<const S3DVertex2TCoords*>(vertices))[0].TCoords2);
//glVertexAttribPointer(EVA_TCOORD1, 2, GL_FLOAT, false, sizeof(S3DVertex2TCoords), &(static_cast<const S3DVertex2TCoords*>(vertices))[0].TCoords2);
}
else
{
@ -1134,7 +1134,7 @@ namespace video
glVertexAttribPointer(EVA_NORMAL, 3, GL_FLOAT, false, sizeof(S3DVertex2TCoords), buffer_offset(12));
glVertexAttribPointer(EVA_COLOR, 4, GL_UNSIGNED_BYTE, true, sizeof(S3DVertex2TCoords), buffer_offset(24));
glVertexAttribPointer(EVA_TCOORD0, 2, GL_FLOAT, false, sizeof(S3DVertex2TCoords), buffer_offset(28));
glVertexAttribPointer(EVA_TCOORD1, 2, GL_FLOAT, false, sizeof(S3DVertex2TCoords), buffer_offset(36));
//glVertexAttribPointer(EVA_TCOORD1, 2, GL_FLOAT, false, sizeof(S3DVertex2TCoords), buffer_offset(36));
}
break;
@ -1266,10 +1266,10 @@ namespace video
glDisableVertexAttribArray(EVA_TANGENT);
glDisableVertexAttribArray(EVA_BINORMAL);
}
if ((vType != EVT_STANDARD) || CurrentTexture[1])
{
glDisableVertexAttribArray(EVA_TCOORD1);
}
//if ((vType != EVT_STANDARD) || CurrentTexture[1])
//{
// glDisableVertexAttribArray(EVA_TCOORD1);
//}
#ifdef GL_OES_point_size_array
if (FeatureAvailable[IRR_OES_point_size_array] && (Material.Thickness == 0.0f))

View File

@ -144,22 +144,22 @@ bool COGLES2FixedPipelineRenderer::OnRender(IMaterialRendererServices* service,
/* Textures Upload */
s32 TextureUsage0 = Driver->isActiveTexture(0);
s32 TextureUsage1 = Driver->isActiveTexture(1);
//s32 TextureUsage1 = Driver->isActiveTexture(1);
IMaterialRendererServices::setPixelShaderConstant("uTextureUsage0", &TextureUsage0, 1);
IMaterialRendererServices::setPixelShaderConstant("uTextureUsage1", &TextureUsage1, 1);
//IMaterialRendererServices::setPixelShaderConstant("uTextureUsage1", &TextureUsage1, 1);
core::matrix4 textureMatrix0 = Driver->getTransform(video::ETS_TEXTURE_0);
core::matrix4 textureMatrix1 = Driver->getTransform(video::ETS_TEXTURE_0);
//core::matrix4 textureMatrix1 = Driver->getTransform(video::ETS_TEXTURE_0);
IMaterialRendererServices::setPixelShaderConstant("uTextureMatrix0", textureMatrix0.pointer(), 16);
IMaterialRendererServices::setPixelShaderConstant("uTextureMatrix1", textureMatrix1.pointer(), 16);
//IMaterialRendererServices::setPixelShaderConstant("uTextureMatrix1", textureMatrix1.pointer(), 16);
s32 TextureUnit0 = 0;
s32 TextureUnit1 = 1;
//s32 TextureUnit1 = 1;
IMaterialRendererServices::setPixelShaderConstant("uTextureUnit0", &TextureUnit0, 1);
IMaterialRendererServices::setPixelShaderConstant("uTextureUnit1", &TextureUnit1, 1);
//IMaterialRendererServices::setPixelShaderConstant("uTextureUnit1", &TextureUnit1, 1);
return true;
}