Page 2 of 2

Re: Fickering issues on some Android devices

Posted: Tue Dec 27, 2022 1:26 pm
by Ats
How are you calculating the screen position of your vertices in your vertex shader? Simply "modelViewProjectionMatrix * vec4(position, 1.0)"? Or are you using multiple matrix multiplications?
Here's what I'm doing:

Code: Select all

uniform mat4 modelViewMatrix;
uniform mat4 modelViewProjectionMatrix;
uniform mat3 normalMatrix;

attribute vec4 position, color; // vertex position & color
attribute vec3 normal;   // vertex normal

varying vec3 N;
varying vec3 v;
varying vec4 v_Color;

void main(void)
{
  v = vec3(modelViewMatrix * position);
  N = normalize(normalMatrix * normal);
  v_Color = color;
  gl_Position = modelViewProjectionMatrix * position;
}
Is the vec4(position, 1.0) necessary?

I'm doing almost nothing with fragment shaders. It displays the things at the correct positions and colors, so I'm happy with that. Coding shaders isn't exactly simple :lol:

Re: Fickering issues on some Android devices

Posted: Tue Dec 27, 2022 2:15 pm
by Kjell
Hi Ats,
Ats wrote: Tue Dec 27, 2022 1:26 pmHere's what I'm doing
Alright, that's perfectly fine & normal.
Ats wrote: Tue Dec 27, 2022 1:26 pmIs the vec4(position, 1.0) necessary?
Nope, that's not necessary. Internally ZGE uses vec3 for vertex positions, but when you define the attribute as vec4 in your vertex shader it automatically fills the position.w component with a value of 1.

K