Cross-platform pixel shader not working on Linux
Posted: Fri Jul 05, 2019 9:02 am
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:
Here is the shader code:
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:
Any advice or direction would be greatly appreciated. If you've gotten this far thanks for reading!
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:
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;
}
]]
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