Search code examples
openglglslantialiasing

Invalid call of undeclared identifier texture2DLodOffset


I am trying to get this FXAA shader run on my machine.

It does not seem to recognize a function named texture2DLodOffset in GLSL. It also does not recognize texture2DLod. The texture2DLod function has apparently had an alternative in texture2D as the third argument bias. However, I could not find alternative to the former missing function texture2DLodOffset. Can somebody get me through this?

It would also be great if somebody could suggest me any more anti-aliasing techniques.

Specifications (working on a Virtual Machine):

OpenGL vendor string: Parallels and Intel Inc.
OpenGL renderer string: Parallels using Intel Iris OpenGL Engine
OpenGL version string: 2.1 INTEL-10.6.20
OpenGL shading language version string: 1.20

Solution

  • texture2DLodOffset() is from EXT_gpu_shader4, make sure that's supported on your GL implementation and enabled via:

    #extension GL_EXT_gpu_shader4 : enable
    

    after your #version directive.

    Or, the jMonkeyEngine sources have some alternatives:

    ...
    #if __VERSION_ >= 130
        #define OffsetVec(a, b) ivec2(a, b)
        #define FxaaTexOff(t, p, o, r) textureOffset(t, p, o)
    #elif defined(GL_EXT_gpu_shader4)
        #define OffsetVec(a, b) ivec2(a, b)
        #define FxaaTexOff(t, p, o, r) texture2DLodOffset(t, p, 0.0, o)
    #else
        #define OffsetVec(a, b) vec2(a, b)
        #define FxaaTexOff(t, p, o, r) texture2D(t, p + o * r)
    #endif
    ...
    

    You'll probably want the last set for #version 120:

    #define OffsetVec(a, b) vec2(a, b)
    #define FxaaTexOff(t, p, o, r) texture2D(t, p + o * r)