Hello I don’t understand why my mesh keeps flickering when I just set the gl_position.y
shader code :
attribute vec3 inPosition; // objectSpace position
attribute vec4 inTexCoord;
uniform mat4 g_WorldViewProjectionMatrix;
uniform mat4 g_WorldMatrix;
varying vec4 vertexPosition;
varying vec4 texCoord;
varying float Horizon;
/*
-
vertex shader template
/
void main() {
vec4 position = vec4(inPosition,1.0);
texCoord = inTexCoord;
vertexPosition = g_WorldMatrixposition;
gl_Position = g_WorldViewProjectionMatrix * position;
dist = Horizon-gl_Position.z;
gl_Position.y -= distdist0.01;
}
I had a problem similar to this a while back. Setting the mesh bounds like so:
[java]
mesh.setBound(new BoundingSphere(mesh_width+1000f, new Vector3f(0,0,0)));
[/java]
may help…
1 Like
pspeed
3
@okelly4408 said:
I had a problem similar to this a while back. Setting the mesh bounds like so:
[java]
mesh.setBound(new BoundingSphere(mesh_width+1000f, new Vector3f(0,0,0)));
[/java]
may help…
…might as well just turn off culling for the Geometry then.
pspeed
4
To the OP, you may want to be more specific about what you mean when you say “flickering”.
Also… this:
dist = Horizon-gl_Position.z;
gl_Position.y -= distdist0.01;
…may not be doing what you think it’s doing depending on what you are passing for Horizon. gl_Position is in projection space at this point.
Thanks pspeed for taking the time to answer some noobs question, I am still trying to figure out the shaders :)!
I think the problem was related to the Graphic card because when I switched computer with a more recent graphic card everything worked out correctly 