Almamu / linux-wallpaperengine

Wallpaper Engine backgrounds for Linux!
GNU General Public License v3.0
1.67k stars 61 forks source link

GLSL shader failed to compile #31

Closed 4kanesora closed 3 years ago

4kanesora commented 4 years ago

Hi, I have succeed build wallpaper engine executable, but when I tried to lunch it with ./wallengine --pkg ~/2113366598, it gives me the error:

Irrlicht Engine version 1.8.4
Linux 5.7.0-kali3-amd64 #1 SMP Debian 5.7.17-1kali1 (2020-08-26) x86_64
No FSAA available.
Using renderer: OpenGL 3.1
llvmpipe (LLVM 10.0.1, 256 bits): VMware, Inc.
OpenGL driver version is 1.2 or better.
GLSL version: 1.4
LOAD TEX: This is a PNG: materials/masks/waterripple_mask_ee0d9bbc6d0516b8583c8fb3e841485c0b7ec4e8.tex
Loaded texture: materials/masks/waterripple_mask_ee0d9bbc6d0516b8583c8fb3e841485c0b7ec4e8.tex
LOAD TEX: This is an ARGB8: materials/effects/waterripplenormal.tex
Loaded texture: materials/effects/waterripplenormal.tex
LOAD TEX: This is an ARGB8: materials/util/noise.tex
Loaded texture: materials/util/noise.tex
LOAD TEX: This is a PNG: materials/masks/pulse_mask_681d95af21112ea41fc4cd51aa49d9c553ef1173.tex
Loaded texture: materials/masks/pulse_mask_681d95af21112ea41fc4cd51aa49d9c553ef1173.tex
ERROR PRE-COMPILING SHADER
racter
GLSL shader failed to compile
0:1(1): error: syntax error, unexpected end of file

LOAD TEX: This is a JPG: materials/75.tex
Loaded texture: materials/75.tex

The related background file I have attached. 2113366598.zip My host graphic card is intel HD650 which support opengl to 4.4, but vmware only support max to 3.3 for windows. So maybe I had to upgrade opengl to 3.3? here is the glxinfo

OpenGL vendor string: VMware, Inc.
OpenGL renderer string: llvmpipe (LLVM 10.0.1, 256 bits)
OpenGL core profile version string: 3.3 (Core Profile) Mesa 20.1.7
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.1 Mesa 20.1.7
OpenGL shading language version string: 1.40
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.1 Mesa 20.1.7
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10
OpenGL ES profile extensions:
Almamu commented 4 years ago

Most likely the issue is with the pre-compiler here, have you tried with the "data-separation" branch? That one has more advanced support for shaders and should yield better results.

4kanesora commented 4 years ago

I have tried the branch you mentioned, but things goes even worse, it not show anything and crash immediately. But it do print more logs, I will put them here so you can debug easier.

Irrlicht Engine version 1.8.4
Linux 5.8.12-arch1-1 #1 SMP PREEMPT Sat, 26 Sep 2020 21:42:58 +0000 x86_64
No FSAA available.
Using renderer: OpenGL 4.6
Mesa Intel(R) UHD Graphics 630 (CFL GT2): Intel
OpenGL driver version is 1.2 or better.
GLSL version: 4.6
/home/arch/linux-wallpaperengine/build/2113366598/project.json
scene.json
scene.json
models/75.json
materials/75.json
effects/waterripple/effect.json
materials/effects/waterripple.json
effects/pulse/effect.json
materials/effects/pulse.json
particles/presets/spark.json
particles/presets/fog2.json
particles/presets/fog2.json
particles/presets/dust_motes_0.json
particles/presets/leaves5.json
Loaded texture: materials/75.tex
shaders/genericimage2.vert
shaders/genericimage2.frag
shaders/common_fragment.h
======================== COMPILED SHADER shaders/genericimage2.frag ========================
#version 120
#define highp
#define mediump
#define lowp
#define mul(x, y) (y * x)
#define frac fract
#define CAST2(x) (vec2(x))
#define CAST3(x) (vec3(x))
#define CAST4(x) (vec4(x))
#define CAST3X3(x) (mat3(x))
#define saturate(x) (clamp(x, 0.0, 1.0))
#define texSample2D texture2D
#define texSample2DLod texture2DLod
#define texture2DLod texture2D
#define atan2 atan
#define ddx dFdx
#define ddy(x) dFdy(-(x))
#define GLSL 1

#define version 2

// begin of included from file common_fragment.h

///////////////////////////////////////////
// Decompress normal from texture
///////////////////////////////////////////
vec3 DecompressNormal(vec4 normal)
{
    // Hack to compensate for DXT compression
#if COMPRESSEDNORMAL
    normal.yw = normal.yw * 2.0 - vec2(0.965, 1.0);
#else
    normal.yw = normal.yw * 2.0 - 1.0;
#endif
    // To support DXT3/DXT1
    //normal.x = normal.x * normal.a;
    normal.z = sqrt(1.0 - normal.w * normal.w - normal.y * normal.y);
    return normal.wyz;
}

vec4 DecompressNormalWithMask(vec4 normal)
{
    normal.xw = normal.wx;
    // Hack to compensate for DXT compression
#if COMPRESSEDNORMAL
    normal.xy = normal.xy * 2.0 - vec2(0.965, 1.0);
#else
    normal.xy = normal.xy * 2.0 - 1.0;
#endif
    normal.z = sqrt(1.0 - normal.x * normal.x - normal.y * normal.y);
    return normal;
}

///////////////////////////////////////////
// Material attributes
///////////////////////////////////////////
float ComputeMaterialSpecularPower(const float roughness, const float metallic)
{
    return (1.01 - roughness) * mix(400.0, 250.0, metallic);
}

float ComputeMaterialSpecularStrength(const float roughness, const float metallic)
{
    return ( 0.5 + metallic * 0.5 ) * ( 1.0 - roughness * 0.9 );
}

///////////////////////////////////////////
// Compute lighting
///////////////////////////////////////////
vec3 ComputeLight(const vec3 normal, const vec3 lightDelta, const vec3 color, const float radius)
{
    float lightDistance = length(lightDelta);
    float lightAttn = saturate((radius - lightDistance) / radius);
    return color * (saturate(dot(lightDelta / lightDistance, normal))) * lightAttn * lightAttn;
}

vec3 ComputeLightSpecular(const vec3 normal, const vec3 lightDelta, const vec3 color, const float radius, const vec3 viewDir, const float specularPower, const float specularStrength, const float halfLambert, const float metallicTerm, inout vec3 specularResult)
{
    float lightDistance = length(lightDelta);
    float lightAttn = saturate((radius - lightDistance) / radius);
    vec3 lightDir = lightDelta / lightDistance;
    float specular = max(0.0, dot(normalize(viewDir + lightDir), normal));
    specularResult += pow(specular, specularPower) * specularStrength * lightAttn * color;
    float lightDot = dot(lightDir, normal);
    float halfLambertLight = lightDot * 0.5 + 0.5;

    lightDot = mix(lightDot, halfLambertLight, halfLambert);
    float rim = metallicTerm * 2.0;
    rim = pow((1.0 - saturate(dot(normal, viewDir))) * pow(halfLambertLight, 0.25), 6.0 - rim) * rim;

    return color * (saturate(lightDot) + rim) * lightAttn * lightAttn;
}

///////////////////////////////////////////
// Texture lookups
///////////////////////////////////////////
#define FORMAT_RG88 8
#define FORMAT_R8 9
float ConvertSampleR8(vec4 sample)
{
#if HLSL_SM30
        return sample.a;
#else
        return sample.r;
#endif
}

vec4 ConvertTexture0Format(vec4 sample)
{
#if TEX0FORMAT
    if (TEX0FORMAT == FORMAT_RG88)
    {
#if HLSL_SM30
        return sample.rrra;
#else
        return sample.rrrg;
#endif
    }

    if (TEX0FORMAT == FORMAT_R8)
    {
#if HLSL_SM30
        return vec4(1, 1, 1, sample.a);
#else
        return vec4(1, 1, 1, sample.r);
#endif
    }
#endif
    return sample;
}

// end of included from file common_fragment.h

uniform sampler2D g_Texture0; // {"material":"Albedo"}

#ifndef VERSION
uniform float g_Brightness; // {"material":"Brightness","label":"ui_editor_properties_brightness","default":1,"range":[0,2]}
uniform float g_UserAlpha; // {"material":"Alpha","label":"ui_editor_properties_alpha","default":1,"range":[0,1]}
#else
uniform float g_Alpha;
uniform vec3 g_Color;
#endif

varying vec2 v_TexCoord;

void main() {
    vec2 texCoord = v_TexCoord.xy;
    vec4 color = texSample2D(g_Texture0, texCoord);

#ifndef VERSION
    color.rgb *= g_Brightness;
    color.a *= g_UserAlpha;
#else
    color.rgb *= g_Color;
    color.a *= g_Alpha;
#endif

    gl_FragColor = color;
}

shaders/common_vertex.h
terminate called after throwing an instance of 'std::runtime_error'
  what():  ERROR PRE-COMPILING SHADERExpected an array but found nothing
Almamu commented 3 years ago

With this branch the compilation has gone better. It crashes because there's an error in the shader pre-compiler, expecting something that is not always there, this is so It's easier to debug and fix issues.

#ifndef VERSION
uniform float g_Brightness; // {"material":"Brightness","label":"ui_editor_properties_brightness","default":1,"range":[0,2]}
uniform float g_UserAlpha; // {"material":"Alpha","label":"ui_editor_properties_alpha","default":1,"range":[0,1]}
#else
uniform float g_Alpha;
uniform vec3 g_Color;
#endif

Those two uniforms are not being properly parsed, I'll take a look at the background on the data-separation branch and fix the issue, that should get the background to at least show. There's no audio processing options implemented yet, so part of the background won't work properly. I'll keep you updated.

Almamu commented 3 years ago

The background should start up now with the latest commit (e89e80c2b8a4734dd935e6bf6a6d50b023a77158). Take in mind the audio processing features are not supported yet, so the background will most likely look static.