Shader not compiling on mac but will on windows


I wrote a fragment shader on my windows machine and it worked fine. But when I try to build it on my late 2012 macbook pro i get the following errors.

Incompatible types in initialization (and no available implicit conversion)

Is this a result from the version differences of OpenGL? Is there a way to force to a specific version of OpenGL?


It’s said that apple will drop opengl?


Do you get a line number as well? Did you search for the error? Maybe this will help:


Yes, that is true, but not for quite some time. We’re working on a Metal compatible render pipeline.


The shader compiler on mac may be more picky than the one on windows. Please post the log that contains the error, there should be a line number to the offending code.


One common mistake is assigning an int to a float lvalue in GLSL:

float a = 1.0; // OK
int b = 1; // OK
float c = 1; // Wrong

But yeah, look at the code at the line number reported by the error.


All my shaders written on a Mac, work on Windows. So Windows is more permissive in your case.


Thank you for the reply it did give me a line number. I dont have my laptop with me this morning but ill post it all latter today.

Thank you, I will later today.

I see. If I remember correctly my code is written correctly as you show it.



I was able to revisit this problem and i narrowed the problem down to this issue. ‘+’ does not operate on ‘vec3’ and ‘vec4’. That makes sense, but I don’t get this error on windows. the vec4 is the time variable from the shadertoy tutorial. Any thoughts? thanks for the help.


Different platforms have different shader compilers. Some are more forgiving while some are not as forgiving, which can let a shader run on e.g. Windows but not on MacOS.

Anyway, it sounds strange that any compiler would accept adding a vec3 and vec4. What would the expected resulting type be?


Either vec7 or vec3.5 =P


The resulting type expected would be a vec3. Im not a shader expert by any means. I just ran through the defold tutorial then started to convert some shadertoy examples over to defold to learn from. I guess I expected that the defold shader was platform agnostic. I converted vec4 time to a vec3 and got it to work (sort of) its not an exact match. Thanks for the help, ill keep plugging away at it.


Haha sounds about right