raysan5
Posts: 37
Joined: Tue Sep 30, 2014 4:44 pm
Location: Barcelona
Contact: Website

Problem with GLSL shader (driver for unroll)

Fri Oct 14, 2016 9:42 am

Hello,

I've got a problem with a shader I'm using internally on my library raylib (https://github.com/raysan5/raylib).

That shader is generic and computes lighting for up to 8 lights that can be omni, spot and directional. Shader works ok on most platforms (Windows, Linux, OSX, Android, HTML5) except on Raspberry Pi (I use a Raspberry Pi 1 Model B). Here it is my GLSL shader for reference: https://github.com/raysan5/raylib/blob/ ... tandard.fs

Shader just fails silently on my Pi, screens turns in white. No compile errors, no warnings.

After long investigation, it seems that shader fails due to the for-loop and branching, on my tests I got it working if I setup a specific lights number and type avoiding for-loop and branches... but I need it to be more generic.

Here it is a detailed explanation (last post): https://github.com/raysan5/raylib/issues/167

Could someone give me some tip/advice/help to solve this problem?

Many thanks! :)

User avatar
paddyg
Posts: 2332
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Problem with GLSL shader (driver for unroll)

Mon Oct 24, 2016 7:10 pm

@raysan5 can't give very specific help but I have found that the impact of conditional sections is very severe on shader performance. In the end, with pi3d, I had a series of different shaders rather than a general one, where code overlaps I have split it into includible sections which are gathered together prior to compiling. Unfortunately that makes the code very difficult to read!
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

raysan5
Posts: 37
Joined: Tue Sep 30, 2014 4:44 pm
Location: Barcelona
Contact: Website

Re: Problem with GLSL shader (driver for unroll)

Tue Oct 25, 2016 10:15 pm

Hi @paddyg, thank you very much for your answer! Just spoken with a couple of shader experts and all of them recommend me the same as you: avoid branches completely and generate multiple shaders instead of a general pourpose one. I will follow your recommendations. Thanks! :)

Return to “OpenGLES”