[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] uniform array of structs in latest chrome



According to the specification (http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf) it should work.

"The uniform qualifier can be used with any of the basic data types, or when declaring a variable whose
type is a structure, or an array of any of these."

The relevant conformance test (https://www.khronos.org/registry/webgl/sdk/tests/conformance/glsl/misc/shader-with-array-of-structs-uniform.html) passes on my machine. Does it pass for you?

On Mon, Oct 1, 2012 at 12:44 PM, Andrew <grizzly33@gmail.com> wrote:

Hi,

I'm not sure if this is a good place to write to, since the topics
here look more advanced, and this is basically just a beginner's
question, so feel free to redirect me.
I've had a small webgl demo that's been running fine for months, but I
noticed some time ago that in the chrome canary build, and now that I
updated to chrome 22 in that as well, it stopped working correctly. It
still works in Firefox.

Basically what the problem comes down to is that I have a uniform
array of struct objects that I use in my fragment shader to simply
draw balls, like this:

struct Ball {
        vec2 pos;
        float radius;
};
const int numOfBalls = 9;
uniform Ball u_balls[numOfBalls];

In the main I simply check if the current pixel (gl_FragCoord) belongs
to at least one of the balls and I set the color accordingly.

What happens is that one ball gets drawn to where it should, but the
rest are stuck in the upper left corner of the browser window. I
believe it's the first that is displayed, except when I set numOfBalls
to 1, then that's too in the upper left corner. It's strange that when
I capture a frame with WebGL Inspector, the uniform calls look
correct, like: uniform2fv("u_balls[0].pos", [x, y]), etc. (where x, y
is a float). Seems like radius is not being set either, but I have one
uniform variable for the color of all the balls, and that seems to get
passed along well, because the balls get that color.

Does anyone have any ideas what could have broken my demo? I can put
up a simplified version of the problem if this is not enough
information. Any help is greatly appreciated!

thanks,
Andrew

-----------------------------------------------------------
You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email:
unsubscribe public_webgl
-----------------------------------------------------------