Hi,
I'm trying to make a pixelated "old fashion" game. I want graphics to be pixelated but can't achieve it.
As zooming/scaling in ORX is all blurry, I assume it's not using GL_NEAREST scale method (not that it is what I'm looking for).
Here is what I need. I have 16x16px image scaled up to 64x64px. But I want that 64x64px rendered image use only 16x16 squares so it looks like rendered with low resolution.
I know there are some tricky ways how to achieve this in OpenGL (something like rendering scene in half size, grabbing that result and rendering it all scaled up), but is there a way to achieve this in ORX?
Comments
1. In Display template, if you want your whole game to have pixelated. By default, its value is false. Hence, no pixelated effect, when you zoom in/out a sprite.
2. In your Object template, if you want some of your objects to have pixel effect. By default, it would use Smoothing defined in Display template.
3. In your Graphic template, if you want some of your graphic to be pixelated. By default, it would use Smoothing defined by its Object.
Now, use it according to your need.
Cheers !
I want it to have visible squares like on left side of this picture.
This picture has only 16x16px originally, rendered to bigger size and still is smooth.
You have to make your images like this, otherwise, drawing a smaller version onto a texture and resizing it wont do what you want. I know nothing about shaders, but you can look into alpha testing to discard semi-transparent pixel or any alternative to alpha testing if you are targeting mobile.
So, a good solution to this problem is, if you have rotated sprite in your pixel game, don't rotate the sprite, but use a sprite-sheet, make your rotation an animation, this way you you are in total control to draw your sprite in certain rotation. This is quite easy and result is as expected as you want. This is the only easy solution I can see now. I have seen many developers to apply this techniques to avoid this type of problem.
But thanks for your answers!
http://www.cocos2d-iphone.org/forums/topic/how-to-get-smooth-edge-when-rotating-sprite/
Wow already 13 posts, I'm coming a bit late on that one, sorry!
So yes, you want a pixelated effect, the good news is that it's pretty easy, the bad news is that it depends on which version of orx you are using.
Let me explain myself: I can see two main ways of achieving this effect: either by doing some compositing as you suggested in your first post (rendering to a low res target and then upscaling the result to screen without smoothing, ie. GL_NEAREST) or by using a custom shader.
The custom shader option is the most flexible one as you can easily control different parameters or even warp the "grid" on which the pixels look to be aligned. You can also adapt the effect at runtime to change the level of pixelation (I think lydesik's using that on the title screen of his latest game).
However it's also a bit more tricky to put together than simply doing compositing.
Compositing is pretty simple: you create a texture in memory that has a lower resolution, link it to the viewport that renders your scene, and then reuse that texture on an object that will then be displayed on screen.
There's actually a tutorial on that: http://orx-project.org/wiki/en/orx/tutorials/community/iarwain/compositing
Now, if you're using a very recent version of orx (synced since last week), the whole compositing process has been simplified. Unfortunately I'm still at the hotel with no real internet connection and haven't been able to update the tutorial yet.
If you choose to go down the compositing road, let me know and I'll try to write a quick example very soon.
Jim: Thanks a lot for all the support you've been giving on the forum lately, it's really nice to see the efforts you make to liven the place!
Are you after something similar to this?
I would have been regular here but I had classes in the past as I am done with my undergrad, I have plenty of time at night, coz I have a day job and I am currently in my workplace
Jim: I never really talked about pixel art as I know this technique is all handwork and thus time consuming. I wanted only pixelated "low-res" effect. And it looks like I can get it working with ORX
The compositing as explained in the tutorial will still work with the latest version, it's simply that it is now simpler to do it, but it's optional.
Mainly the intermediate texture doesn't have to be created in code anymore and there's no need for an object in the second scene that renders to screen. I'll post a quick example tonight as I'm on my phone at the moment.
My bad, but the link you gave me confused me. Anyway, doing something old fashioned with advanced opengl techniques is not old fashioned anymore Good luck with your game.
Yea, that's why I used quotation marks
In config:
That's all for config, let's look at the code (really there isn't much).
There you go, you have your two viewports (just make sure the one that creates the intermediate texture is created before the one that's going to use it in its shader ).
The way it works is that when a viewport is created and has a target texture, it'll try to load it from file (or cache if it's already loaded). If the texture's not found, it'll then create a new texture (and own it and delete it when needed) using its current size. If the viewport has no size set, it'll use the screen size instead.
Lastly, the last viewport doesn't render a scene (no camera) so there's no real CPU rendering cost there, however, as it's linked to a shader, it'll render a quad to its target using that shader.
Of course you can add more complexity with more viewports + intermediate textures for lighting or other effects, but in that case everything should be controllable from config, as long as all the viewports are created code-wise, you're good.
If I didn't make any mistakes, that's all you need to setup compositing for your game.
Lemme know if you have any troubles or any thoughts/comments!
Cheers,
Rom
I have just little problem building new version. I can't get working Lua premake script and building with old Makefile isn't working (ORX can't load plugins).
Btw, I am getting an error or warning don't know,
All I did, just added the config part into 01_object.ini, and changed 'RenderViewport' Camera to 'Camera' what was defined in config. Here is my config, http://codepad.org/2NTS0XmK
If you want to access the texture, you can either retrieve it from the viewport (orxViewport_GetTextureList()) or directly with its name (orxTexture_CreateFromFile). Yes, that name is a bit misleading now, I know.
If you retrieve it with the CreateFromFile function, don't forget to delete it when you're done (it just updates internal reference counters).
When you have the texture, get the bitmap from it, unlink it, delete it, create a new one and link it to the texture using the same name.
After that, don't forget to update the size of the viewport as it won't match the new texture.
But as this is quite a lot of things to do just in order to change the pixelation size, you could simply play with the shader instead.
Create the texture as big as needed for the less pixelated version (might even be the exact size of your screen), and then control the size of the visible "pixel" via a parameter in your shader. You can modify that value on the fly by listening to the shader param event.
This approach is also more efficient as there won't be any de-allocation/re-allocation of textures.