This is a true catch 22 if I've ever seen one. I don't believe it's written in BBC basic until I see the code. But I don't want to see BBC Basic code.
Nah but it looks nice. Is the code viewable? I have done very little 3d work, and certainly nothing in Basic, so I'd be interested in seeing how it works.
The code looks complicated. How do you know what values to use and what formulas to use? Can you visualize all those things on your mind before writing the code or it's trial and error? Did you study Math at an advanced level? What was the inspiration behind that algorithm?
So I’m actually a chemistry student with no background in computer graphics, but about 10 years experience writing code in basic. but being a gamer I became very interested in how cgi is done and with covid sweeping the world I suddenly had weeks to kill. I spent a lot of time researching and teaching myself how raytracing works and the maths behind it. Quite simply the program fires vectors into the scene and computes their intersection with objects. It then sends out new vectors towards light sources and if those vectors intersect more objects then the original point is in shadow. It sends ‘rays’ for every pixel and after a few minutes you get an image.
Never heard of BBC BASIC before this but it looks like a really simple language. Obviously OP knows how Ray tracing/path tracing works. The math is mostly (if not exclusively) trigonometry/pythagoras' theorem.
You don't know exactly what the code is gonna be when you start - it's an iterative process: Draw a triangle. Draw a pyramid. Make a light. Put them in a box. Make the light move. Etc.
Ray tracing is a pretty fundamental concept in graphics programming. Only recently has hardware become powerful enough to do nice looking 3-dimensional light ray tracing in real time, so that's probably what you'll find if you Google the topic.
I've heard about raytracing ages ago in a French magazine called PC Team. They had POV (Persistence of Vision) tutorials. Do you know any good resources for beginners about how this thing really work?
Ray tracing is used for more than just pretty graphics, especially in 2D, eg. calculating line of sight and drawing shadows.
There are tons of material online explaining the topic. Just Google it.
If you plan to get into this sort of thing, I highly recommend starting with 2D. Graphics programming is a pretty heavy topic, and it gets unimaginably more complex in 3 dimensions.
I also agree this is in the wrong sub. ShittyProgramming happens out of ignorance or inexperience. This is neither of those. You chose to use basic as a challenge
The light source is not actually white, it’s 3 lights very near each other: 1 red, 1 green and 1 blue. The greenish blue fringe is where the red light is hidden and the red/purple fringe where the green light is hidden
105
u/SireBillyMays Jul 18 '20
This is a true catch 22 if I've ever seen one. I don't believe it's written in BBC basic until I see the code. But I don't want to see BBC Basic code.
Nah but it looks nice. Is the code viewable? I have done very little 3d work, and certainly nothing in Basic, so I'd be interested in seeing how it works.
63
u/pinksheep8426 Jul 18 '20
But this aint shitty
6
u/[deleted] Jul 18 '20
Question: Why are the edges of the shadow maroon and green?
4
u/GearBent Jul 19 '20
What is this running on?
I can’t imagine actually running that on a BBC Micro.
36
u/cpupro Jul 18 '20
I didn't even know Big Black Cock Basic existed.
11
u/[deleted] Jul 18 '20
wrong sub :(
5
u/Otroletravaladna Jul 19 '20
This is definitely not shitty, and the fact you've written it in BBC basic is pretty impressive.
2
u/OceanLinerXLL Jul 19 '20
This is a great sub I've found. I'm the athour of many a shitcode.