When i render some basic terrain with lwjgl and move the my mesh there are some weird artifacts, this only happens with windows 8 and a nvidia gpu.
On my old macbook the exact same code (except for natives) works fine.
https://www.youtube.com/watch?v=_Jae2Zf7IkQ
I already tried to render on a texture but it didnt change.
Has this something to do with my code or is it a bug with the nvidia drivers.
fragment shader
#version 400core
in vec2 texCords;
in vec3 surfaceNormal;
in vec3 toLight;
in vec3 toCamera;
in vec3 position_out;
in float distanceToCamera_out;
uniform vec3 diffuseLightColor;
uniform vec3 specularLightColor;
out vec4 out_Color;
void main(void){
vec3 unitNormal = normalize(surfaceNormal);
vec3 unitToLight = normalize(toLight);
//temporary
vec4 color = vec4(1,1,1,1);
//diffuse light
float diffuseFactor = max(dot(unitNormal, unitToLight),0);
vec3 diffuse = diffuseLightColor * diffuseFactor;
//specular light
vec3 reflected = reflect(-unitToLight,unitNormal);
float specularFactor = max(dot(reflected,normalize(toCamera)),0);
specularFactor = pow(specularFactor,50); //dampening
vec3 specular = specularLightColor * specularFactor;
//final light
vec3 finalLight = diffuse + specular;
//final color
out_Color = color * vec4(finalLight,1);
}
render function
public void render(Entity entity) {
TexturedModel texModel=entity.getModel();
RawModel model=texModel.getModel();
ModelTexture texture = texModel.getTexture();
GL13.glActiveTexture(GL13.GL_TEXTURE0);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getBaseId());
GL30.glBindVertexArray(model.getVaoId());
GL20.glEnableVertexAttribArray(0);
GL20.glEnableVertexAttribArray(1);
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, model.getVboiId());
shader.loadTransformation(Maths.createTransformationMatrix(entity.getPosition(), entity.getRx(), entity.getRy(), entity.getRz(), entity.getScale()));
GL11.glDrawElements(GL11.GL_TRIANGLES, model.getVertexCount(), GL11.GL_UNSIGNED_INT, 0);
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
GL20.glDisableVertexAttribArray(0);
GL20.glDisableVertexAttribArray(1);
GL30.glBindVertexArray(0);
}