OpenGL, glDrawElementsInstanced behave differently on NVIDIA GPU than AMD

I have an AMD GPU on my desktop, AMD HD 5770. I have been working on a project on my desktop for over a year now. On stage, I have grassy grasses and trees. As it should, everything works fine on the desktop.

I recently copied my code to my laptop which has an nVidia GPU. Here's the problem: the grass renders fine, but when it comes to trees, they get rendered in the same position, i.e. (0,0,0,0). So, for example, if I want to display 10 trees in different places, on AMD they are displayed in their respective positions, but on nVidia they are all displayed at the origin.

Here is what I made sure,
* First I checked if the positions are being created correctly, the answer is YES.
 * I have checked if the layout is configured correctly.
 * I have verified that the glVertexAttribPointer parameters are correct.  
* I have made sure that I am sending data to the correct layout variable.
* Installed "fresh" nVidia drivers.

Here is the code for instancing and shaders respectively.

    //setting up the instanced buffer.
    glBindBuffer(GL_ARRAY_BUFFER, iVBO);
    glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0); 
    glEnableVertexAttribArray(0); 
    glVertexAttribDivisor(0 ,1);

      


Vertex shader -

        mat4 m, m1;
        m = m4_model;

        vec4 pos = in_model_v4instancedPositions;
        //translate..
        m1[0] = vec4(i_scale, 0.0, 0.0, 0.0);
        m1[1] = vec4(0.0, i_scale, 0.0, 0.0);
        m1[2] = vec4(0.0, 0.0, i_scale, 0.0);
        m1[3] = vec4(pos.x, pos.y, pos.z, 1.0);
        m*=m1;

        mat4 mv = m4_view * m;

        //mat4 light_mvp = u_bias_proj_view_matrix *get_shadow_model();
        light_vertex_position = u_m4MVP_light * vec4(in_model_v3Position,1.0);
        vs_lightPosition=vec3(u_m4lightMatrix*vec4(uv3inLightPosition,1.0));

        vs_model_v2UV      = in_model_v2UV;
        vs_out.texcoord    = vs_model_v2UV;
        vs_model_v3Normal  = normalize(u_m3NormalMatrix * in_model_v3Normal);
        vs_model_v3Tangent = u_m3NormalMatrix * in_model_v3Tangent; 
        vs_model_v3Color   = in_model_v3Color;
        vs_model_v3Position= in_model_v3Position;

        gl_Position = m4_projection * mv * (vec4(in_model_v3Position,1.0));

      

I am out of ideas as the same code works great on AMD.

+3


source to share





All Articles