MatCap in PlayCanvas

I found this really cool demo scene with MatCap shaders in PlayCanvas:
https://playcanvas.com/project/575970/overview/matcap-shaders

Unfortunately, the demo throws an error:

[.WebGL-0x7fccc403c000]GL ERROR :GL_INVALID_OPERATION : glDrawElements: Source and destination textures of the draw are the same.

My GLSL skills are pretty basic, so this puzzles me. Does anyone know how to fix the error? The results I get from Googling suggest that it probably generates a ton of garbage.

I’ve seen this error when I’ve tried to capture the screen and apply the texture to a material that can be seen by the camera, creating a feedback loop of capturing something that I’m trying to write to.

As it only happens once, it might be to do with something on initialisation.

Hi @Excess,

On what device/browser are you running the demo?

I’ve just tested on Firefox and Chrome (Windows 10) and it works as expected with no error.

Edit: Tested also on a Samsung Galaxy S10 / Android, it works with no error.

I’m on MacOS 10.14.6 running Chrome Version 78.0.3904.108

I just tried the demo on Firefox. Here I’m getting a similar error:

Error: WebGL warning: drawElements: Texture level 0 would be read by TEXTURE_2D unit 0, but written by framebuffer attachment COLOR_ATTACHMENT0, which would be illegal feedback.

Might be something with the Mac GPU drivers, I don’t have access to a Mac to try.

Though I’ve just tried on an iPhone 10 (iOS 13) and it works as well.

Could you try running the example on Safari on your Mac with the WebGL2 feature option enabled in the experimental menu?

https://discussions.apple.com/thread/8655829

In Safari I’m getting yet another error. Don’t know if it’s related:

WebGL: INVALID_ENUM: texParameter: invalid parameter name

The scene does work in all browsers, I’m just seeing the error in the console.

Right, if you would like submit an issue in the engine repo to help the team with debugging:

I just had a colleague try the demo in Chrome on a PC running Windows 10 and he’s also getting an error:

[.WebGL-00000149825816F0] GL_INVALID_OPERATION: Feedback loop formed between Framebuffer and active Texture.

I’m surprised it’s working for you without errors @Leonidas

So, I think when you say error you mean the yellow browser warning that starts with Error: etc right?

I was carried away when you said unfortunately in your initial post and thought that you got an actual JS error and the demo wouldn’t run.

Those WebGL errors aren’t that uncommon when doing shader dev, it doesn’t mean always a render stop error, can be also a warning on initialization. Especially if the code is executing with no issue.

I’d say still submit the issue for someone working on the internals of the engine to take a look at.

I get the warning in console @Leonidas. It doesn’t stop the app from working (Chrome, Windows)

Yes, I take the warning as well, and it is working. Thanks @yaustar!

Yes, It’s indeed a warning. Except in the experimental Safari test – that was an actual error.
However, from what I’ve been reading about these types of GL errors, they could be generating garbage.

My concern is whether it would be safe to use in actual production. If the error could be fixed, that would definitely be preferred.

1 Like

Hi @Excess,

The error message appears in Safari because you’ve enabled the ‘WebGL 2.0’ experimental feature. Unfortunately Safari’s WebGL 2.0 support is incomplete. Disabling WebGL 2.0 will make the errors disappear.

Thanks!

1 Like