Pixel Three - Shader code problems

So I keep getting this error on a scene that uses a shader with a texture sampler on my pixel three:

Error: FRAGMENT SHADER ERROR: 0:38: 'sampler2D' : requires extension GL_EXT_gpu_shader5 to be enabled 

I have tried to include that extension but it does not seem to work.

Kinda confused here, as I would figure a pixel three should have some decent support.

@Evgeni_Popov you usually know whats going on with shaders!

https://playground.babylonjs.com/#ARLADE#11

I think I figured it out now… I gotta get rid of the texture array reference that uses a dynamic index.

Ew… its not the cleanest work around but I am going to use a #define placeholder and then do a regex replace and add in a switch that will handle the layer loop.

for(int i=0; i<2; i++){
  float frameID;
        switch(i){
        case 0 : frameID = texture(tileMaps[0], (tileID + 0.5) / stageSize, 0.).x;
        break;    
        case 1 : frameID = texture(tileMaps[1], (tileID + 0.5) / stageSize, 0.).x;
        break;
        }

Why that?
what about unrolling like creating a function that accepts a frameID and call it twice:

myFunc(0);
myFunc(1);

I got it actually :slight_smile: the switch solution adds 1 more calc per frame, but really does nothing to the performance.

I was looking initially at doing it how you just suggested, but it looks like the switch solution ends up fitting into the code structure a little better.

I’ll be submitting a PR to fix the SpriteMap here soon.

1 Like

Nice backgrounds, it reminds me of old Prince of Persia game for some reason :slight_smile:

Ayyy it works!

2 Likes

HEY! congrats

I at first tried adding

#extension GL_EXT_gpu_shader5 : enable

to top of fragment shader and kept getting the same error.
So the extension was there but it wasn’t using it.
Eventually I realised that I had this set at the top of the my fragment shader:

#version 300 es

When I changed this to

#version 310 es

it started working fine with the indices passed into the shader from uniforms.

Hope this helps someone.