This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Shadows with alpha test (discard) not working on Galaxy Note 4 SM-N910U, ARM Mali-T760 MP6

Is this the right place to report problems with the GPU Driver?

I'm an engine developer, just added GLES3 support to my engine and I've noticed that on Android Galaxy Note 4 SM-N910U, ARM Mali-T760 MP6, the alpha tested shadows aren't working correctly.
I suspect OpenGL Driver fault, as the same code works fine on iOS, Windows, Mac, Linux, etc.

Shadows that don't use alpha-test (discard) work correctly, but those that use discard, don't display at all.

Shader for alpha-tested materials is below:

Vertex Shader:
#version 300 es
#ifdef GL_ES
#define LP lowp
#define MP mediump
#define HP highp
precision HP float;
precision HP int;
#else
#define LP
#define MP
#define HP
#endif
#if __VERSION__>=300
#define attribute in
#define varying out
#endif
varying vec4 GL_Tex0;
varying vec4 GL_Tex1;
varying vec4 GL_Tex2;
struct VS_PS{
vec3 _pos9;
vec3 _nrm2;
vec2 _tex3;
};
VS_PS _O1;
vec3 _TMP225;
vec4 _m0228[3];
vec4 _TMP344;
attribute vec4 ATTR0;
attribute vec4 ATTR3;
vec3 _TMP348;
vec3 _TMP349;
vec3 _TMP350;
vec3 _TMP351;
vec4 _TMP352;
vec4 _TMP353;
vec4 _TMP354;
vec4 _TMP355;
uniform vec4 ProjMatrix[4];
uniform vec4 ViewMatrix[180];
void main()
{
vec4 _O_vtx;
_m0228[0]=ViewMatrix[(3*gl_InstanceID+0)];
_m0228[1]=ViewMatrix[(3*gl_InstanceID+1)];
_m0228[2]=ViewMatrix[(3*gl_InstanceID+2)];
_TMP348.x=_m0228[0].x;
_TMP348.y=_m0228[1].x;
_TMP348.z=_m0228[2].x;
_TMP349.x=_m0228[0].y;
_TMP349.y=_m0228[1].y;
_TMP349.z=_m0228[2].y;
_TMP350.x=_m0228[0].z;
_TMP350.y=_m0228[1].z;
_TMP350.z=_m0228[2].z;
_TMP351.x=_m0228[0].w;
_TMP351.y=_m0228[1].w;
_TMP351.z=_m0228[2].w;
_TMP225=ATTR0.x*_TMP348+ATTR0.y*_TMP349+ATTR0.z*_TMP350+_TMP351;
_O1._pos9=_TMP225;
_O1._tex3=ATTR3.xy;
_TMP352.x=ProjMatrix[0].x;
_TMP352.y=ProjMatrix[1].x;
_TMP352.z=ProjMatrix[2].x;
_TMP352.w=ProjMatrix[3].x;
_TMP353.x=ProjMatrix[0].y;
_TMP353.y=ProjMatrix[1].y;
_TMP353.z=ProjMatrix[2].y;
_TMP353.w=ProjMatrix[3].y;
_TMP354.x=ProjMatrix[0].z;
_TMP354.y=ProjMatrix[1].z;
_TMP354.z=ProjMatrix[2].z;
_TMP354.w=ProjMatrix[3].z;
_TMP355.x=ProjMatrix[0].w;
_TMP355.y=ProjMatrix[1].w;
_TMP355.z=ProjMatrix[2].w;
_TMP355.w=ProjMatrix[3].w;
_TMP344=_TMP225.x*_TMP352+_TMP225.y*_TMP353+_TMP225.z*_TMP354+_TMP355;
_O_vtx=_TMP344;
GL_Tex1.xyz=_O1._nrm2;
gl_Position=_TMP344;
GL_Tex2.xy=ATTR3.xy;
GL_Tex0.xyz=_TMP225;
}


Pixel Shader:
#version 300 es
#extension GL_EXT_shader_texture_lod:enable
#extension GL_EXT_shadow_samplers:enable
#ifdef GL_ES
#define LP lowp
#define MP mediump
#define HP highp
precision HP float;
precision HP int;
precision HP sampler2D;
#if __VERSION__<300
#define gl_InstanceID 0
#endif
#else
#define LP
#define MP
#define HP
#endif
#if __VERSION__>=300
#define texture2D texture
#define varying in
#else
#endif
varying vec4 GL_Tex2;
struct MaterialClass{
vec4 _color;
vec4 _ambient_specular;
vec4 _sss_glow_rough_bump;
vec4 _texscale_detscale_detpower_reflect;
};
float _c0079;
uniform MaterialClass Material;
uniform sampler2D Col;
void main()
{
_c0079=texture2D(Col,GL_Tex2.xy).w+(false?float(Material._color.w)*5.00000000E-001-1.00000000E+000:float((Material._color.w-1.00000000E+000)));
if(_c0079<0.00000000E+000){
discard;
}
}

Expected result from Windows:

What I'm getting on Galaxy Note 4:

The tree model is composed of 2 materials (trunk that has no "discard", and the leaves that use the "discard" shader). Both shaders are shadow shaders, don't output any color, their only purpose is write to the depth buffer.

Here is the link to the APK that you can test by yourself:

www.dropbox.com/.../Application 3D.7z

Parents
  • Hi Esenthel,

    Thanks for reporting the issue. I have been able to reproduce it on a Note4 internally and seems this issue has already been fixed in newer versions of the driver. I found though some strange issue with your application where black lines straight lines are visible across the screen. I have run your sample with the Mali Graphics Debugger and found there are several errors from the API during initialization and also runtime. Also, in the RenderPass 3 you are using a texture as depth attachment but at the same time you are passing the same texture as a texture object to the shader. That is not allowed by the OpenGL ES spec.

    Also to reduce the number of drawcalls each frame would it be better if you use multiple FBOs initialized at the beginning and use glClear directly at the beginning of each renderpass (this is important since avoids reading back previous content).

    If you can create a smaller sample with only the Cascade shadow map generation I can try to see if there is a possible walkaround for the issue in  the driver version you have.

    Regards,
    Daniele

Reply
  • Hi Esenthel,

    Thanks for reporting the issue. I have been able to reproduce it on a Note4 internally and seems this issue has already been fixed in newer versions of the driver. I found though some strange issue with your application where black lines straight lines are visible across the screen. I have run your sample with the Mali Graphics Debugger and found there are several errors from the API during initialization and also runtime. Also, in the RenderPass 3 you are using a texture as depth attachment but at the same time you are passing the same texture as a texture object to the shader. That is not allowed by the OpenGL ES spec.

    Also to reduce the number of drawcalls each frame would it be better if you use multiple FBOs initialized at the beginning and use glClear directly at the beginning of each renderpass (this is important since avoids reading back previous content).

    If you can create a smaller sample with only the Cascade shadow map generation I can try to see if there is a possible walkaround for the issue in  the driver version you have.

    Regards,
    Daniele

Children