Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Image blurring when using draw_rot
- By johanati Date 2010-05-30 02:37
Hello, I'm trying to create a game with a retro look, so I need to be careful that my pixels look crisp.

When I draw an image using Gosu::Image.draw_rot (default parameters, angle 0), there seems to be some blurring/anti-aliasing. Using Gosu::Image.draw, it looks perfect.

I made a quick example using a Mario sprite, see here: http://img541.imageshack.us/img541/8573/drawrot.png

Any tips on what I could do to prevent this blurring, or what would be causing it?

Thanks!
- By BlueScope Date 2010-05-30 02:48
Rotation aliasing normally happens when the interpreter tries to render something to imaginary positions (as you only get exact coordinates for 90° rotations normally). Some image processing programs, however, show that aliasing also for exact rotations (90° steps), in which case I guess the exact rotations aren't excluded from aliasing or whatever...

Either way, what you're asking for is completely disable rotation aliasing, isn't it... that would make your sprites look incredibly cluttered, unless you're using a scaled up image (aka each "pixel" actually has 10x10 pixels, for example). But as aliasing normally adds up to an image's appearance during rotation, I wouldn't necessarily deem it an unwanted feature.
- By jlnr (dev) Date 2010-05-30 03:27

> Any tips on what I could do to prevent this blurring, or what would be causing it?


draw_rot will center the image on x/y, so if you use an odd width or eight, that may just cause it. (Effectively drawing the image at xxx.5 or yyy.5)

Of course, that only applies to angle=0, for other angles, the rotation will still be what OpenGL makes of it. I am not sure how rotations look with the (undocumented ;) ) Gosu::enabled_undocumented_retrofication feature. If they still look too new-school with that, you can only pre-render really oldschool rotations.
- By johanati Date 2010-05-30 03:35
I can see why (and wouldn't have a problem with) aliasing when there's some rotation involved, I was hoping that the level of aliasing would be dependant on the amount of rotation though. Ie. 0 rotation = no aliasing, 1 degree rotation = slight amount of aliasing.

I don't think it'd be good for me to try to switch off aliasing entirely, because as you pointed out, it definitely has its place.
- By johanati Date 2010-05-30 03:35
Thanks jlnr, I'll take a look at that..
- By johanati Date 2010-05-30 05:06
Just confirming that giving the image even dimensions worked perfectly, problem solved. Thanks, guys.
- By ippa Date 2010-05-30 19:52
Gosu::enabled_undocumented_retrofication  ftw :) .. glad someone else then me needed it too ;)
- - By mathias Date 2010-05-30 22:11
ippa:

> Gosu::enabled_undocumented_retrofication  ftw :) ..
> glad someone else then me needed it too ;)


I used it too, but implemented it myself at that time :)
What I don't get is: Why didn't jlnr already document it? ;)
Parent - - By kaBOOM Date 2010-12-18 05:24
I want it. Whos willing to share?
Parent - By Spooner Date 2010-12-19 19:04
I use it too; I guess he just thinks that he doesn't want to support it if it goes wrong?
Parent - By jlnr (dev) Date 2010-12-19 23:29 Edited 2010-12-19 23:53
The syntax is clearly temporary, as soon as there is a new syntax I'll document it. But for now I don't want anyone to depend on the specific way it's activated.
- - By kaBOOM Date 2011-01-26 13:57
I really need my retro style graphics... :)
Anyone willling to share? nahpr2@hotmail.com
Thank You
Parent - - By bestguigui Date 2011-02-02 20:03
In fact, there is an efficient way to prevent ANY BLURY effect to get your pixellate render of choice (which is mine too !). But there is a big drawback.

You have to use OpenGL to setup all your textures, which (this is the drawback) have to be power of two :(
All you have then to do is to add this to your Sprite class initialize method :

glBindTexture(GL_TEXTURE_2D, your_sprite.gl_tex_info.tex_name)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)

Then any operation will be full pixels, no blur at all.
Parent - - By jlnr (dev) Date 2011-02-03 03:07
That is exactly what the 'Gosu::enable_undocumented_retrofication' method is doing. BTW you can do this without power of two textures, no problem. :)
Parent - - By kaBOOM Date 2011-02-04 05:58
Hi. I'm so stupid. Until a couple of days ago, I didn't realized all I had to do was put "Gosu::enable_undocumented_retrofication" in my code to get the rsults I wanted. I was thinking it was a method with lots of necessary arguments "a la" draw_rot.
Thanks good sir. I love GOSU.
Parent - - By bestguigui Date 2011-02-04 19:50
I don't see what Gosu::enable_undocumented_retrofication refers to, I'm no native english and don't understand what it represents exactly, can you explain it to me ?

BTW, my method didn't work on textures not power of two because Gosu::Images that are not power of two don't have a gl_tex_info method.
Parent - - By Spooner Date 2011-02-04 23:17
retrofication is a made up word meaning to make something "retro" in style. That is, pixellated. By not blurring images, it allows for indie-style retro blocky graphics, without forcing the user to use a very low screen resolution .
Parent - - By bestguigui Date 2011-02-05 08:25
Thanks a lot for the explanation, it's just a huge method !
Parent - - By jlnr (dev) Date 2011-02-05 09:03
Also, it's supposed to be used in a "rescue" block because it will disappear as soon as there is a proper interface to do the same thing.
Parent - - By bestguigui Date 2011-02-06 08:34
Could you explain what this method does exactly, after creating the same effect I wrote earlier ? Maybe I'm coding lots of things you took care of with it ! I don't see this method on Gosu RDoc, usually I'm able to look at those points alone :)
Parent - - By jlnr (dev) Date 2011-02-06 09:35
It does exactly what you posted above for all textures. Just use it like that: "begin; Gosu::enable_undocumented_retrofication; rescue; end". It's undocumented on purpose because it will be part of the new Image constructors later. You can use it to play around in the meanwhile though.
Parent - - By bestguigui Date 2011-06-26 21:48
Hi Julian !

Can you explain how to use this feature ? I don't want to use Ruby-OpenGL anymore, but I really need pixellate zooms. Please, help ! :)
Parent - - By jlnr (dev) Date 2011-06-27 04:17
Just like the code I wrote above. You can call it once after startup, in the Window constructor or directly after require 'gosu'.
Parent - By bestguigui Date 2011-06-27 07:02
Hi Julian ! I was trying that code into the draw method, which didn't work. I put it under require "gosu", now it works ! Perfect !

Thanks a lot !
Up Topic Gosu / Gosu Exchange / Image blurring when using draw_rot

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill