How I Created a Voxel Raycaster in Python...

  Рет қаралды 7,080

Gpopcorn

Gpopcorn

Күн бұрын

Try out CodeCrafters.io:
app.codecrafte...
Voxel Space GitHub (by Sebastian Macke):
github.com/s-m...
Comanche gameplay credit:
• Comanche gameplay (PC ...
My microphone (affiliated):
tinyurl.com/2h...
KZfaq growth tool (affiliated):
vidiq.com/l4fp...

Пікірлер: 64
@dungeonrobot
@dungeonrobot Ай бұрын
For performance you should rewrite it in Rust and then hand $5,000 in cash to me immediately. This will surely improve your FPS
@lukasjetu9776
@lukasjetu9776 Ай бұрын
hey, i want some too
@dungeonrobot
@dungeonrobot Ай бұрын
@@lukasjetu9776 Always happy to lend some performance. I’ll cut you a sweet deal too: $3,000
@JJoe1
@JJoe1 28 күн бұрын
after making it in rust do it again in C++ as it is just a bit better (le joke)
@ThankYouESM
@ThankYouESM Ай бұрын
Cache Combine Distant Voxels: when more than one voxel looks like a single pixel.
@Lexxaro
@Lexxaro Ай бұрын
Some Ideas on optimizing: -Profile your code! If you don't know what's actually slowing down your program you'll probably spend huge amounts of time just optimizing small things that aren't actually the bottleneck of your program. And in the worst case you'll even slow down parts of your program. -Make sure your using library calls correctly. My personal experience with python graphics is very limited, but it could be that the calls to functions drawing your image and presenting it are taking much longer then expected. In graphics programming generally when rendering the image try to keep calculation of the image and presentation seperate. Hand the rendering API only the finished image as memory operations are much more expensive than math operations. -And lastly: If you're actually trying to get comparable speeds, you will need to use a faster language, like c/c++/rust. It may seem daunting at first, but in the end they are also just programming languages and thus more similar to python than not. Your rendering code for example could look nearly identical. And by using all the high level features provided by the standard libraries of these languages you don't have to be some kind of wizard to use them. Well I'm interested to see what you'll code in the future!
@The-python-guy
@The-python-guy Ай бұрын
Dude I had a choice between 2 amazing youtubers and well looking I noticed you, ofc I have to click God bless your sorce code on a textured raycaster helped me so much. funny enough I've used that exact same voxel pixel renderer that your showing on the screen right now to make a doom clone deathmatch shooter that me and my bother love Amen man wish you well
@super3dcrafts
@super3dcrafts Ай бұрын
1000 subscribers! Gratz!
@FinFET
@FinFET Ай бұрын
Pretty coool, I would suggest using numba to speed things up
@michaelgalin7373
@michaelgalin7373 21 күн бұрын
This guy knows
@poptre67
@poptre67 Ай бұрын
i think you could optimize it by using a different coding language and using parallel processing
@yovo7499
@yovo7499 10 күн бұрын
bro was like 'refrain from mentioning parallel processing' but since you can separate and calculate all the verical lines independently of each other you can just use numba in parallel for one of the loops. You have to reorder your z and x loops though, so that you go first through each vertical line and then for it you go through each z distance. For the same resolution that you set and with render distance of 2000 I got like 700-800fps...
@shifteleven
@shifteleven 10 күн бұрын
Is there source for this code he and you did?
@electrobean
@electrobean Ай бұрын
Also, this is coming from someone writing a Vulkan renderer for fun, so take this with a grain of salt, but OpenGL is not very hard to learn. Some of it doesn’t transfer great to Python, so if you really want it to go fast I’d honestly say moving to Kotlin (likely using LWJGL’s OpenGL bindings) would probably go reasonably well considering you know Python already.
@coleslater1419
@coleslater1419 Ай бұрын
this reminds me of a spoonkid video, this is wonderful
@anzo.7806
@anzo.7806 Ай бұрын
First of, what I don't see a lot of ppl mentionning here, is to try identify what truly makes your code slow down... Forget about implementing x or y blindly. Without knowing what kind of issue you are addressing (memory banwidth ? Too much computation ?) you are not going to make significant improvement. So get a python profiler, learn a bit how pygame works (bc imho you may be calling its graphic api in an very unsufficiant maneer), and see which functions calls slow you down. Then, and only then try to think about optimization : Is computing the square root too much ? Maybe try an approx. Is blitting one pixel after another too expensive ? Maybe try to coerce chunk of colors together. etc etc.. Finally, when this repeated over and over, and you can't get much more, only then should you consider multiprocessing (which is a whole another beast on its own) That's how I would do it. Have fun !!!
@_Zie_
@_Zie_ Ай бұрын
I think you could try and divide the map into chunks and use parallel processing 👉👈 Using chunks for render distance and LOD might be able to really cut down on the number of distance calculations you need. Or you could pre-process chunks in different LODs, using more memory space but cutting down on the number of calculations you have to do every frame?
@Gamedevanimatorbunny
@Gamedevanimatorbunny Ай бұрын
Wow make this more popular get this guy to 1m subs
@ThankYouESM
@ThankYouESM Ай бұрын
Binary Meshing (Cache): 0 = space. 1 = voxel... create a pre-calc rotation dict()
@ginodianna-h1z
@ginodianna-h1z Ай бұрын
you need to blow up i love your videos
@ThankYouESM
@ThankYouESM Ай бұрын
Avoid the use of floating point numbers altogether when rendering in gameplay by using dict() cache or memoization.
@jasm0_0
@jasm0_0 Ай бұрын
one optimization technique is to use c++
@axiomgd5416
@axiomgd5416 Ай бұрын
you could try running it with pypy its an alternative python implementation thats quite fast and very compatible with cpython code
@ThankYouESM
@ThankYouESM Ай бұрын
Just in case still too slow no matter what you do... have Javascript with JSON creating temp (buffer overwriting) PNG1 + PNG2 to do all the heavy lifting so it reads like MP4 streaming instead.
@oneomany
@oneomany Ай бұрын
why's young garfield teaching me python
@ThankYouESM
@ThankYouESM Ай бұрын
Speeding Up Python Code With Caching - kzfaq.info/get/bejne/ZsWZmNmGq5awj3k.html
@ThankYouESM
@ThankYouESM Ай бұрын
Maybe use resize * 16 + PIL blur to create the height map
@moldybot9387
@moldybot9387 Ай бұрын
Using a jit compiler should improve performance drastically
@blaz2892
@blaz2892 Ай бұрын
Now do it in C
@Person-who-exists
@Person-who-exists Ай бұрын
Try running it in pypy. Pypy is just a python interpreter but is much faster than cpython.
@felixhartl4813
@felixhartl4813 Ай бұрын
PLEASE USE THE NUMBA MODULE!!!
@moonyl5341
@moonyl5341 Ай бұрын
2:29 y'uore're*
@BiuerBoris
@BiuerBoris Ай бұрын
I bet Shoriminimoe has some great optimization tips
@wijiler5834
@wijiler5834 25 күн бұрын
Make it in c and vulkan with hardware raytracing (very fun trust me)
@SNOUTxTOUT
@SNOUTxTOUT Ай бұрын
rendering with the experimental _sdl2 module in pygame-ce should speed things up a lot as it will draw using the GPU i've seen some performance increase using pypy with pygame too
@electrobean
@electrobean Ай бұрын
I’m sure people have already said this but please just profile before listening to anyone’s suggestions, fix what’s slow not what looks slow.
@DavidRobichaud-c2j
@DavidRobichaud-c2j Ай бұрын
Great work!
@hillybankok
@hillybankok Ай бұрын
use parrallel processing.
@link1581
@link1581 23 күн бұрын
He should add multithreading 😆
@thoughted6069
@thoughted6069 Ай бұрын
Do rendering on the GPU please. Use a graphics API with python bindings. Rendering on the CPU is a goddamn crime. Yet alone rendering on a CPU with python!
@user-zo1kn8ob7h
@user-zo1kn8ob7h Ай бұрын
please try nonperpendicular processin
@LLDJ_
@LLDJ_ Ай бұрын
why does this only have have 76 views 😭😭
@ulixir
@ulixir Ай бұрын
time to switch to lua boy 300x the performance frfr
@1ups_15
@1ups_15 Ай бұрын
how much faster do you think this could get if you did all the calculations using numpy?
@ThankYouESM
@ThankYouESM Ай бұрын
How Sets Can Truly OPTIMIZE Your Python Code - kzfaq.info/get/bejne/ocV4o5d0krW1nYE.html
@tochukwuukpabi901
@tochukwuukpabi901 Ай бұрын
wow, just wow
@MuffinTastic
@MuffinTastic Ай бұрын
i'm thinking of two words and they both begin with the letter p
@user-zo1kn8ob7h
@user-zo1kn8ob7h Ай бұрын
2:45 and java xD
@mokouu
@mokouu Ай бұрын
what the hell man dont find me
@cvabds
@cvabds 26 күн бұрын
I bet you can't create it on templeOS
@brunobaur
@brunobaur Ай бұрын
Use C++ 😂
@krikusZ80
@krikusZ80 Ай бұрын
Shaders pls, just use shaders of any kind, compute shaders or fragment… you can save up so many resources by using them for other cool stuff and allow it to run on any potato
@sjoerdev
@sjoerdev Ай бұрын
why python tho......
@theplaneguy45
@theplaneguy45 Ай бұрын
cool! please never code graphics in python again! thanks!
@D01Light
@D01Light Ай бұрын
Python isn't that slow
@theglowpt3
@theglowpt3 Ай бұрын
wait until you find out about the GIL
The biggest lie in video games
15:18
AIA
Рет қаралды 1,8 МЛН
Why Devs NEED TO know about Render Matrices!
11:31
Kaze Emanuar
Рет қаралды 62 М.
Kind Waiter's Gesture to Homeless Boy #shorts
00:32
I migliori trucchetti di Fabiosa
Рет қаралды 12 МЛН
Look at two different videos 😁 @karina-kola
00:11
Andrey Grechka
Рет қаралды 14 МЛН
黑天使遇到什么了?#short #angel #clown
00:34
Super Beauty team
Рет қаралды 44 МЛН
天使救了路飞!#天使#小丑#路飞#家庭
00:35
家庭搞笑日记
Рет қаралды 88 МЛН
I Added Infinite Crafting to Minecraft (with AI)
13:08
Blucubed
Рет қаралды 1,3 МЛН
Can AI Code Minecraft? Watch ChatGPT Try
8:06
BadGameDev
Рет қаралды 1,3 МЛН
AutoHotKey - Voxel Space 3D Game
10:30
Spawnova
Рет қаралды 5 М.
I Made a Voxel Engine
10:33
Zyger
Рет қаралды 49 М.
Making a difficult game about fitting in - Acerola Jam 0
19:17
jess::codes
Рет қаралды 345 М.
Do Video Games Fake Buoyancy?
17:08
Acerola
Рет қаралды 229 М.
I Made an AI with just Redstone!
17:23
mattbatwings
Рет қаралды 955 М.
Making a Voxel Engine from SCRATCH (w/ Destruction)
14:31
MaxMakesGames
Рет қаралды 33 М.
New Maze Generating Algorithm (Origin Shift)
6:32
CaptainLuma
Рет қаралды 79 М.
Как бесплатно замутить iphone 15 pro max
0:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 9 МЛН
how to make soler led bulb | How do you use a soldering iron first time?
1:00
Nk creative experiment
Рет қаралды 2,3 МЛН
Запрещенный Гаджет для Авто с aliexpress 2
0:50
Тимур Сидельников
Рет қаралды 1,9 МЛН
Слетела прошивка на LiXiang L7
1:01
Настя ЧПЕК Туман
Рет қаралды 4 МЛН