Sitemap
Ben Golus
1 min readFeb 1, 2021

--

The shader presented does not use the tex2Dgrad function. It uses tex2Dbias, the equivalent of which GLSL has had since version OpenGL 2.0 / GLSL 1.0. It’s an overload of the default texture sampling function with the bias as a third parameter after the texture and uv coordinates. The use of tex2Dgrad is only presented as an optional replacement for tex2Dbias in cases where the later is for some reason unavailable (specifically Unreal Engine’s material system).

I do use derivatives for knowing the sample offset, but that shouldn’t be a problem for OpenGL 2.1 either as the equivalentdFdx and dFdy functions are both required core features.

If you were using OpenGL ES 2.0 or WebGL 1.0, neither of those have guaranteed derivative support. You would need to pre-compute the approximate isotropic derivatives on the CPU in those cases. Or at the very least the texel size to view linear depth ratio and get the offset based on the depth. But both of those APIs have the same bias overload for the texture function as OpenGL 2.0 has.

--

--

Ben Golus
Ben Golus

Written by Ben Golus

Tech Artist & Graphics Programmer lately focused on Unity VR game dev. https://ko-fi.com/bgolus

No responses yet