Demo: Rotating Cube On the Homebrew CPU!

Поділитися
Вставка
  • Опубліковано 10 лют 2025

КОМЕНТАРІ •

  • @weirdboyjim
    @weirdboyjim  Місяць тому +1

    Join us on Discord: discord.gg/jmf6M3z7XS
    Follow me on Twitter: twitter.com/WeirdBoyJim
    Support the channel on Patreon: www.patreon.com/JamesSharman

  • @mspeir
    @mspeir День тому +25

    I remember buying a 3D engine development book, "Engines of Creation" by Jonathan Blossom, for the Mac decades ago. The included software was able to draw a 3D scene in B/W using dithering with multiple lights. I thought it was so amazing that it could draw a "real time" 3D scene in 15 or so FPS!🤣 And here you are, building your own computer from chewing gum and paper clips, and can squeeze out nearly 30 FPS with a smooth shaded cube! Bravo!

  • @R.Daneel
    @R.Daneel День тому +21

    One of only a few channels I thumbs-up before watching and have never been let down.

    • @Xylarr
      @Xylarr 22 години тому

      Ha ha, same here

  • @dufflepod
    @dufflepod День тому +3

    An absolute masterclass. I remember programming a wire-frame cube on bare metal 20+ years ago as a learning exercise, but you have put me to shame. Great video. 👍👍👍

  • @JohnScherer
    @JohnScherer 4 години тому +1

    Very nice James! The work involved in this is pretty mind bending to me. 3D transformations in assembler. Really cool!

  • @MeriaDuck
    @MeriaDuck День тому +8

    Brings back 35 year old memories of demo scene coding. Had a friend who was very involved in graphics coding on amiga, pc and later professionally for PlayStation.

    • @weirdboyjim
      @weirdboyjim  15 годин тому

      Very much so, although this is just 8-bit so closer to pre-Amiga hardware.

  • @ruevs
    @ruevs День тому +8

    Beautifully explained as usual!

    • @weirdboyjim
      @weirdboyjim  День тому +2

      Glad it was helpful! It did turn into a partial "intro to 3d"

  • @FrankGevaerts
    @FrankGevaerts Місяць тому +7

    Very impressive work! One day I will actually have to sit down and learn how to do 3D properly.
    That palette timing trick is clever!

    • @weirdboyjim
      @weirdboyjim  Місяць тому +2

      Basic 3D is quite easy when the fundamentals click into place. The palette trick is indeed cool, probably used that most on PlayStation 2!

  • @janschrder
    @janschrder Місяць тому +8

    Jesus! - I'm inline with Peter. I only grasped maybe half of it. Never the less, a beautiful video, that demonstrates, that the really hard part of coding, is optimizing and simplifying as You need to know and understand Your hardware to the very edge. James, You're doing an amazing job. Thanks :-)

    • @weirdboyjim
      @weirdboyjim  Місяць тому +3

      Glad you enjoyed it! I never know if I'm hitting the right level of detail with my explanations of stuff!

    • @janschrder
      @janschrder Місяць тому +5

      @@weirdboyjim Your level is just right. Don't lower the bar. If I need to dig deeper into the subject at hand, all I need to do is go back to one of the relevant videos. I find Your level inpiring 🙂

  • @krustostoianov9792
    @krustostoianov9792 Годину тому

    seeing this result after many months of hard work is truly rewarding and amazing. Keep up with the good work !👍

  • @nolan412
    @nolan412 День тому +2

    Bravo. One difference from my teenage mind and years ago now is I realized lerping. And lots of it in parallel.

    • @nolan412
      @nolan412 День тому +1

      And the 21st century flip from filling pixels inside shapes to querying if each pixel is in any of the shapes.

  • @RayR
    @RayR День тому +3

    Thank you for this comprehensive and excellent tutorial. You have a talent for teaching.

  • @rdwells
    @rdwells День тому +1

    As one who did some fairly low-level graphics early in my career (for a 2D CAD system running on IBM XTs), I can really appreciate the mathematical tricks you pulled out of your hat to get this working. Great job, as usual, and thanks for sharing it with us all.

  • @edgeeffect
    @edgeeffect 14 годин тому

    Wow James, you've blown my mind.
    He's me, thinking myself awfully clever because I've written a bit of assembler for microcontrollers. And then you dump this epic on my desk! "I'm not worthy!" ;)
    And I love the sort-of "cop outs" you've done, like positioning the cube so you don't need to care about clipping. I had a go at very entry-level graphics programming on my 386 back in the days when a 386 was cutting-edge but got disheartened when performance was sloooooow... I wasn't wise to look-up tables and didn't even consider craftily avoiding clipping and such like.
    Splendid stuff!
    ... oh yeah... and the trick to change the background colour as the code goes on so that you've got visual feedback to how long stuff is taking to complete is just brilliant.

  • @MissNorington
    @MissNorington 16 годин тому

    Probably the best video so far! I know most of the 3D stuff, but it is the optimization techniques and ideas that I get inspired with while I am currently working with 8-bit programming

    • @weirdboyjim
      @weirdboyjim  15 годин тому

      Kind words! Pushing very low end systems is always interesting!

  • @baronvonschnellenstein2811
    @baronvonschnellenstein2811 17 годин тому

    Very cool demo and excellent discourse around how it was put together, stage by stage. The snippets of theory are helpful starting points where one might want to delve into the topic further - Cheers!

    • @weirdboyjim
      @weirdboyjim  15 годин тому

      Thanks! Glad you enjoyed it!

  • @missamo80
    @missamo80 День тому +2

    0:21 You should be! It looks fantastic, congrats!

  • @NeoAF10
    @NeoAF10 4 години тому

    Amazing work James, worth the wait! 🤩

  • @GodmanchesterGoblin
    @GodmanchesterGoblin 12 годин тому

    Thank you, James. This was wonderful. I love the way that you walked us through the development process and the many levels of optimisation that you then worked through to achieve the final result.

  • @andythebritton
    @andythebritton 14 годин тому

    Closest I got to anything like this back in the day was (hand-assembled) 6502 machine-code line drawing and flood-filling routines, but this is some next-level stuff. Thanks for sharing.

  • @charlesanthony3248
    @charlesanthony3248 День тому +2

    I recently learned of a quick and easy hardware fill. On each scanline, the pixel color XORs the current color instead of setting it. This allows you to do a fill line by setting just the endpoints of the line.

  • @rueda-roja
    @rueda-roja 21 годину тому

    Instanteneous thums-up before watching :D Very nicely done!

  • @joeysartain6056
    @joeysartain6056 День тому

    Great to hear from you again! Excellent as always.

  • @miege90
    @miege90 День тому +1

    I've written both a rastarizer and a pathtracer in modern languages. I can't even fathom the difficulty of writing it in assembly 🤯 Well done!

    • @weirdboyjim
      @weirdboyjim  День тому

      To be honest, the principles are all the same. It just takes longer

  • @Anticitizen666
    @Anticitizen666 День тому +1

    This is great! It takes me WAY back to writing 3D demos in x86 ASM on the PC for the old VGA cards at the time. A lot of the techniques here are identical (I had no floating point co-pro on my PC at the time, so also used fixed point math!) I remember using phong shading at the time, and using the brightness of the pixels as a primitive depth buffer, to allow objects to merge as they passed through each-other! I foresee a new PCB to DMA polygons to the frame buffer in the future! :)

  • @roboman2444
    @roboman2444 17 годин тому +1

    spinnin cubes are always appreciated

  • @ExcelKobayashi
    @ExcelKobayashi День тому +3

    I don't remember if the video card had a register for setting the base address for the VRAM, but adding/using that could be a nice enhancement that would allow switching the frame buffer in hardware and eliminating the need for copying block copy for the double-buffering.
    Could also update the background clearing so that it only needs to processes the values before/after the min/max X extent of the edges being drawn on a given scanline.

  • @andymouse
    @andymouse День тому

    Always love it when you post a new vid and this one is stunning.....cheers !!

  • @tux1968
    @tux1968 День тому

    This was awesome James. Thank you so much!

  • @koroidX
    @koroidX 10 хвилин тому

    This instantly makes me think of Bresenham's line algorithm, which can be implemented purely with integer arithmetic, and leaves no gaps in the rasterized lines.

  • @alskidan
    @alskidan День тому +2

    That’s what I call a Data-Oriented Design 🎉 I applaud you!

  • @m1geo
    @m1geo Місяць тому +3

    James, you're a bloody wizard! 😍

    • @weirdboyjim
      @weirdboyjim  Місяць тому +5

      @@m1geo my owl must have got lost 🤣

  • @peter.stimpel
    @peter.stimpel Місяць тому +2

    Congrats for another achievement and great video. I like the explanation, even I did only understand half of it :)

    • @weirdboyjim
      @weirdboyjim  Місяць тому

      Thanks Peter! I was very pleased with how it came out, even if it did take me 3 times longer than planned!

  • @sanketsbrush
    @sanketsbrush 6 годин тому

    to be honest , that is coolest and cleanest looking computer.

  • @raven9057
    @raven9057 День тому

    This was great! Well done Sir.
    Subscribed!

  • @Packbat
    @Packbat День тому

    What a cool demo! Congratulations!

  • @wallyhall
    @wallyhall Місяць тому +1

    That lighting trick relying on only 3 sides being visible (so you can “adjust” the lighting on each flat side in the pallet like you described) I did not see coming. And I admire it so much 😀

    • @weirdboyjim
      @weirdboyjim  Місяць тому +1

      Glad you liked it! It was handy!

  • @starc0w
    @starc0w Місяць тому

    Thank you so much James! This is really fantastic and super exciting to see! 🍀✨
    Congratulations on taking this next step!
    Merry Christmas and happy relaxing (if you get the chance).

    • @weirdboyjim
      @weirdboyjim  День тому

      I actually spend lots of time over Christmas writing the guts of another game, you'll see that soon!

  • @malte9999
    @malte9999 День тому +3

    The next extension has to be a vector co-processor.

  • @TheDrunkenMug
    @TheDrunkenMug 5 годин тому

    Hurray, very impressive! 🎉😃

  • @talideon
    @talideon День тому

    The lighting is pretty sweet!

    • @weirdboyjim
      @weirdboyjim  15 годин тому

      Yeah, basic lighting can really lift even basic 3D!

  • @damouze
    @damouze Місяць тому +1

    I really like the result and the explanation of the process you went through to get there. 3D graphics were never my forte (in fact, I try to steer clear of it as much as possible ;-)), but you made it look and sound all so easy!

    • @weirdboyjim
      @weirdboyjim  День тому +1

      Glad you enjoyed it! I've been thinking about doing an introduction to 3d graphics. This kind of touches on some of the basics, maybe I'll do more with Jam-2.

  • @Xylarr
    @Xylarr 22 години тому

    I did a computer graphics class at university back in 1992. It was written in C and had all the matrix stuff you mention there. The problem was that I only had a 386sx computer - so it had no floating point hardware and did it all through emulation. It was slow. My friend had a brand new 486, and I was really happy to see how fast it went on that system.

  • @Krzychu-bh4rl
    @Krzychu-bh4rl 14 годин тому

    I'm very impressed. DIY CPU rendering a 3D object. You can conquer the world :D

  • @jimmy21584
    @jimmy21584 День тому +5

    When’s the hardware rasteriser + transform & lighting coming?

  • @khatharrmalkavian3306
    @khatharrmalkavian3306 Місяць тому

    Merry Christmas, James!

  • @theoriginalrecycler
    @theoriginalrecycler День тому

    Excellent.

  • @gnagyusa
    @gnagyusa 22 години тому

    Awesome!

  • @Kheir2
    @Kheir2 День тому

    a piece of art ❤

  • @Spongman
    @Spongman День тому

    nice demo. you can reduce your clear routine by approximately 50% by only clearing the annulus of those pixels that can possibly _not_ be drawn on (ie. never clear the ones in the center that will always be overdrawn by the cube.)

  • @AJB2K3
    @AJB2K3 18 годин тому

    Congrats, to think this is all in raw and custom hardware.

    • @weirdboyjim
      @weirdboyjim  15 годин тому

      Writing some cool demos (and games) was always the end goal for this project!

  • @miege90
    @miege90 День тому +1

    What's the reason for the fireflies? Also, I'm really missing the screen recordings you did in the vga series.
    The camera recording and youtube compression really can hide some imperfections in the vga output, but I think they are important in understanding the system and it's limits and I'd appreciate more screen recordings 😊

  • @timothyp8947
    @timothyp8947 2 години тому

    Stunning piece of work - and to have it on your own machine you designed & built from scratch must feel quite something. Any temptation to build an extension to perform the matrix arithmetic as new operations? 😉

  • @-lolus-
    @-lolus- День тому

    love it

  • @roboman2444
    @roboman2444 17 годин тому

    7:30
    If dealing with 4x4 matrices, you can concatenate the world->view matrix and the view->projection matrix into one world->projection matrix. Not sure if that concatenation operation will be worth it for only 8 points, but if you start adding in more complex geometry it will definitely help.
    There's probably a way to construct a world->projection matrix directly, instead of calculating two separate matrices and concatenating them together. Just need to go through and do the maths for it.

    • @weirdboyjim
      @weirdboyjim  16 годин тому +1

      That is how you do it on more modern systems but using the 3x4 and doing the projection directly is far more efficient at this scale.

  • @twobob
    @twobob 20 годин тому

    Fire

  • @ianhanschen
    @ianhanschen 18 годин тому

    Way cool

  • @djsmeguk
    @djsmeguk День тому

    Cool demo. Given you have complete control of the hardware, do you think maybe a custom "blit" chip to do some of those graphics manipulations might be useful? It'd be very reminiscent of the Amiga stuff :D

    • @weirdboyjim
      @weirdboyjim  15 годин тому +2

      That’s tricky, Demo coding has always been about pushing the hardware, not sure it counts if I start adding hardware for specific things. I’d rather make good general purpose circuitry and then use it as best as I can.

  • @akioasakura3624
    @akioasakura3624 День тому

    insane

  • @ViniciusMiguel1988
    @ViniciusMiguel1988 День тому

    Amazing James, now add 3D acceleration :D

  • @TrollingAround
    @TrollingAround День тому

    So you only clear the area used by the cube, do you only copy from the back buffer for the same area? Couldn't you combine the the copy and clear routines? Great vid BTW

  • @ToumalRakesh
    @ToumalRakesh День тому

    Oh man, this reminds me of writing 3d graphics from scratch first in turbo pascal, then in C, then switching to GLIDE, then buying the first GeForce 256 when that came out and tossing out all the 3d calculations in favor of OpenGL...

  • @rich_in_paradise
    @rich_in_paradise День тому

    Dude, is that Visual Studio 6? Proper old school!
    Seriously cool stuff though. I was reading through some of the Elite source code recently as someone did a line-by-line explanation of how it all works. My brain still won't let me believe that it's possible to do 3d on an 8 bit computer though :)

    • @weirdboyjim
      @weirdboyjim  19 годин тому +1

      Hah! VS2008, I bought a copy personally years ago, I'll be forced to upgrade one day but I'm always using the latest version for work but for some reason the old version just feels right when working on the retro stuff.

  • @OscarSommerbo
    @OscarSommerbo День тому

    Reminds me of being 14 and using the Amiga to create a rotating square and then cube. But not back face culling or filling just the lines.

  • @Xylarr
    @Xylarr 22 години тому

    I wonder if you could have work out some hardware acceleration for doing things such as clearing the window (or back buffer), setting it to a certain value - or maybe just zero. Call it a memory fill operation. Could you have some DMA type hardware? It could fill and maybe even copy between two memory blocks. I know that on the C64, where you could have extra memory in a cartridge, they often also included DMA hardware to copy (or swap) blocks between the cartridge RAM and base computer RAM. If setting memory to a constant value, could you get it down to a byte per cycle. You'd need lines to assert the bus and/or pause the main CPU while the block fill happened.

  • @NuttySwiss
    @NuttySwiss 20 годин тому

    Sounds like you need a hardware matrix multiplier, or a bit/blit like coprocessor to set/clear/move bits en-mass. Mini amiga. 😎

  • @turbinegraphics16
    @turbinegraphics16 19 годин тому

    Could this be made into a kit that people can make?

  • @ArnCiS96
    @ArnCiS96 6 годин тому

    Will we see multi-cores or GPU for this?

  • @hazypugfluffgaming99
    @hazypugfluffgaming99 День тому

    geat! now can we do the spinning fish meme?

    • @weirdboyjim
      @weirdboyjim  19 годин тому

      Probably best done as a flick book animation rather than 3d rendering on this kind of low end hardware.

  • @MrHamof
    @MrHamof 20 днів тому

    Looking at this, it occurs to me that Elite was designed to run on exactly this kind of computer. It'd probably be way too much work to port it even if the source code is available, but would be cool.

    • @weirdboyjim
      @weirdboyjim  День тому +1

      Not having a true bitmap raster buffer is the biggest thing in the way. Of course 8-bit Elite implementations tended to be line's only as well. Would be fun.

    • @jorvikwitch
      @jorvikwitch День тому

      The original BBC Elite source code is available (with permission) and there's a project that documents the assembly, but yes it would be a huge project to port.

  • @serato_fig
    @serato_fig День тому

    Is flip copying data? Could you have two screen buffers and just update which one is displayed by the hardware?

    • @weirdboyjim
      @weirdboyjim  20 годин тому

      Yes, that would be hardware double buffering. You would need twice as much video memory as is required for a display frame, something I don't have in this build.

  • @jurepecar9092
    @jurepecar9092 День тому

    Now you have a cube, 2nd Reality in what, 3 months? :D

  • @find2hard
    @find2hard 5 годин тому

    Better buy some nvidia puts.
    Cool project dude!

  • @lazerpie101_A
    @lazerpie101_A 9 годин тому

    Vulkan support when?

  • @TheRealBobHickman
    @TheRealBobHickman День тому

    Looks like the spam filter gobbled up my last comment. I also did ZBuffering and have support for vertex shading too. I'm just flat shaded at the moment though, I might look into specular. I can in theory add texturing pretty easily since I did the barycentric coordinate calculation already, but I don't have much RAM for textures, and they might be a but meaningless on a 64x64 pixel object.

    • @weirdboyjim
      @weirdboyjim  19 годин тому

      For you Bob I checked the moderated comments feed, nothing in there for this video so far. Depth buffering is rarely beneficial for efficiency in a software rasterizer, it's usually better to get the faces drawn in the right order. Texturing can work on a 64x64 though, my "Doomed" runs at a 60 pixel vertical resolution. I could do a textured cube rotating on one access with that code.

  • @AlbySilly
    @AlbySilly 17 годин тому

    Would the computer be fast enough to be able to handle bitmap frame buffers if you built the hardware, or is that against the design philosophy for this computer?

    • @weirdboyjim
      @weirdboyjim  15 годин тому

      Sure, although the higher the resolution the more effort it takes to fill it. A resolution like 320x200 like early pc games would be workable but it would need banking to fit into the 64k address space.

  • @jonorgames6596
    @jonorgames6596 День тому

    Could you minuterize this into only a few chips?

    • @olavl8827
      @olavl8827 День тому +2

      You mean the computer he built? That whole thing could easily be reduced to only one single chip. But that's not why we're here.

  • @frognik79
    @frognik79 День тому

    Nice. Add one more side, I dare you. :P

  • @Otakutaru
    @Otakutaru День тому

    So... no textures?

  • @thanatosor
    @thanatosor 13 годин тому

    Look like this CPU actually support an Intel_Syntax Assembly..