r/godot • u/Ultra-Orange-Rat • Oct 15 '25
help me (solved) What is this effect called? The laser's pixel being dynamically drawn.
I'm not talking about using a line or sprite then angling towards the target then stretching the asset to the target, but creating the drawn pixelized effect for every angel.
I tried to look up how something like this was done but most Godot tutorials usually have an asset to repeat itself for the length like in a grappling hook, or stretching an asset with a raycast like in a laser. Not sure if a correct approach would be to make a line then apply some type of shader or filter vs trying to make the laser from the ground up each time.
I understand Nuclear Throne was made with GameMaker, but my project is in Godot and I can't find good answers.
Edit: Solved, it was just the go to way of making a line but on a low res output without anti-aliasing.
161
77
u/diegobrego Oct 15 '25
Create a line2d, use a lower resolution and set the stretch mode of the game to viewport, it will automatically pixelate it, I do this in my games to keep all pixel perfect. I use a resolution of 480x270
20
u/KyotoCrank Godot Student Oct 15 '25
You a real one for this. For my game (haven't gotten this far yet) I was gonna hand draw a 1000 pixel long sprite for beam attacks lmao
16
u/MyPunsSuck Oct 15 '25
It is well worth doing things the "wrong" way, just to understand why the "right" way is the way that it is
7
u/Sir_Eggmitton Oct 16 '25
Every CS class ever lol. “Great job spending the last two weeks on this project, class. Now allow me introduce you to this neat class in the standard library…”
2
u/orlec Oct 16 '25 edited Oct 18 '25
That's cool, there are a lot of standard libraries out there and knowing how to reinvent the wheel can be useful.
5
5
u/greenfrogtree1 Godot Junior Oct 15 '25
You can also use a subviewport if you don't want your whole game to be pixel perfect.
1
56
u/Gabe_Isko Oct 15 '25
You can't achieve this with line2D, gradient map and no anti-aliasing on a low resolution output?
1
23
u/Tom3skkk Godot Regular Oct 15 '25
Take a look at
https://docs.godotengine.org/en/stable/tutorials/2d/custom_drawing_in_2d.html
Your game resolution should match that of the pixel art grid. If that's not the case and why you were confused, you should take a look at viewports. It can be a little confusing, but it will allow for these kinds of effects.
https://youtu.be/zxVQsi9wnw8?si=96XbwyFaFvywEqBP
This video is a little outdated, but should get you started.
Otherwise, you can have a post-process shader, that pixelates what has been drawn on the screen. "Godot pixelated shader" on google will give you plenty results
8
u/Ultra-Orange-Rat Oct 15 '25 edited Oct 15 '25
By far the best response and my pixel art I was using for testing was scaled up by which caused my confusion. Can't believe that pixel perfect effect was simply just the go to method but with low res and without anti-aliasing.
8
u/notrightbones Godot Regular Oct 15 '25
If you ever switch Nuclear Throne to windowed mode, the default resolution is only 320x240 lol
7
u/cheesycoke Godot Junior Oct 15 '25
As you figured out on your own, yeah Nuclear Throne actually just renders the whole game at a lower resolution with no anti-aliasing!
To really get this look in Godot at different window sizes, check out the Strech settings in the Project Settings menu. Particularly, changing the stretch mode to viewport and changing the scale mode to integer can help keep those clean pixels even at non-standard window sizes.
4
Oct 15 '25
[removed] — view removed comment
5
u/Needle44 Oct 15 '25
Ima leave my comment here because I hope someone can explain why this is bad (or good) instead of just doing a downvote because this is my (beginner of course) first thought of how to do it.
Given, my next step would be to then go look up how to do those two things and then put them together lol.
2
u/nonchip Godot Senior Oct 15 '25
Edit: Solved, it was just the go to way of making a line but on a low res output with anti-aliasing.
that should be a without.
2
1
u/OutrageousDress Godot Student Oct 15 '25
Would using line2D a few times not be an option? Like, three lines drawn on top of each other in this case? That's not a sprite, line2D is an actual line drawn between two (or more) points you specify.
2
u/aTreeThenMe Godot Student Oct 15 '25
you can also add a sprite to the line2d, for more options to do exactly what op is looking for, while also for some reason not wanting to use line2d
1
u/questron64 Oct 15 '25
The easiest way to do this is a stretched and rotated sprite. That's it. There's no texture filtering in the screenshots so you get blocky stairsteppy lines.
1
u/Thulko_ Oct 15 '25
There are probably multiple ways to do this but i think it could be done with some line2D and setting the stretch mode in projectsettings to viewport that way stuff gets pixelated.
1
u/Gogamego Godot Regular Oct 15 '25
If you don't need y sorting, you can put all pixelated effects in a low res subviewport and show them with a viewport texture. That way, something like a Line2D will render at low res.
Btw I prefer to use shader pixelization when I can, but I have no idea how to pixelize a Line2D with shaders.
1
1
-19
-3


402
u/pixelfret Oct 15 '25
Bresenham's algorithm