Skip to content

GetUniformLocation() returns -1 on Nvidia #2154

Closed Answered by bamfbamf
bamfbamf asked this question in Q&A
Discussion options

You must be logged in to vote

I found the problem. It seems that NVidia is optimizing out so hard, that even despite that this function:

vec2
ComputeDepth(vec3 position, float near_plane, float far_plane, mat4 view, mat4 projection) 
{
    // Raw depth value of the fragment position in clip space.
    vec4 clipSpacePosition = projection * view * vec4(position.xyz, 1.0);
    float depth = (clipSpacePosition.z / clipSpacePosition.w);

    // Linear depth of the fragment position in view space.
    float shiftedDepth = depth * 2.0 - 1.0; // Put back between -1 and 1.
    float linearDepth = (2.0 * near_plane * far_plane) / (far_plane + near_plane - shiftedDepth * (far_plane - near_plane)); // Get linear value between 0.0…

Replies: 10 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Perksey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
bug Something isn't working
3 participants
Converted from issue

This discussion was converted from issue #2153 on April 22, 2024 23:36.