• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[SOLVED] uniform float arrays GLSLES

Hi. I'm trying to get a uniform array of floats into my GLSLES shader, but all I'm getting is sytax error warnings:

How come the following doesn't work?

uniform float some_array[8];

GMS 1.4.1763
 

Mool

Member
Its correct.

I use it like you:

uniform float time[8];
uniform float posX[8];
uniform float posY[8];
uniform float amount;
uniform vec2 screen;

There is a other error in your code...
 
If I remove that one line though, then the syntax error goes away.

Plus the only other lines above it are:

attribute vec2 in_Position; //[0 = back, 1 = front], bullet index
//--------------------------------------------------------------
varying vec4 v_vColour;
//--------------------------------------------------------------
uniform float time;

EDIT

here's the whole real vertex shader. Can you spot the error? The compiler is saying a syntax error is on line 7. I tried switching to using arrays of vectors in case an array of floats alone wasn't working for some reason.

Code:
//--------------------------------------------------------------
    attribute vec2 in_Position;  //[0 = back, 1 = front], bullet index
    //--------------------------------------------------------------      
    varying vec4 v_vColour;
    //--------------------------------------------------------------
    uniform float time;
    uniform vec2 bullet_position[64];  // <---- line 7
    uniform vec2 bullet_speed[64];
    uniform vec2 bullet_lifetime[64];
    uniform vec3 bullet_colour[64];
    //--------------------------------------------------------------
    uniform mat4 current_matrix;
    uniform mat4 previous_matrix;
    //--------------------------------------------------------------
    void main() {
        int _index = int(in_Position.y);
        //--------------------------------------------------------------
        vec2 _initial_position = bullet_position[ _index ];
        //--------------------------------------------------------------
        vec2 _speed = bullet_speed[ _index ];
        //--------------------------------------------------------------
        float _time_alive = time - bullet_lifetime[ _index ].x;
        //--------------------------------------------------------------
        vec4 _front_position = current_matrix * vec4( _initial_position + _speed * _time_alive, 0.0, 1.0 );
        vec4 _back_position = previous_matrix * vec4( _initial_position + _speed * (_time_alive - 1.0), 0.0, 1.0);
        gl_Position = mix( _back_position, _front_position, in_Position.x );
        //--------------------------------------------------------------
        v_vColour = vec4( bullet_colour[ _index ], 1.0 );
    }
//--------------------------------------------------------------
 
Last edited:
I still haven't made any progress solving this problem. Someone has got to know what's going on. Do I have to enable arrays somehow? Are arrays simply not avialable in GLSLES?
 
Oh god, this is embarrassing. The error was actually in the fragment shader, not in the vertex shader as I was assuming, and the error was the result of a missing semicolon.

The lesson here is to read error messages very carefully. Also a good idea, post the exact wording of your error message when asking for help.

:oops: <-- egg on my face.
 
Top