equivalent texture function to texture2D in OpenGL-ES?

| | August 4, 2015

I’m trying to figure it out how can implement the same result using texture2D. The result expected is a luminescence operation but I couldn’t replicate the same functionality using texture2D for iOS. could you explain a little bit what the texture function does with the 20.0 value?

float logAvgLum = exp(texture(hdrSampler, texCoord ,20.0).a) ;

One Response to “equivalent texture function to texture2D in OpenGL-ES?”

  1. The 20.0 is the bias used to manipulate the mipmap level to read. The same parameter exists in OpenGL ES (see a description in the specs here: http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf page 71).
    Note that it is only available in the fragment shader as the derivatives used to calculate the mipmap level are the differences to the neighbouring pixels (of one 2 by 2 quad in case you want to google more details) and this just doesn’t exist during the vertex shading stage.
    So at least in the fragment shader the code should also run on ES (by replacing texture with texture2D), do you try to run it in the vertex shader?

Leave a Reply