It has been a while. No major progress in development. This is just a small technical tip.
As you all know, when creating a pixel art game in defold, all you have to do is change the “Texture filtering and sampling” from linear to nearest in game.project
> Graphics
, but in the case of my game However, my game has a mix of normal resolution backgrounds and pixel art characters. In this case, what should I do to render the screen beautifully?
After some experimentation, my conclusion is that I can get the desired results by rendering the pixel art sprite as nearest and linear for the others.
How to do it. It is simple, just change the Samplers of the material attached to the pixel art sprite as follows
In my environment, it can only be displayed in this hard-to-see state. For reference, the code is pasted below.
(sprite.fp
and sprite.vp
are not modified.)
sprite.material
name: "sprite"
tags: "tile"
vertex_program: "/sandbox/player/sprite.vp"
fragment_program: "/sandbox/player/sprite.fp"
vertex_space: VERTEX_SPACE_WORLD
vertex_constants {
name: "view_proj"
type: CONSTANT_TYPE_VIEWPROJ
}
fragment_constants {
name: "tint"
type: CONSTANT_TYPE_USER
value {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
}
samplers {
name: "texture_sampler"
wrap_u: WRAP_MODE_REPEAT
wrap_v: WRAP_MODE_REPEAT
filter_min: FILTER_MODE_MIN_NEAREST_MIPMAP_NEAREST
filter_mag: FILTER_MODE_MAG_NEAREST
max_anisotropy: 0.0
}
max_page_count: 0
One problem with this method is that when the camera is zoomed in/out, linearly drawn objects (in my case, other than the character, i.e., background) are sometimes blurred. To solve this problem, control the zoom value with a precise value, such as 0.5, 0.75, or 1.25, to avoid blurring.
Maybe I can render this more cleanly with the Sharp Sprite - RGSS for Defold, but for now I will continue to develop it as is.