Open xinaesthete opened 2 years ago
I suppose an ugly solution is to define GL_OES_standard_derivatives in the surrounding code, but I wonder if it could be something like
#if __VERSION__ !== 100 || defined(GL_OES_standard_derivatives)
// use standard derivatives
#else
// fallback
#endif
I've not tested this, so I'm not 100% certain the correct check though.
That looks only incrementally uglier, so seems like an obvious approach, however...
In the context of my own code, I think I'm tempted to just drop the fallback option. That may not be a 'correct' solution, and I'd hesitate to advocate it here... it would be good to know how common it is for configurations in the wild not to support derivatives.
In the context of some fairly GPU heavy / VR stuff, I strongly doubt that a machine without that support would be a viable platform for the code itself.
What happened as a result of having the (untested) fallback option was that it suddenly made things look bad (I've identified this as a bug in one project, but in the back of my mind am now thinking it probably also applies to something else I haven't got around to looking at yet). It manifests in a way that requires some pretty careful analysis to diagnose (in the case of my other project, sapped at my motivation to get back into a side-project that had gone by the wayside for a year or so).
Much more difficult to trace than a shader compiler error pointing at the precise line where it's failed... and in this instance, simply bypassing the #ifdef
would have just resulted in not ever having a bug in production (the visual problems weren't apparent in all circumstances, so weren't spotted when the change went in).
I haven't actually used this package, but use the same function elsewhere. It's come to my attention that in a WebGL2 context
#ifdef GL_OES_standard_derivatives
evaluates false, because standard derivatives are no longer defined as an extension, but part of the base functionality.As such, this code when compiled in a WebGL2 context ends up falling back to the case where derivates aren't supported.