About Monkey 2 › Forums › Monkey 2 Programming Help › Texture filters
This topic contains 17 replies, has 9 voices, and was last updated by 
 Diffrenzy
 1 year, 10 months ago.
- 
		AuthorPosts
 - 
		
			
				
May 28, 2017 at 1:43 am #8326
I just updated to the latest Monkey 2 dev build, and it seems TextureFilter is gone?
I want scaled images to use GL_NEAREST, and I’ve tried TextureFlags.None and TextureFlags.Filter, but none of them have that effects.So how do I get my images nice and pixely?
Do I have to use canvas.TextureFilteringEnabled=False just before I draw that image?May 28, 2017 at 11:01 pm #8346Yes, ripped this out for now while 3d stuff is being added.
What are you wanting to do exactly? How were you using TextureFilter before?
Canvas.TextureFilteringEnabled:Bool is back now, but that flushes rendering so isn’t particularly efficient (unless you sort Draw calls). It’s really meant for a quick ‘n’ dirty ‘retro mode’, which seemed to be what most people wanted.
May 30, 2017 at 2:56 am #8375Bump…would quite like a reply to this if possible!
May 30, 2017 at 7:39 am #8377From what I understand GL_NEAREST creates this pixelized effect, which is particularly good for retro styling.
From my perspective it would be a much preferred way to produce this effect in a post processing shader. Because that way you don’t have to mess with the underlying engine configurations.
May 30, 2017 at 8:50 am #8378I’m more interested in how (and why) its being used.
Canvas.TextureFilteringEnabled (which globally forces nearest filtering for all drawing) takes care of all the stuff in bananas and the framework stuff in modules – what else is needed on top of this?
I’m guessing the ability to selectively enable nearest filtering for only some textures, in which case perhaps adding an optional textureFlags param (that includes texture filtering modes, as it used to!) to Image.Load would be enough?
It’s hard to say what ‘best’ here (while also taking into account the new 3d stuff) unless I have an idea of what it’s being used for.
May 30, 2017 at 10:38 am #8380I’m using this:
‘need this for pixels and not smoothed
canvas.TextureFilteringEnabled = falseIt gives pixel graphics that have not been smoothed. so I can use (say a 16×16) graphic without it looking like crap at bigger resolutions.
Also great for making games that want low res graphics for example:
Attachments:
May 30, 2017 at 11:11 am #8383I’m using this for my Voxel module.
If I have filtering enabled, you can barely tell what the voxel objects are supposed to be since I’m stretching them so much.
But with filtering off, it looks like good old voxel cubes.
But now, since it’s a canvas option, everything is forced to be without filtering just because you’re using my Voxel module. Even text and stuff, which might look better with some filtering.
I’d gladly take a loading flag for no filtering over forcing the entire canvas to be one specific thing.
May 31, 2017 at 5:05 am #8391I’ve been using TextureFilter per image, instead of setting the canvas. I’m still on V1.1.04, though.
May 31, 2017 at 12:31 pm #8401I’m thinking this is maybe relevant? : http://monkey2.monkey-x.com/forums/topic/texturemapping-wrap-with-drawprimitives/
The feature request is: Let it be possiple to set the texture wrap flag at runtime, after loading.
myimg.Textureflags(n,flags) or something…OR maybe specifying them when calling DrawPrimitives()?
May 31, 2017 at 11:07 pm #8403With image filters set an the image level not the canvas level I guess we could create something like this:

If anyone wants to mix retro we “modern”.
May 31, 2017 at 11:43 pm #8404There is actually a simple way to modify texture flags currently in the develop branch – the Texture.Flags property is now read/write so you can actually just blast your own flags in, eg:
image.Texture.Flags|=TextureFlags.WrapST ‘enable texture coordinate wrapping.
image.Texture.Flags&=~TextureFlags.FIlterMipmap ‘disable filtering/mipmapping.
This does actualy take care of all the above issues in a pretty clean way!
Is everyone OK with this approach (and with TextureFilter being moved to TextureFlags)?
June 1, 2017 at 12:48 am #8405June 1, 2017 at 5:00 am #8406why not have both?
June 1, 2017 at 5:02 am #8407Not using the dev branch yet, but this seems fine to me. Thanks.
June 1, 2017 at 9:23 am #8408image.Texture.Flags|=TextureFlags.WrapST ‘enable texture coordinate wrapping.
image.Texture.Flags&=~TextureFlags.FIlterMipmap ‘disable filtering/mipmapping.
it’s a bit messy
why not use your own system and wrap them up nicely in a property, E.G.
image.Texture.TextureFilter = true/false
image.Texture.WrapST = true/false
This would make it a much more friendly approach
 - 
		AuthorPosts
 
You must be logged in to reply to this topic.
