Тёмный

Building ASCII Graphics Engine and 3D Rendering Pipeline in Windows Command Prompt 

Kuba Maruszczyk
Подписаться 85
Просмотров 3,9 тыс.
50% 1

Welcome to my video about programming ASCII graphics in Windows command prompt. All done with just 16 colors. No graphics APIs, no Windows GDI+ and no other libraries. Just a Windows console application. That's it!
This video is an intro to a set of tutorials that I will be posting soon.
In this video, I've included demos of:
- 3D Software Rasterizer (with: simple lighting, skyboxes, clipping, face culling)
- Wolfenstein-style 2.5D Raycaster
- Image Viewer
- 2D Sidescroller with Parallax Background
- and more
All of the code is available on my GitHub:.
Nostalgia ASCII Engine:
github.com/kub...
Texture creator:
drive.google.c... (build)
github.com/kub... (source)
K-Means:
github.com/kub...
Hope you enjoy it!

Опубликовано:

 

12 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 27   
@Kyjor_
@Kyjor_ Год назад
This is amazing!
@davidziemkiewicz1350
@davidziemkiewicz1350 Год назад
This is extremely impressive! Some time ago I wrote a wolfenstein-style raycasting engine in ASCII, used the same method for fast console output, but this is completely next level. One trick I tried that worked pretty well was rendering stuff at twice the resolution and then assigning a character to every group of 4 pixels, so that its brightness in 4 corners matches the pixels. This way, for example algorithm naturally used |, / ,\ for thin lines etc. Of course for resolutions like 320x200 as shown here, that is a bit of an overkill.
@skwiglyman2052
@skwiglyman2052 Год назад
A few months ago, I was also making a 3D graphics engine off of the windows command prompt but I hit a performance wall with texturing and stopped. I just want to know, what speedups did you use for rendering textures and how did you keep your program to such a steady fps? Your engine is amazing and way farther than I thought could ever be done with just the command prompt and I want to say you've inspired me to continue development on my own engine!
@kubamaruszczyk4043
@kubamaruszczyk4043 Год назад
It's great to hear that! I'm currently working on videos describing the nitty-gritty details, but it will probably take a while, so I'll try to give some answers now. There are a few tricks that I've used: (1) Multithreading (a thread pool in this case). To deal with more computationally-demanding cases my engine provides a virtual OnDrawColumn() method. Each call is handled by one of the available threads from the dedicated thread pool. This approach allows for almost full utilization of all available CPU cores. Parts of the rasterizer and raytracer extensions take advantage of this feature. (2) Avoid frequent palette colour changes. I found that the Windows console rendering algorithm is struggling with frequent palette colour changes. So I tried to minimise the number of these changes and instead obtain desired colours by using background-foreground interpolation with ASCII characters. It works quite well, especially at higher resolutions. (3) Luma (intensity) textures. It is somewhat related to the previous point. The engine supports two types of textures: a) luma textures - CSV-based format, where each value is a floating point number from 0 to 1. b) chroma textures - CSV format, where each value is an integer value from (0-16) representing a colour value. These come with palette.txt files, where each RGB triplet represents one of the 16 colour values. Both types of textures can be combined to achieve quite good results. Examples include the ImageViewer. However, in real-time applications, I used luma textures combined with thresholding. This approach gives good levels of flexibility while avoiding colour-switching.
@skwiglyman2052
@skwiglyman2052 Год назад
@@kubamaruszczyk4043 One more thing I want to ask, have you ever considered making this in the newer windows terminal instead of the old command prompt?
@kubamaruszczyk4043
@kubamaruszczyk4043 Год назад
​@@skwiglyman2052 It's an interesting idea. I looked into it briefly. At first, it seemed quite promising, plus the terminal has support for 24-bit colour. However, it turned out to be a bit of a dead end. For example, colours can only be set via VT sequences Also, from what I read, the terminal aims to be compatible with WSL, so much of the win32 API functionality is not supported, for example, direct buffer access.
@ranpix
@ranpix Год назад
thats really amazing! I didnt think it is really possible to make with c# in real cmd app , the reason that i am amazed is because is year or so ago i wanted to make a console game engine with c# that has character rendering like yours (not 3d), but we abandoned on rendering stage because we were really unexperienced and we didnt know which libraries to use (the only helping thing was getting some random dll so we could output different colors in console but it used alot of memory), and you inspired me to continue restore the development :)
@kubamaruszczyk4043
@kubamaruszczyk4043 Год назад
Thanks RanPix! Interop services can be quite useful if you need direct access to some lower level system features. You can find the list of method signatures, types, and other stuff (related to calling Win32 and other unmanaged APIs from managed code) on pinvoke net. It's basically an iterop wiki made by developers. Good luck with building your engine!
@ranpix
@ranpix Год назад
@@kubamaruszczyk4043 thank you :)
@ranpix
@ranpix Год назад
@@kubamaruszczyk4043 by the way you said that windows console only supports 16 colors but there is a way to output any rgb color value, you didnt find it or didnt use it? and if so why you didnt?
@kubamaruszczyk4043
@kubamaruszczyk4043 Год назад
@@ranpix I think I said that you can have only 16 colors at one time :) You can set each palette color to a custom rgb color - which I showcased in the video. This can be done via Win32 API. You haven't specified which particular way you have in mind, so I'm gonna guess that you were reffering to "24 bit console color support" introduced in Windows 10 Build #14931, which was announced here: devblogs.microsoft.com/commandline/24-bit-color-in-the-windows-console/ (correct me if I'm wrong). That's the only alternative that I know of. However, it is not suitable for real time puproses, as it can only be accessed via virtual terminal sequences, which makes is basically useless for real-time graphics. The following sources I've come accross indicate that MS is not planning on providing access to 24 bit color via Win32 API. More details: stackoverflow.com/questions/56006863/winapi-access-to-24-bit-color-on-windows-console github.com/Microsoft/WSL/issues/1118 Because there isn't a way of accessing the console buffer directly with VT sequences, like I did with win32, I couldn't use char+attrib memory buffer for fast rendering. So I guess, technically, there is a way of outputing custom rgb values to console, but it doesn't seem relevant for real-time gfx stuff.
@ranpix
@ranpix Год назад
@@kubamaruszczyk4043 hello, can you please check the spam section? youtube sent my messages because they had links :/
@jh1sc
@jh1sc 11 месяцев назад
Your insanely good! I wish I found this sooner, i also enjoy the native command prompt, and with some C# embedded Code in my powershell code, I have made also a 3d renderer with ascii, and i cant wait to add colour!!
@joeroeinski1107
@joeroeinski1107 Год назад
Really cool, but one nitpick - your mic needs more filtering
@kubamaruszczyk4043
@kubamaruszczyk4043 Год назад
Thanks Joe! There are quite a few issues with my voice over here, it's uneven at times, and I'm too close to the mic. I'll try to fix these in the future videos. Thanks!
@stimpyfeelinit
@stimpyfeelinit 8 месяцев назад
neat
@rinav5684
@rinav5684 2 месяца назад
How do you handle terminal pixels not being 1:1 ratio and distorting whole image ? It will be really helpful, if you could help me with this....
@osloyy
@osloyy Год назад
one tip step back from the mic you don't have to be right next to it feels like your whispering in my ear n it's weird
@kubamaruszczyk4043
@kubamaruszczyk4043 Год назад
A console whisperer :) I agree though. I recorded it with being too close to the mic and then compressed the crap out of it to compensate for the low levels. Somehow it sounded better on my setup at the time.
@L_ona
@L_ona 8 месяцев назад
This is awesome!
Далее
Jump King Modding Tutorial: Hitboxes
31:49
БЕЛКА РОЖАЕТ?#cat
00:28
Просмотров 314 тыс.
GenAI Roadmap - Job ready AI path
8:13
Просмотров 914
Adding Web Browsing to GPT-O1
6:55
Просмотров 54
БЕЛКА РОЖАЕТ?#cat
00:28
Просмотров 314 тыс.