We have seen Ray tracers that run in Excel or on a calculator and I have also done similar projects on my channel now a very interesting challenge would be to create such array Trace in Minecraft with redstone Redstone is super basic it can be on or off one or zero which means We have to do everything from scratch Thank you so this is the final image that I rendered it doesn’t look like much but these points that you see here are actually eight spheres that are being rendered with a ray traced camera system so this is a fully functioning 3D environment and here’s a blender Simulation of what it would look like we can move around by changing the coordinates of the camera we can move forward up and down and left and right and we can do the same in Minecraft we just have to enter different coordinates here in the back so let’s enter these Three coordinates here but we have to use binary and let’s start the rendering and as you can see the pixels here at the top are being rendered and this is very slow every single Pixel takes like five minutes to calculate even with mods to speed up my game and To render this first whole image I had Minecraft open in the background for more than a week or so people have built other 3D renders in Minecraft in the past like this one and they used a technique called rasterization so what is the difference between this and a ray Tracer in the First case we start with the 3D points of our object and we first project them onto a flat plane our screen and now we basically have 2D coordinates so now we can draw the image into D for example by connecting the points with lines and This is very fast and that’s why we use it in real time applications like video games the ray tracer on the other hand kind of works in the opposite way we start at the screen and for every pixel we shoot a so-called camera array which we then intersect with the objects in Our scene and this array then returns data that we can use to color this pixel and this is extremely slow because we have to do this for every single Pixel and that’s why in the past we could only use this for offline rendering like blender cyclists of course we could make This Ray Chaser more complex we could add lighting Ray Trace shadows and Reflections just as we did in my tutorial series we could basically create a full pass Tracer even with redstone but this would be insanely slow and nobody wants to do that just to give You an idea to render this simple scene as a 64 by 64 image we would need to calculate many thousands of square roots divisions and multiplications with redstone even a single division can take many seconds to calculate so I really needed to do some optimization I simulated this whole thing in blender it Looks very complex but mathematically it is very simple for example I got rid of other square roots and now we are left with only the most basic operations like addition subtraction multiplication and division and some other operations like bit shifting which are extremely fast and simple I used 20 bit integers which Means every number is represented as 20 zeros or ones 20-bit integers give us enough Precision to render the scene at a resolution of 256 only after that we start to see artifacts next I had to build this in Minecraft I highly recommend the tutorial series from matpat Wings which gave me a good Introduction to Redstone and many parts of this build are based on these tutorials I started with the carry cancel adder and expanded it to 20 Bits And if we look from the top this basically looks like an addition node in blender here we have the two inputs and Here’s the output which gives us the result of the addition and every number is represented with 20 bits stacked vertically and you could actually take the output signals and connect them to the input socket of another node now from this Adder I made a subtractor multiplier and divider I also built some Other components for bit shifting memory and so on now if we want to calculate something like our Ray Tracer we could chain all these components together just like the blender nodes and we would get the correct output but that’s not a good approach for many reasons instead what If we could build some sort of redson computer which we can give a set of instructions a program and it then executes this program automatically the most simple way to do this is to just connect all the inputs and outputs with one single wire now let’s say we want to Multiply two numbers and so let’s say they are stored in these memory cells which are also connected to this main data wire to multiply a and b we first open a and let this data flow out and now the number a is in this Redstone Wire now we want to input a into the multiplier so we accept the data here in the first input slot and now a is stored in here then we open the memory cell that holds B and we accept B in the second input slot and now the multiplier Does the calculation and then it outputs the result also into this main wire and now we can do whatever we want with this result for example we could store it in another memory cell or we could input it into another function like the addition component for example so this thing can Execute any series of additions or multiplications you want now all these instructions for example the instruction open a could be triggered by its own Redstone signal and we could put all these wires on one side and depending on which wire we power a specific instruction is executed for example if We power this wire a opens now we can program this whole thing by defining a pattern of instructions that will power one of these wires after another and this is very similar to how this Ray Tracer works we have different functions that are all connected to this main Redstone wire here and there are 35 different instructions that control this whole thing now this module here stores the whole program it contains around 280 lines of code so 280 instructions and when I start the whole calculation process I send a redstone pulse into this module and it will return this pose In the lane that I specified in the code and this pulse will then execute the specific instruction inside the machine after that the pools will then return back here to execute the next instructor so a single pulse is constantly cycling through this whole system and executes One line of code after another and to complete a single image over a million Cycles have to be completed in conclusion this was a very interesting project it has all kinds of problems and you could spend a lot of time optimizing it but the main goal for me was to learn How basic binary operations work and how to turn them into something that can be programmed to calculate basically anything you want Video Information
This video, titled ‘I built a 3D RAY-TRACER using REDSTONE (Minecraft) + Download’, was uploaded by georg240p on 2023-03-26 22:49:19. It has garnered 230269 views and 10252 likes. The duration of the video is 00:07:09 or 429 seconds.
My Tutorial Series: https://www.youtube.com/watch?v=jcdERB5gRYo (Building a Raytracer from scratch with Blender Math Nodes)
Map Download: https://www.mediafire.com/file_premium/cnhsifzm0jzx8vr/mc_raytracer_georg240p_1.19.2.zip/file (It takes like 200+ hours for one image to render, even with Carpet Mod which speeds up your game)
Some people in the comments said that what I built is actually a Pathtracer, Raycaster and one guy thought this was Raymarching. I’ve had this discussion for years. Using the names introduced in the old original papers has become very confusing. Today, Raytracing is mostly used as a very general term, and both Pathtracing and Raycasting are listed as a subset. e.g. Wikipedia’s page about Raytracing: “…ray tracing-based rendering techniques, such as ray casting, recursive ray tracing, distribution ray tracing, photon mapping and path tracing, …” Wikipedia’s page about Raycasting: “…, see ray tracing (graphics) as both are essentially the same technique under different names. Scott Roth had invented the term “ray casting” before having heard of “ray tracing”. ” Raymarching usually just means that the intersection is computed iteratively by stepping along the ray in small increments – I’m not doing that at all.
What I built is bascially a “Raycaster” – the most important part of a “typical” Raytracer, it shoots the primary rays into the scene. The problem with calling it raycasting is that today people associate that with something that is very different from what I built. e.g. If you search for “raycasting” on google images, you only find Wolfenstein 3D stuff, which is actually only casting rays in 2D, which are used to define the height of 2D collumns to give the illusion of a 3D environment.
What I built uses the exact same camera system as a typical Raytracer, but I do not shoot any further rays for reflections or shadows – I thought about rendering one sphere and a reflective floor plane – but that would not look good on a redstone lamp display. I need to build a better display first, that can display multiple shades of gray without dithering. I decided for rendering 8 spheres in a cube formation so that it can be compared well to rasterization.
The main motivation for me was to learn binary arithmetic, and building a simple programmable computer. And Minecraft Redstone is perfect for learning such things.
This build is actually not that complex, the only reason why nobody built a Raytracer before is that it’s super slow and you can get better looking images with traditional 3d rendering (rasterization).
This was my first time actually using Redstone for something more complex than opening a door. A lot of things could be optimized… especially the individual components like the adder and multiplier are not synced so a lot of time is wasted in between instructions.
Big thanks to @mattbatwings for their amazing Redstone Tutorial series. Many parts of my build are based on these tutorials.
Music at the Beginning: Giving Up – JVNA (YouTube Audio Library)
Chapters: 0:00 – Intro & Reveal 1:31 – Traditional Rendering vs Raytracer 3:31 – Building it in Minecraft 4:27 – Redstone Computer Explanation 6:20 – Implementation in Minecraft