- Home /
Pixel-art styled line generation.
Hey there,
I'm working on a 2D game using pixel art style. I chose to use 2D Toolkit. The pixel art style requires to display fake big pixel on a pixel grid then everything will look aligned. To simulate old games, you can't display an object not aligned with the pixel grid.
Everything was cool until I needed to display lines onscreen. I tried to use a line renderer then I tried to generate my own line mesh but the renderer can't stop smoothing things up if the resolution allows it. Here is what I have so far. ![alt text][1]
As you can see the blue line is not "jagged" enough. It clearly doesn't fit the pixel grid.
Do you know how I can achieve such "effect"? I just want to display things in a way they are not smoothed or distorded due to the high resolution. I just need to make pixel art :)
Thanks for your time.
Perhaps with some math, you could use your line renderer to draw a zigzag line?
You mean like an anti-anti-aliasing algorithm? :) Wouldn't it be overkill ?
Answer by FredericRP · Sep 13, 2013 at 03:35 PM
You could write your own line renderer using Bresenham's line algorithm, it's quite fast. With that, you can draw a pixel texture using GUI.DrawTexture or maybe put some "pixel sprites" in 2D Toolkit render queue (I don't use 2D Toolkit so I don't know if it's possible) ?
I actually found this right after your answer : http://wiki.unity3d.com/index.php?title=TextureDrawLine
looks like I forgot that link but still remembered the algorithm ;)
Your answer
Follow this Question
Related Questions
How to create a line renderer with end point as the mouse position, but facing only one direction 0 Answers
Issue with close point in line renderer 1 Answer
Trail Renderer detection 0 Answers
Is it possible to import Nurbs from Rhino / 3DSMax into Unity 1 Answer
Rendering large amount of lines 2 Answers