Defold Editor on Windows didn't show shader errors

For example we have a shader:

varying mediump vec2 var_texcoord0;

uniform lowp sampler2D DIFFUSE_TEXTURE;
uniform lowp vec4 tint;
uniform lowp vec4 colorization;

void main()
{
    lowp vec4 color1 = texture2D(DIFFUSE_TEXTURE, var_texcoord0.xy);
    lowp vec4 color2 = (colorization.xyz*color1.w, color1.w);
    lowp vec4 color3 = mix(color1, color2, colorization.w);

   // Pre-multiply alpha since all runtime textures already are
    lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w);
    lowp vec4 color_result = color3 * tint_pm;
    gl_FragColor = color_result;
}

On windows game with this shader starts and shader didn’t work.
But on mac it show an error:
WARNING:GRAPHICS: ERROR: 0:10: Incompatible types in initialization (and no available implicit conversion)

The right version of shader is:

varying mediump vec2 var_texcoord0;

uniform lowp sampler2D DIFFUSE_TEXTURE;
uniform lowp vec4 tint;
uniform lowp vec4 colorization;

void main()
{
    lowp vec4 color1 = texture2D(DIFFUSE_TEXTURE, var_texcoord0.xy);
    lowp vec4 color2 = vec4(colorization.xyz*color1.w, color1.w);
    lowp vec4 color3 = mix(color1, color2, colorization.w);

   // Pre-multiply alpha since all runtime textures already are
    lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w);
    lowp vec4 color_result = color3 * tint_pm;
    gl_FragColor = color_result;
}

Would be great if windows version of Defold Editor 2 shows the same error like mac version. It will make a shader writing on Windows much easier.

(I am not sure is it editor2 specific issue or not? Should I create an issue for editor2 on github?
maybe this or this ?
)

3 Likes

We could do a better job warning for stuff that’s not supported by some target GL version. Feel free to comment on the issues you linked to, or add your own :slight_smile:

2 Likes

I really like how it’s works on mac, but on Windows it works worse (
And guys who works on PC have many issues with this.

This is problem!
Now we are developing a set of new shaders, and this error made me lose the evening. More precisely - no mention of the error. I have been writing all kind of shaders for 7 years already and it was thought that finally I had gone mad. :frowning:

1 Like

We hoped that DEF-2739 would help with this error (no mention of the error), but it did not help.

What OS and version is the device/machine running?
Also, if you have details on graphics card, drivers and OpenGL (supported) version that would also be really helpful.

Oh, just to try something really crazy (if you are able to start the game/engine ofc);
Could you try modifying one of the shaders you are having issues with and hot-reload it once (ctrl/cmd+r), does it print any errors?

2 Likes

Faced the same problem. Please correct

On my PC with GTX1050 and win10 i haven’t errors when build
When i run apk on my android 7.0 with MediaTek MT6737T & Mali-T720 MP2 i have black screen without errors.
When i build on my macbook air 2015, defold report errors screenshot

this is wrong and very complicates the development!

1 Like

This relates to: Android Shader Conversion Error (SOLVED)

I’m not sure how we detect and surface the error, but I assume it is based on the error we get from the driver or similar. And if your Windows driver happily accepts the shader then you won’t get an error. And it seems like your Macbook is more stringent and detects the problem, and we can thus pick it up. I’m fairly sure that if you check logcat on your Android device you’d see an error as well.

In any case, fix the error mentioned in your screenshot and the shader should work on all devices. Remember to keep to the Open GL ES 2.0 specification to ensure compatibility on all platforms.

1 Like

The best way for me to pick up the errors on windows was by using the ‘adb logcat’ to debug the Android device directly, most of the errors just appear to be simple conversions which are easily fixed. This is my experience of it.

3 Likes

With a delay, but I provide details (see attached files).OpenGL_and_DxDiag.zip (6.6 KB)

The problem still exists. Or not a problem and a feature?

IT CORRECTLY WORKS on my PC:
06
but this don’t works on android & etc.

This is really correct form of the shader, this works everywhere:
%D0%A1%D0%BA%D1%80%D0%B8%D0%BD%D1%88%D0%BE%D1%82-2018-06-01-13!!!

I used a hot-reload in different versions (incorrect->correct and correct->incorrect) but I have everything working on my PC:
5211