Skip to main content
10 votes
Accepted

How to handle day and night in a 2D sprite game

The quick-and-dirty solution would be to use a camera filter effect. The color correction curves filter might do what you want. Move the end-points of the R, G and B curve down, but the blue-curve a ...
Philipp's user avatar
  • 121k
6 votes
Accepted

How can I efficiently make a solid Texture2D?

Instead of texture.SetPixel, use texture.SetPixels ...
Philipp's user avatar
  • 121k
5 votes
Accepted

How to get the RGB color values of a clicked pixel on a rendered image in SDL2?

After much scouring the Internet, I discovered this forum post, containing the following code that completely solved my problem. I've abridged it slightly for easy copy-paste into your project. ...
Sciborg's user avatar
  • 604
5 votes
Accepted

How could I do a 2d pixel design in game where you can see though the obstacles/upper floors?

When the sprite is obscured by an object, you could make that object transparent: You can make a sprite transparent in Unity by setting the alpha-value of the sprite color. ...
Philipp's user avatar
  • 121k
5 votes

Drawing a 1 pixel thick line in Unity

Textures mapped onto the surfaces of 3D geometry were developed to represent, well, surface texture. This type of detail usually doesn't align precisely with the grid of screen pixels, due to varying ...
DMGregory's user avatar
  • 136k
4 votes
Accepted

SDL render surface from byte array efficiently

It seems like you have 2 questions here: 1. Why doesn't this code change the surface? 2. Is there a way to do this faster? Why doesn't this code work? For me, opening a window, grabbing the screen ...
Sardonic's user avatar
  • 168
4 votes

In pixel art, should i keep the same color palette for every sprites?

Pixel art is a stylistic choice. How many colours you want depends on the style that you are going for. You might want to limit yourself to 8 or 16 colours through the game to mimic the style of ...
Jack Aidley's user avatar
  • 2,146
4 votes

Why does my 2D + 2.5D implementation look weird?

Firstly, don't rip graphics or IP in general from other games. Even doing this as filler can be problematic as you're going to need to go back through your game later on & check your content to ...
Pikalek's user avatar
  • 12.5k
4 votes
Accepted

Why does my 2D + 2.5D implementation look weird?

The problem is the perspective mismatch between the character and the environment. It is very obvious that they are seen at different angles, which confuses the spatial perception of the viewer. What ...
Philipp's user avatar
  • 121k
3 votes
Accepted

How can I fully or partially colorize a SpriteRenderer and make its "color" value match the end result at 100% opacity?

After much trial and error, I was able to achieve what I wanted by modifing Unity's default "GUI/Text Shader" shader, which I downloaded from here under "Downloads (Win)" > &...
Pikamander2's user avatar
3 votes
Accepted

How to render a grid of dots being exactly 1x1 pixel wide using a shader?

This does pretty well, though I found I needed to add a small fudge factor to avoid dots occasionally winking out when the grid point exactly straddled the border between pixels, but this does create ...
DMGregory's user avatar
  • 136k
3 votes

Why does my 2D + 2.5D implementation look weird?

It has been done before, games like the early GTA titles used to be top-down with 360 directions in a 3D-like environment. Although the camera angle showed both environment and character in one angle. ...
Steven's user avatar
  • 903
3 votes

Drawing a 1 pixel thick line in Unity

There are many ways to create cross-hairs and cross-hair-like effects in Unity. Here are just a few of them: 9-sliced image: You don't need a 2kx2k pixel texture just for a cross-hair. In fact, that ...
CosmicGiant's user avatar
  • 2,114
3 votes
Accepted

In pixel art, should i keep the same color palette for every sprites?

The thing is, it might be either. 256 colors is not recommended mostly due to it being simply overkill for pixel art, since all we need is usually as fewer colors as possible to imitate visual style ...
Ocelot's user avatar
  • 1,433
3 votes
Accepted

SharpDX Texture to Image in C#

I have two methods for doing this I will post them both. Code is in VB.net and using sharpDX 3.0.2 Basically you copy your texture data to a staging resource and then write that staging resource to ...
Justin William Stanley Bryant's user avatar
3 votes

In SDL2 what is the fastest / most efficient way to draw pixels onto the screen? Using SDL_RenderDrawPoint or SDL_RenderCopy with a Texture?

Neither of those: use SDL_LockSurface to directly access directly the surface data. Then changing pixels is changing values in an array, which is fastest.
user1039663's user avatar
2 votes
Accepted

Circular lighting mask stretches to ellipse in Monogame using Pixel Shader

This was a pretty simple error made in my initialization code for the two render targets. The render target mainTarget had a height twice the length of the lightsTarget. When the shader was ...
Ragnoroct's user avatar
2 votes
Accepted

In SDL2 what is the fastest / most efficient way to draw pixels onto the screen? Using SDL_RenderDrawPoint or SDL_RenderCopy with a Texture?

So I ran both Functions 100,000 times (ran it a few times just to make sure), and timed it using time.h . I rendered a simple 1x1 pixel at 0,0 and a texture of a 1x1 pixel at 0,0. Below is basically a ...
Ray C's user avatar
  • 273
2 votes

2D isometric pixel art technique

(Disclaimer: this is a subjective response to a subjective question. That's art for ya!!) All isometric game art is composed from tiles that look like this, can be broken down into tiles that look ...
jodediah holems's user avatar
2 votes

Modern Techniques of Drawing Pixels?

Most of the 2D graphics in modern engines are actually 3D graphics in disguise. The modern GPU is optimized for drawing in 3D; but a 3D rectangle viewed from the right angle is simply a picture in a ...
Felsir's user avatar
  • 4,087
2 votes

How to paint a circle of pixels so that at diameter=3 the result is a cross shape?

Look: Here you see a Circle of 1.5 radius. So it barely touches the outside of the 3 by 3 grid. Now, you are checking a point that is (1, 1) from the center of the ...
Theraot's user avatar
  • 27.5k
2 votes

Extracting cell center and corner points from rasterized Voronoi diagram

It is better to generate a Voronoi diagram as vectors first, e.g. via Fortune's Sweepline Algorithm, then rasterise. If, however, you are dead set on using the rasterised version as a basis, then you ...
Engineer's user avatar
  • 30.3k
2 votes

SDL2 oversized pixels

The answer to this headbreaking problem, when I saw it, was laughably simple. (And the bit of code I needed to see was at the end of a long line, offscreen. Argh!) Here's the scoop: You draw to a ...
Joymaker's user avatar
  • 121
1 vote
Accepted

Godot distorting pixels

The issue, which @Theraot helped me figure out, was that the camera was zoomed at a factor of 0.7, which caused issues since it didn't divide evenly. Changing to 0.5 fixed the problem.
shreyasm-dev's user avatar
1 vote

Palette Swapping in Allegro 5

I'm not familiar with Allegro, but a scan through the documentation turns up the following: al_draw_pixel void al_draw_pixel(float x, float y, ALLEGRO_COLOR color) ...
Pikalek's user avatar
  • 12.5k
1 vote

Looking for a square-to-hex pixel coords algorithm

Convert in-hex coordinates to screen space and work therein, as that is the common pixel space. To know where your pixel-in-a-hex is in screen space, just get the hex's offset (which I presume you ...
Engineer's user avatar
  • 30.3k
1 vote

Parts of sprite disappear when zoomed out

You need to enable Mip Maps and filtering on minimisation. Point filtering drops entire pixels rows and columns when scaling down (zooming out). The downside of mip maps and filtering is your ...
Stephane Hockenhull's user avatar
1 vote
Accepted

Pixel-art sprite distortion with 1:1 pixel ratio

So the problem was that there was some kind of artifact going on caused by how the sprite meshes were constructed. When i changed the mesh type of the sprite to rect - the problem disappeared. Here's ...
sarneeh's user avatar
  • 143
1 vote
Accepted

How to use traditional pixel coordinates system in modern OpenGL? (3.1) (with C++/GLFW)

In modern OpenGL (> 2.0 actually) the matrix stack has been removed . The matrix stack was part of the fixed pipeline. The fixed pipeline (for example, glBegin, glEnd) is deprecated and has been ...
Folkert Hoogenraad's user avatar
1 vote

Java/Libgdx Pixel game with individual pixel changing

I just post this here as i don't have enough reputation to comment; maybe you could use GL_POINTS when doing a glBegin(GL_POINTS); if you use Libgdx (which is ...
cocosushi's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible