Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7672981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:24:30+00:00 2026-05-31T16:24:30+00:00

I have a fragment shader with the following attributes: varying highp vec2 coordinate; precision

  • 0

I have a fragment shader with the following attributes:

varying highp vec2 coordinate;
precision mediump float;

uniform sampler2D videoframe;
uniform sampler2D videosprite;
uniform vec4 mask;
uniform float threshold;

I am getting their locations and later setting them:

_frame = glGetUniformLocation(_program, "videoframe");
_sprite = glGetUniformLocation(_program, "videosprite");
_mask = glGetUniformLocation(_program, "mask");
_threshold = glGetUniformLocation(_program, "threshold");

NSLog(@"%i %i %i %i", _frame, _sprite, _mask, _threshold);

However, the log reveals: 0 2 1 -1

From documentation, i see that -1 (the threshold uniform) means it failed. Why is it failing?
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:24:31+00:00Added an answer on May 31, 2026 at 4:24 pm

    The GLSL compiler can (and usually will) optimize away any uniforms and attributes that are not used in the shader. You can only query the locations of active uniforms, being the ones that are used in at least one branch of your shader.

    So I guess the threshold variable isn’t used anywhere in your shader code. But in this case you don’t need it’s value anyway, and setting a uniform value for location -1 will just do nothing. So you actually don’t have to worry about this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code in the Fragment Shader: precision lowp float; varying vec2
I have the following vertex shader : uniform mediump mat4 projMx; attribute vec2 a_position;
I'm using GLSL. I have a simple fragment shader here: uniform sampler2D backBuffer;, uniform
I have an GLSL geometry shader that looks like the following: #version 150 uniform
I have the following vertex shader: uniform mat4 uMVP; attribute vec4 aPosition; attribute vec4
I have two textures generated using a fragment shader. I want to be able
I try to access 2 textures in 1 fragment shader. For this I have
If I have a few Program3D objects (each with it's own Vertex-Shader and Fragment-Shader
I have a very basic fragment shader which I want to output 'gl_PrimitiveID' to
I have a vertex/fragment shader that draws a rectangle performing many calculations based on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.