Author Topic: mipmap = 1 is a game changer!  (Read 2136 times)

zpaolo11x

  • Hero Member
  • *****
  • Posts: 1234
    • View Profile
    • My deviantart page
mipmap = 1 is a game changer!
« on: August 24, 2018, 01:37:40 AM »
Not only mipmap = 1 improves dramatically the scaling of pictures, but when a GLSL fragment shader is applied to an image with mipmap enabled the fragment shader can sample the desired mipmap level! This is a godsend for smoothnig and blurring filters, and also for averaging and in all those cases where it's better to work with a lower resolution image that is then upscaled. Definitely very cool!

The only issue is what happens on AM 2.3? Is it time to ditch the old good guy and develop only for AM 2.4+? Also, there's probably a way to pass mipmaps to the fragment shader through a vertex shader, but I'm not good enough at GLSL ;D

zpaolo11x

  • Hero Member
  • *****
  • Posts: 1234
    • View Profile
    • My deviantart page
Re: mipmap = 1 is a game changer!
« Reply #1 on: August 24, 2018, 03:18:16 AM »
Speaking of this, what is the fastest way to obtain an "average" color value for a texture? In my current GLSL fragment shader I sample 9 points of the texture image and get the average value, this is far from perfect since for every pixel of the image I have to sample 9 points, that are always in the same positions :D

So I thought I could sample just 1 point per pixel, but on a mipmap level that is high enough so that this single pixel is the average of the texture color. This means though that I need to go to a mipmap level of around 10 or 11 to be sure that even large images get averaged properly (a 1024x1024 texture with mipmap 10 is 1x1 pixel).

I'm sure that's a better way to do this, maybe with a vertex shader, but I'll do some tests to see which of those method is the fastest.

zpaolo11x

  • Hero Member
  • *****
  • Posts: 1234
    • View Profile
    • My deviantart page
Re: mipmap = 1 is a game changer!
« Reply #2 on: August 24, 2018, 09:11:59 AM »
Ok, on my Mac mimap works, but the GLSL shader I wrote that uses textureLod or texture with bias to sample the mipmap doesn't seem to work :( If I place #version 130 and up in the header it says version 130 is not supporte, only up to 120, but my macbook should support up to OpenGL 4.1 :/ I'm probably doing something wrong :(((