GameFoundry / bsf

Modern C++14 library for the development of real-time graphical applications

Home Page:https://www.bsframework.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shader compiling with lighting fails on some locales

hhyyrylainen opened this issue · comments

When I import a transparent shader with lighting on it. I get errors like:

Failed compiling GPU program(s): Fragment program: Compile error: ERROR: 0:146: '' : float literal needs a decimal point or exponent 
ERROR: 0:146: '' : compilation terminated 
ERROR: 2 compilation errors.  No code generated.


Fragment program: Compile error: ERROR: 0:151: '' : float literal needs a decimal point or exponent 
ERROR: 0:151: '' : compilation terminated 
ERROR: 2 compilation errors.  No code generated.


Fragment program: Compile error: ERROR: 0:146: '' : float literal needs a decimal point or exponent 
ERROR: 0:146: '' : compilation terminated 
ERROR: 2 compilation errors.  No code generated.

Intercepting the full shader source (full code here: https://pastebin.com/4ah08G0z) one of the problematic lines is:

return normalize(mix(N, R, vec3((1,000000f - r2) * (sqrt(1,000000f - r2) + r2))));

Which pretty clearly indicates that those floats have been printed with a , as the decimal separator due to my locale setting. There is someplace in the shader source generation that uses a locale dependent float formatting function.

If I run my import script (which passes the locale down to bsf) like this I can import my shader just fine:

LC_ALL=en_GB.utf8 ./ImportAssets.rb

So I basically set English as my locale. Funnily enough this also affects the animation speed of my shader vertex animation, so there's some places where this locale difference doesn't cause a compiler error, but it does change the parameters to some math functions.

Thread on the forum: https://discourse.bsframework.io/t/importing-transparent-shader-with-lighting-fails/482?u=hhyyrylainen

I submitted a fix to our cross-compiler generator that should resolve your problem. However before I go updating all the dependencies, could you compile it yourself and test if it indeed solves the issue?

The steps to compile it are:

  1. Clone https://github.com/bearishSun/xshadercompiler
  2. Git checkout banshee branch
  3. Run ./install and wait for it to finish, when it ends you'll have an install folder at repo root
  4. Copy the contents of the newly created install folder to bsf/Dependencies/XShaderCompiler, overwriting existing files.

Couple of notes for step 4:

  • Make sure not to delete .version file within the bsf/Dependencies/XShaderCompiler folder, otherwise cmake will just re-download its own version of the binaries when its ran.
  • If on Windows, move contents of lib/x64 to lib, then delete both x64 and x86 folders.

Then compile bsf and try again...

Sorry for not replying earlier. I just now got the time to test this. And I think it worked. At least I didn't get an error importing my shader with the updated shader compiler version (b1005bf81bd02959112e177fb29558bf5e4b32bc)

Thanks for confirming. I'll keep this one open until I update the precompiled binaries on all platforms.