y4my4my4m / kde-shader-wallpaper

KDE / Plasma - Shader Wallpaper plugin
GNU General Public License v3.0
224 stars 12 forks source link

ShaderCompiler.py fails to parse shader #44

Closed Shoshele closed 2 months ago

Shoshele commented 2 months ago

When trying to add a shader to the plasma6 version, running ShaderCompiler.py fails with the error message:

QSpirvCompiler: Failed to parse shader
Shader baking failed: ERROR: package/contents/ui/Shaders/ConvertMe/red bubbles 3.frag:3: 'ubuf' : undeclared identifier  
ERROR: package/contents/ui/Shaders/ConvertMe/red bubbles 3.frag:3: 'iResolution' : vector swizzle too long  
ERROR: package/contents/ui/Shaders/ConvertMe/red bubbles 3.frag:3: 'iResolution' : unknown swizzle selection  
ERROR: package/contents/ui/Shaders/ConvertMe/red bubbles 3.frag:3: 'iResolution' : unknown swizzle selection  
ERROR: package/contents/ui/Shaders/ConvertMe/red bubbles 3.frag:3: 'iResolution' : unknown swizzle selection  
ERROR: package/contents/ui/Shaders/ConvertMe/red bubbles 3.frag:3: '' : compilation terminated  
ERROR: 6 compilation errors.  No code generated.  
Conversion failed for: red bubbles 3.frag

The file, red bubbles 3.frag, is a simple shader that has worked flawlessly in the plasma5 version. I've attached the file (as a txt due to github limitations). I understand the issue is probably with my shader rather than with the compiler, I still don't fully understand how any of it works.

bubbles.txt

y4my4my4m commented 2 months ago

@Shoshele you need to run ShaderProcessor.py first.

Unfortunately the processor is very weak codewise and it probably will fail since you don't have double newline at the top (I'll improve it, it's kinda rushed right now).

Read the README_Dev.md to add the relevant missing shader part at the beginning and end of the file.

Shoshele commented 2 months ago

I did run ShaderProcessor first, but still got the issue. But thank you for pointing me in the right direction! Adding the definitions and main() manually, and running qsb instead of ShaderCompiler, gave me compiler errors I actually could understand, and I was able to edit bubbles.frag such that it would successfully compile, and it's now running quite well under plasma6.

Am I correct to think the plasma6 requirement for compilation is why it no longer supports editing parts of the shader in the configuration? That's unfortunate.

y4my4my4m commented 2 months ago

Am I correct to think the plasma6 requirement for compilation is why it no longer supports editing parts of the shader in the configuration? That's unfortunate.

Yes, that's right! The way Plasma5's plugin works is by doing some frankenstein regex search of "vec3" variables in the shader code and editing them on the fly. Since it now needs to be compiled, it's not as straight forward.

However, I belive it is still achievable! The way it works now is backward, instead of gathering variables from the shader, we must feed the shader the variables we want.

I'm planning to work on some pre-processor that will inject variables to the shader code if relevant and it'll have conditional state depending on whether or not that customization option is available.