• e0qdk@reddthat.com
    link
    fedilink
    English
    arrow-up
    5
    arrow-down
    1
    ·
    12 days ago

    Games need to figure out what color to show for each pixel on the screen. Imagine shooting lines out from your screen into the game world and seeing what objects they run into. Take whatever color that object is supposed to be and put it on the screen. That’s the basic idea.

    To make it look better, you can repeat the process each time one of the lines hits an object. Basically, when a line hits an object, make more lines – maybe a hundred or a thousand or whatever the programmer picks – and then see what those lines run into as they shoot out from the point in all directions. Mix the colors of the objects they run into and now that becomes the color you put on screen.

    You can repeat that process again and again with more and more bounces. As you add more and more bounces it gets slower though – since there are so many lines to keep track of!

    When you’ve done as many bounces as you want to do then you can shoot out lines one last time to all the lights in the game. If there is an object in the way blocking a light, the color for the object you’re trying to figure out will be darker since it’s in a shadow!

    It’s an old and simple idea to figure out what color something is like that by bouncing off objects repeatedly… but it’s hard to do quickly. So, most games until very recently did not work that way. They used other clever tricks instead that were much faster, but made it hard to draw reflections and shadows. Games with those other techniques usually did not look as good – but you could actually play them on old computers.