Cross-platform pixel shader not working on Linux

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
sundowns
Prole
Posts: 1
Joined: Fri Jul 05, 2019 7:06 am

Cross-platform pixel shader not working on Linux

Post by sundowns »

Hi there!

I have a simple diffuse lighting pixel-shader that works like a charm on several Windows PCs but causes wild graphical errors on my Linux laptop. Unfortunately I dont have access to another non-windows environment to see if this is specific to my machine or not. I've attached a Iove file and would greatly appreciate if somebody else developing on a Linux machine could run my game and let me know if they encounter the same thing. For reference I'm running Linux Mint 19 Cinnamon.

The shader just changes per-pixel colour & brightness according to distance to multiple light sources in the scene, but instead I'm getting a wild grainy effect like this:
Image

Here is the shader code:

Code: Select all

return [[
#define MAX_LIGHTS 32
struct Light {
    vec2 position;
    vec3 diffuse;
    number strength;
    number radius;
};

extern Light lights[MAX_LIGHTS];
extern number light_count;
extern number ambient_light;
extern number breath_offset; //This could be moved to the light struct and be per-light

vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords){
    vec4 pixel = Texel(texture, texture_coords);
    vec3 final_colour;
    for(int i = 0; i < light_count; i++)
    {
        Light light = lights[i];
        vec2 to_light = vec2(
            light.position.x - screen_coords.x,
            light.position.y - screen_coords.y
        );
        number brightness = clamp(1.0 - (length(to_light) / (lights[i].radius + breath_offset) / lights[i].strength), 0.0, 1.0);
        final_colour += lights[i].diffuse * brightness * lights[i].strength;
    }
    
    vec4 ambience = pixel * ambient_light;
    pixel.r = pixel.r * final_colour.x;
    pixel.g = pixel.g * final_colour.y;
    pixel.b = pixel.b * final_colour.z;
    return pixel + ambience;
  }
]]
This is my first foray into shaders so I'm not sure where to look. I printed out some info on my opengl version, not sure how helpful it is:

Code: Select all

> glxinfo | grep 'version'  

server glx version string: 1.4
client glx version string: 1.4
GLX version: 1.4
    Max core profile version: 4.5
    Max compat profile version: 3.0
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.2
OpenGL core profile version string: 4.5 (Core Profile) Mesa 18.2.8
OpenGL core profile shading language version string: 4.50
OpenGL version string: 3.0 Mesa 18.2.8
OpenGL shading language version string: 1.30
OpenGL ES profile version string: OpenGL ES 3.2 Mesa 18.2.8
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
Any advice or direction would be greatly appreciated. If you've gotten this far thanks for reading!
Attachments
grim gamers 2 dev.love
(158.61 KiB) Downloaded 91 times
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Cross-platform pixel shader not working on Linux

Post by raidho36 »

It would be more helpful if you specified the GPU used rather than glxinfo output. It could be a driver bug or, more likely, a hardware failure that only shows up in edge cases which your shader somehow triggers.

First of all, try unrolling the loop. Second, try using basic types instead of composite types (i.e. structs). Third, use vector operations instead of element by element operations (probably won't change anything but it's worth a shot). Finally, implement the effect without using a shader: a simple inverted color overlay with light patches rendered into it as sprites, applied with subtractive blending over the unlit scene will do the same exact job.
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: Cross-platform pixel shader not working on Linux

Post by pgimeno »

Works fine on my desktop Linux nVidia GeForce 210 (with proprietary 340.107 drivers).
Post Reply

Who is online

Users browsing this forum: No registered users and 38 guests