pouët.net

Shaders compilation issues using WebGL

category: code [glöplog]
 
Hi all,
I'm facing link issues on a regular basis when compiling fragment shaders with Chrome or Firefox. The DirectX linker complains about division by 0 while there is no division or normalization in the code.
The only solution I found so far is to randomly add new lines of code, and it eventually solves the compilation error, but this is of course not a right cure.
This also happens on fragment shaders that feature very few uniforms or samplers, so capability limits are not reached. The only particular thing with my shaders is that they make a massive usage of #define and #ifdef directives
Anyone ever met such a problem, or can suggest good investigation tools?
added on the 2015-01-12 08:49:07 by Soundy Soundy
My solution is not elegant, but works. I use chrome, have angle enabled, use Windows 8.1, and did the following:

Search for d3dcompiler_47.dll in your system. Go to your chrome installation folder, and replace the d3dcompiler_43.dll and d3dcompiler_46.dll with the d3dcompiler_47.dll (overwrite both).

You'll instantly profit from the most recent shader compiler, which should be more correct and way faster.

Hello shadertoy users, this will make the site useable again! :)
added on the 2015-01-12 11:06:10 by xTr1m xTr1m
Btw, for those who don't have Windows 8.1, there's also a solution for you:

Microsoft provides 2 versions of d3dcompiler_47.dll. The one from windows 8.1 depends on the WinRT API, so you can't use that. There's also the d3dcompiler_47.dll that lies in the Visual Studio 2013 installation folders. That one uses the good old WinAPI, and works on Windows 7.
added on the 2015-01-12 11:07:26 by xTr1m xTr1m
Oh and finally: If you want to check which variant of the d3dcompiler_47.dll you currently have, drag it over depends.exe
added on the 2015-01-12 11:08:15 by xTr1m xTr1m
Thanks for your suggestions!
As the shaders need to be recompiled on the viewer's browser, you need every watcher to do your trick so that the demo runs, so this is a cool hack while developing, praying for the final version of your shaders to compile with a non-hacked configuration.
Still, that's better than being blocked during development!
added on the 2015-01-12 11:21:26 by Soundy Soundy
If adding new lines of code helps you can write helper for compiling that does just that. If it fails to compile, adds extra line and tries to compile again. :D
added on the 2015-01-12 14:43:55 by ClySuva ClySuva
Interesting case: I have my camera's position as: uniform vec3 camPos
camPos is used when calculating the rays, and I can raymarch a scene with no problem.
But when I use the same camPos uniform again to position an object in front of the camera, e.g:
vec3 pos = camPos + someVector
then the link of the fragment shader fails
So: camPos uniform is OK since the raymarcher works perfectly fine, but I can't use it in all the functions. This is nonsense. The link error talks about Nans and div by #0, which is weired at compile time for a uniform, or it can't find it....
added on the 2015-01-12 19:42:16 by Soundy Soundy
Beautiful technology.
added on the 2015-01-12 21:01:24 by superplek superplek
yeah the desire intro (which is a pretty neat work codewise) renders perfectly under internet explorer 11 but on latest firefox runs pretty slow with the sound halved to 50% and on chrome the 'happy new year' flying text is not present at all. chrome and firefox certainly need to update/enhance their connection to direct x api on any platform.
added on the 2015-01-12 21:28:19 by Defiance Defiance
correction, had to run it from a chrome that allowed file access to render properly.
added on the 2015-01-12 21:49:26 by Defiance Defiance
Oh yeah, sorry about that, did not check for loading errors and display the right message when not running the online version, this was a really really quick piece of code.
Should work on all explorers (including IOS and Android) if you run the online version.
The engine I did for 68000 Reasons is more comprehensive and handles loading errors gracefully, will try to do better for my next real prod'.
added on the 2015-01-13 09:53:19 by Soundy Soundy
Thanks for that dependency tool xTr1m. I've been looking for something like that for a while.
Anytime :) That's a must have for every coder.
added on the 2015-04-20 22:44:37 by xTr1m xTr1m
i use ollydbg to figure out dll dependencies. its also a nice debugger for windows if you code in assembly or don't have the sources for an exe
added on the 2015-04-21 07:33:54 by musk musk
and on topic, some versions of fireform incredibly well, compile all page worth of shaders under a second and if a specific shader crashes then only that one crashes not all of them

but then i updated firefox and it all went to hell. now it shadertoy barely runs
added on the 2015-04-21 07:40:49 by musk musk
*firefox perfom incredibly well, damn megatypo
added on the 2015-04-21 07:42:13 by musk musk

login