1
\$\begingroup\$

I've recently tried to run my game in a new hardware (arm a17 processor, Mali-T760) and the result is quite bad, as you can see in the images below seems that the polygon's coordinates are clamped to infinite values. The game runs ok and at a good framerate on PC and on another arm-a20 based tablet. This is how it should be: good pattern

And this is what I get (ignore the color change): bad pattern

Another detail is when I zoom in into this area it disappears, same as a near/far plane clip issue, but can't find the error.

My game uses Ogre3D (OpenGL ES 2.0). Any ideas of what this glitch could be about?

EDIT: Code that I use to initialize entity's material:

Ogre::TextureManager* tmgr = Ogre::TextureManager::getSingletonPtr();
Ogre::TexturePtr ptr = tmgr->createManual(mColorMapTextureName,                             Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                               Ogre::TEX_TYPE_2D,
                               16,  // Width 
                               4,    // Height
                               1, // Depth
                               0,

                               Ogre::PF_A8B8G8R8,

                               Ogre::TU_AUTOMIPMAP | Ogre::TU_DYNAMIC);


        ptr->createInternalResources();
        ptr->load();
    }


    Ogre::MaterialManager* mmgr = Ogre::MaterialManager::getSingletonPtr();
mMaterialName = uniqueMaterialName("Ground");
mMaterial = mmgr->create(mMaterialName, "General");

Ogre::Technique* tec = mMaterial->getTechnique(0);
tec->setSchemeName("ShaderGeneratorDefaultScheme");
Ogre::Pass* pass = tec->getPass(0);
pass->setDepthBias(mDepthBias);
pass->setVertexProgram("Ground/vs", false);
pass->setFragmentProgram("Ground/fs", false);
pass->setDepthWriteEnabled(false);
pass->setDepthFunction(Ogre::CMPF_LESS);
pass->setCullingMode(Ogre::CULL_NONE);
pass->setColourWriteEnabled(true);
pass->setLightingEnabled(true);
pass->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
Ogre::TextureUnitState* tus = pass->createTextureUnitState();
tus->setTextureFiltering(Ogre::TFO_NONE);
tus->setTextureAddressingMode(Ogre::TextureUnitState::TAM_CLAMP, Ogre::TextureUnitState::TAM_CLAMP, Ogre::TextureUnitState::TAM_CLAMP);
tus->setTexture(tmgr->getByName(mColorMapTextureName));

mMaterial->prepare();
mMaterial->load();

Fragment shader:

#version 130
precision mediump float;

uniform sampler2D colormaps;
uniform float alpha;

varying vec2 texCoord;

void main()
{
    vec4 color = texture2D(colormaps, texCoord);
    gl_FragColor = vec4(color.xyz, color.a * alpha);
}

Vertex shader:

#version 130

precision mediump float;

uniform mat4 mvp_matrix;
uniform float activeView;
uniform vec2 colormapsScale;

attribute vec4 vertex;        
attribute vec3 normal;        

varying vec2 texCoord;

void main()                    
{
    gl_Position = mvp_matrix * vertex;

    float slot = 1.0;

    texCoord.x = (slot + 0.5)       * colormapsScale.s;
    texCoord.y = (activeView + 0.5) * colormapsScale.t;
}

Then to update entity's mesh I simply call the mesh method addTriangle() with the new triangle vertex coordinates as arguments.

\$\endgroup\$
2
  • \$\begingroup\$ There are many routes you could be taking to produce this image, each with its own potential glitches. Can you walk us through the steps in your rendering, including the models & textures you're using, or a minimal sample of the relevant code? \$\endgroup\$
    – DMGregory
    Sep 25, 2017 at 14:00
  • \$\begingroup\$ Added some code extract. \$\endgroup\$
    – EzeEst
    Sep 25, 2017 at 15:14

1 Answer 1

1
\$\begingroup\$

Luckily the fix was quite simple: increase shader precision. On both shader files I changed the line

precision mediump float;

by this one

precision highp float;

And everything was drawn correctly on screen.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .