Actually this would just be sorted if LOVE would allow you to set the texture mode for openGL.
Texture modes in opengl:
The GL_REPEAT mode has textures repeat when you go past (0,0) to (1,1) range
The GL_CLAMP_TO_EDGE mode has textures stop at the last pixel when you fall off the edge.
EDIT -- I think the default is GL_CLAMP_TO_BORDER
Other modes: GL_MIRRORED_REPEAT, GL_MIRROR_CLAMP_TO_EDGE, etc.
EDIT -- I believe that you do not need to fluff your graphics by 1 pixel borders and you do not need to avoid every decimal fraction for scaling.
I believe the GL_MIRRORED_REPEAT mode would be the best suited default for this scenario, or nearly all scenarios really.
Image Filter artefacts when zoomed
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Party member
- Posts: 134
- Joined: Tue Mar 29, 2011 11:05 pm
Re: Image Filter artefacts when zoomed
Last edited by drunken_munki on Fri Oct 16, 2015 10:10 am, edited 1 time in total.
Re: Image Filter artefacts when zoomed
Texture modes don't help with quads though...?drunken_munki wrote:Actually this would just be sorted if LOVE would allow you to set the texture mode for openGL.
Texture modes in opengl:
The GL_REPEAT mode has textures repeat when you go past (0,0) to (1,1) range
The GL_CLAMP_TO_EDGE mode has textures stop at the last pixel when you fall off the edge (I think this is the default)
Other modes: GL_MIRRORED_REPEAT, GL_MIRROR_CLAMP_TO_EDGE, etc.
Opengl does all of this and everyone's insinuations and insults to people learning LOVE2D is just plain wrong. No you do not need to fluff your graphics by 1 pixel borders. No you do not need to floor every co-ordinate. No you do not need to avoid every decimal fraction for scaling.
I believe the GL_MIRRORED_REPEAT mode would be the best suited default for this scenario, or nearly all scenarios really.
-
- Party member
- Posts: 134
- Joined: Tue Mar 29, 2011 11:05 pm
Re: Image Filter artefacts when zoomed
I beleive it should work with all draw types.S0lll0s wrote:Texture modes don't help with quads though...?drunken_munki wrote: I believe the GL_MIRRORED_REPEAT mode would be the best suited default for this scenario, or nearly all scenarios really.
If I can assume somewhere in the underbelly of love2d it is calling:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
with GL_LINEAR or GL_NEAREST
to set the filter mode when we call love.graphics.setDefaultFilter.
I could expect a new function love.graphics.setDefaultTextureMode would call the gl function:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
where the mode could be GL_REPEAT, GL_MIRRORED_REPEAT, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_BORDER.
This attrubite is bound to the texture and then we would hope the scaling/rotating artifacts would go away with no other fuss if set to anything other than GL_CLAMP_TO_BORDER.
If we're asking does this work with buffer objets and other things like that, then I do not know -- however I would assume the same principle is applied when those textures are bound to the graphics memory.
- slime
- Solid Snayke
- Posts: 3162
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Image Filter artefacts when zoomed
LÖVE does allow you to set the wrap mode for images and canvases (see the [wiki](Image):setWrap[/wiki] and [wiki]WrapMode[/wiki] wiki pages.)drunken_munki wrote:Actually this would just be sorted if LOVE would allow you to set the texture mode for openGL.
Opengl does all of this and everyone's insinuations and insults to people learning LOVE2D is just plain wrong. No you do not need to fluff your graphics by 1 pixel borders. No you do not need to floor every co-ordinate. No you do not need to avoid every decimal fraction for scaling.
The clamp wrap mode is the default in LÖVE, and it is appropriate for dealing with this problem if Quads are not used.
However, as pointed out above, the OpenGL / GPU texture wrap mode only affects the borders of the texture, not the borders of a quad. With a texture atlas / sprite sheet this means it only affects the borders of the entire atlas, rather than the borders of each sprite within the atlas. So it doesn't solve this problem when texture atlases are used.
Modern GPUs have another technique that can get around the problems inherent to texture atlases: Array Textures.
However Array Textures require a modern GPU as well as custom shader code in order to use, so it might be challenging to integrate them into LÖVE in a clean and nice manner.
Re: Image Filter artefacts when zoomed
Also, all array textures must be the same size. Texture atlas can contain images of different sizes and you don't waste additional memory for smaller images (and don't have to crop them later).slime wrote:Modern GPUs have another technique that can get around the problems inherent to texture atlases: Array Textures.
However Array Textures require a modern GPU as well as custom shader code in order to use, so it might be challenging to integrate them into LÖVE in a clean and nice manner.
I've read somewhere that border padding can't be an ideal solution for eliminating texture bleeding, it just shifts the problem onto another mipmap level. But you can use different version of texture atlas for each mipmap level. LÖVE v.0.10.0 allows creating such mipmaps (didn't tested this yet).
- slime
- Solid Snayke
- Posts: 3162
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Image Filter artefacts when zoomed
Each layer in an array texture has to be the same size, but you can theoretically have a texture atlas in each layer if you want (although in that situation you'll have most of the same problems that regular texture atlases do, of course.)arampl wrote:Also, all array textures must be the same size. Texture atlas can contain images of different sizes and you don't waste additional memory for smaller images (and don't have to crop them later).
Yeah. Images don't use mipmaps in LÖVE though, unless you explicitly enable them.arampl wrote:I've read somewhere that border padding can't be an ideal solution for eliminating texture bleeding, it just shifts the problem onto another mipmap level.
Re: Image Filter artefacts when zoomed
Hm, thought SDL generates them automatically anyways. Scaled image's quality is good enough in LÖVE which I'm not sure is possible without mipmaps. And I have problems with texture atlas with borders' padding when scaling. Or SDL allows to load textures without mipmap generation and LÖVE uses this loading function?slime wrote:Images don't use mipmaps in LÖVE though, unless you explicitly enable them.
- slime
- Solid Snayke
- Posts: 3162
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Image Filter artefacts when zoomed
LÖVE doesn't use SDL for the love.graphics module, it uses OpenGL directly (and the SDL_Render API doesn't support mipmaps at all.)
You can enable mipmaps in LÖVE 0.9 with [wiki](Image):setMipmapFilter[/wiki], or in 0.10.0 with [wiki]love.graphics.newImage[/wiki](filename, {mipmaps=true}).
You can enable mipmaps in LÖVE 0.9 with [wiki](Image):setMipmapFilter[/wiki], or in 0.10.0 with [wiki]love.graphics.newImage[/wiki](filename, {mipmaps=true}).
Re: Image Filter artefacts when zoomed
Good then! Tomorrow I'll try to make test suite for this problem.
I'm especially interested in creating custom mipmaps for atlases (on the fly, of course, using scaling).
I'm especially interested in creating custom mipmaps for atlases (on the fly, of course, using scaling).
-
- Party member
- Posts: 134
- Joined: Tue Mar 29, 2011 11:05 pm
Re: Image Filter artefacts when zoomed
That's really interesting news thank you everyone.
Who is online
Users browsing this forum: Google [Bot] and 3 guests