[fixed]android ogles2 shader problem fixed

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
feelthat
Posts: 194
Joined: Sat Feb 02, 2013 5:27 am

[fixed]android ogles2 shader problem fixed

Post by feelthat »

//in COGLES2Solid.vsh

//for (i = 0; i < int(uLightCount); i++) //will failed on some android system
{
if (uLightType == 0)
pointLight(i, Position, Normal, Ambient, Diffuse, Specular);
}

//please use this way~~~
for (i = 0; i < int(MAX_LIGHTS); i++)
{
if( i >= uLightCount )
break;

if (uLightType == 0)
pointLight(i, Position, Normal, Ambient, Diffuse, Specular);
}
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: android ogles2 shader problem fixed

Post by CuteAlien »

Thanks for the report. Seems it's not just in COGLES2Solid.vsh, but same bug is also in COGLES2Refelction2Layer.vsh, , COGLES2Solid2.vsh and COGLES2SphereMap.vsh.
Some cards accept it, but it's not really valid in GLSL it seems. Will fix later on (when I'm back on a system where I can test Android).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: android ogles2 shader problem fixed

Post by CuteAlien »

Fixed in r5117.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: [fixed]android ogles2 shader problem fixed

Post by hendu »

Unrelated to this, but are you aware of the command-line shader checker?

git clone https://github.com/clbr/glsl-optimizer.git
cd glsl-optimizer/src/glsl
make
cd ../../contrib/glslopt
make
sudo cp glslopt /usr/bin

I regularly use it to check desktop GLSL shaders, but it also supports GLES 2 and 3.
Usage: glslopt <-f|-v> <input shader> [<output shader>]
-f : fragment shader (default)
-v : vertex shader
-1 : target OpenGL (default)
-2 : target OpenGL ES 2.0
-3 : target OpenGL ES 3.0

If no output specified, output is to [input].out.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: [fixed]android ogles2 shader problem fixed

Post by CuteAlien »

Didn't know it - thanks. Also for the make instructions (as it didn't build otherwise - although https://github.com/aras-p/glsl-optimizer which seemed the original got a little further on building before it failed).

But won't use it on Irrlicht-shaders - because it does remove comments and makes the code harder to read. And Irrlicht shaders aren't really meant to be used like that in a time-critical game anyway. They do everything and have to reduce for a real game.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: [fixed]android ogles2 shader problem fixed

Post by hendu »

I meant use it as a checker, not as an optimizer - delete the .out optimized shaders. It will bail out if you have invalid GLSL.

Very handy when editing shaders, speedy test cycles.
Post Reply