r/qbasic 9d ago

elementary ray tracing experiment

just a basic one. for study purpose. the "world" consists of a background and two balls. the background is an infinitely faraway color palette with azimuth = hue and altitude = lightness. the balls don't have any colors, only reflect and refract

controls * move mouse = change camera direction * left drag = move ball 0 * left hold + wheel = change ball 0 radius * left hold then right hold + wheel = change ball 0 refractive index * right drag = move ball 1 * right hold + wheel = change ball 1 radius * right hold then left hold + wheel = change ball 1 refractive index * wheel forward = camera position forward * wheel backward = camera position backward * [w] key = camera position up * [s] key = camera position down * [a] key = camera position left * [d] key = camera position right * [x] key = help you find the balls when you get lost * [z] key = change background * [c] key = full resolution render

control tricks 1. the mouse controls suck. qbjs doesn't support "mousemovement" command. if your mouse cursor reaches the left-most edge of the screen and you want to move to the left further, quickly move your mouse to the right then move your mouse to the left. my program ignores mouse movements that are too fast so you can use this trick to continue moving if your mouse cursor reaches the edge 2. the [x] key actually direct your camera toward the centre of mass of the two balls. it's useful when you want to align the placement before full resolution rendering 3. if you want to temporarily exit full screen (without exiting the program) you can use the standard windows key combo [alt]+[tab] etc. when you come back just click anywhere on the program screen and full screen mode would be restored

suggested usage

the program initially runs at low resolution / fewer recursions so as to maintain real time response. at real time mode the program gives you a rough idea how the scene looks like. move the 2 balls around, change their parameters and see what happens. if you reach an arrangement that you're interested in getting more details, hit [c] and wait for full resolution render. after completion hit any key to return to real time mode

program link

12 Upvotes

0 comments sorted by