Jump to content

  • Log In with Google      Sign In   
  • Create Account

GLSL num of uniform variables used in vertex shader


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 smitty1276   Members   -  Reputation: 560

Like
0Likes
Like

Posted 27 January 2011 - 04:16 PM

Setting aside the quality of the code, etc., can anyone explain to me how this vertex shader code would fail to link with the this error? "Error: uniform variables in vertex shader do not fit in 251 vectors."

The excerpt below contains all of the declarations at the top of the source... I'm only counting 120-130 vectors in the worst possible case (depending on how the implementation stores them I guess). What am I missing?

// lights
const int maxLights = 8;


// attributes
attribute vec4 inPosition;
attribute vec4 inDiffuse;
attribute vec2 inTextureCoordinate;
attribute vec3 inNormal;


// uniforms
uniform mat4 ModelViewProjectionMatrix;
uniform mat4 NormalMatrix;
uniform mat4 TextureMatrix;


// the light uniform
uniform float lighting_enable;


struct LightSourceParams {
float light_enable;
vec4 light_ambient;
vec4 light_diffuse;
vec4 light_specular;
vec4 light_position;
vec4 light_spotDirection;
float light_spotExponent;
float light_spotCutoff;
float light_spotCosCutoff; // user must define
float light_constantAttenuation;
float light_linearAttenuation;
float light_quardraticAttenuation;
vec4 light_halfVector; // user must define ... halfVector=Eye-Light [not presicion]
};
uniform LightSourceParams LightSource[maxLights];



// material-uniforms
uniform vec4 material_emmision;
uniform vec4 material_ambient;
uniform vec4 material_diffuse;
uniform vec4 material_specular;
uniform float material_shininess;

// varyings
varying vec4 v_texcoord0;
varying vec4 v_outcolor;




Sponsor:

#2 karwosts   Members   -  Reputation: 840

Like
0Likes
Like

Posted 27 January 2011 - 04:28 PM


// uniforms
uniform mat4 ModelViewProjectionMatrix;
uniform mat4 NormalMatrix;
uniform mat4 TextureMatrix;


+3*4 = 12

// the light uniform
uniform float lighting_enable;

+1 = 13

struct LightSourceParams {
1 float light_enable;
2 vec4 light_ambient;
3 vec4 light_diffuse;
4 vec4 light_specular;
5 vec4 light_position;
6 vec4 light_spotDirection;
7 float light_spotExponent;
8 float light_spotCutoff;
9 float light_spotCosCutoff; // user must define
10 float light_constantAttenuation;
11 float light_linearAttenuation;
12 float light_quardraticAttenuation;
13 vec4 light_halfVector; // user must define ... halfVector=Eye-Light [not presicion]
};
uniform LightSourceParams LightSource[maxLights];

+13*8 (104) = 117

// material-uniforms
uniform vec4 material_emmision;
uniform vec4 material_ambient;
uniform vec4 material_diffuse;
uniform vec4 material_specular;
uniform float material_shininess;
+5 = 122

Hmm I'm not sure either, that's a strange message. Have you tried reducing the number of lights to see how many it will let you compile with? Not that that has to be the solution, but it would be something interesting to know.

What does your implementation report for GL_MAX_VERTEX_UNIFORM_COMPONENTS?
My Projects:
Portfolio Map for Android - Free Visual Portfolio Tracker
Electron Flux for Android - Free Puzzle/Logic Game

#3 smitty1276   Members   -  Reputation: 560

Like
0Likes
Like

Posted 27 January 2011 - 04:40 PM

Unfortunately, this implementation is on a particular device that I can't check at the moment... I'll definitely go try it later. I was hoping maybe there was some obvious thing that I was overlooking. ;) Thanks for looking at it.

EXPLANATION: I just realized that this wouldn't make much sense without explanation... I have an email with someone asking me why something isn't working on this device. I didn't just now run it myself and get the link error.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS