LWJGL Forum

Programming => OpenGL => Topic started by: Maykin53 on July 16, 2011, 04:47:24

Title: How am I exceeding GL_MAX_FRAGMENT_UNIFORM_COMPONENTS?
Post by: Maykin53 on July 16, 2011, 04:47:24
Hello everyone. I've run into a problem where the linking of my fragment shader is failing due to GL_MAX_FRAGMENT_UNIFORM_COMPONENTS being exceeded - yet based on that value and the uniforms that are in my shader, I do not see how that's possible.

In my test the uniform declaration part of my generated fragment shader source is:

uniform sampler2D tex;
uniform float ambientEnabled;
uniform vec3 eyeVector;
uniform float lightTypeList0[156];
uniform vec3 lightDirectionList0[156];
uniform vec3 lightLocationList0[156];
uniform vec3 lightColorList0[156];
uniform float lightDistanceRateList0[156];
uniform float lightAreaLimitList0[156];
uniform float lightShineList0[156];

By my calculations that comes to a total of 2026, but the value I'm getting back from:

System.out.println("Max Fragment Uniform Components: "+GL11.glGetInteger(GL20.GL_MAX_FRAGMENT_UNIFORM_COMPONENTS));

is:

Max Fragment Uniform Components: 2048



Can anyone please advise as to how I'm exceeding 2048 floats? Does the sampler2D count towards the limit? If so, by how much?
Title: Re: How am I exceeding GL_MAX_FRAGMENT_UNIFORM_COMPONENTS?
Post by: spasi on July 16, 2011, 08:54:31
The vec3s probably count as vec4s, that's why you go over the limit.
Title: Re: How am I exceeding GL_MAX_FRAGMENT_UNIFORM_COMPONENTS?
Post by: Maykin53 on July 16, 2011, 11:15:10
Thankyou! That was the problem - each of the uniforms was being considered a vec4 in terms of the component count. Now I've packed them together into vec4s and its working great.
Thanks again.