Mobile shadows (PCF filter)

Hey,

I’m working on a project that uses the following filter.

shadowGenerator.filter = ShadowGenerator.FILTER_PCF

On PC it works great, but on certain mobiles (a Samsung mobile particularly) I’m getting some errors.

BJS - [16:47:04]: Error: FRAGMENT SHADER 0:148: S0032: no default precision defined for parameter 'webgl_4aeb46af4241331f'
babylon.js:16 BJS - [16:47:04]: Trying next fallback.
BJS - [16:47:04]: Unable to compile effect:

and then a lot of errors that I’m not sure are particularly useful.

It works fine on my Pixel phone, but this error is happening on a Samsung Galaxy S21 (Exynos I think).

If I use a different filter it seems to work fine. Is this expected? I would hope that it would fallback rather than fail?

I’m using babylon 4.2.

Thanks,
Chris

Hi Chris_Rollinson,

I’m not an expert on this, but it does look like some of our shaders include precision designations and some don’t. @Evgeni_Popov, could that be what’s causing the errors Chris is seeing?

Due to the name of the parameter in the error it looks like a driver / angle bug on those devices… Unfortunately you could open a Chromium bug or a Samsung one to see if they could fix it.

We already had this kind of error in the past:

Thank you all for your replies, and from Evgeni_Popov has said I’ve realized that if you search for webgl_4aeb46af4241331f this error has been reported a few times :(.

In case anybody else finds this thread, seems like the best way to deal with it is this…

Regarding how to deal with the problem: add a callback to material.onError and in the callback just turn off the filter on the shadowGenerator. This will force the material to recompile

material.onError = (effect: Effect, errors: string) => {
...
};

EDIT: And I’ve also seen that apparently you can use the CascadedShadowGenerator rather than the ShadowGenerator, but I haven’t tested this yet.

Thanks again for your help.

1 Like