ioscifilter

How to specify LOD bias in Metal?


I'm rewriting an OpenGL filter from the Android version of the app I'm currently working at in Metal. It uses the following texture lookup function: vec4 texture2D(sampler2D sampler, vec2 coord, float bias)

Assuming my filter kernel function looks like this:

float4 fname(sampler src) {
    ...
}

The texture lookup call would be the following:

src.sample(coord)

But how can I pass the bias parameter? (the sample function takes only 1 argument)


Solution

  • I'm afraid Core Image only supports 2D textures – no mipmapping and LOD selection. Only bilinear sampling is available.

    If you need different LODs, you need to pass different samplers to your kernel and do the interpolation yourself.