Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How advanced math do I require to create a game engine and shaders

Discussion in 'General Discussion' started by elmar1028, Feb 7, 2016.

  1. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,353
    This thread left me wondering what it takes to develop a game engine.

    And with a game engine, I mean using OpenGL and C++ minimum. Assuming I am going to develop my own renderer and libraries from scratch.

    How advanced can math get while doing so?

    Thanks!
     
  2. landon912

    landon912

    Joined:
    Nov 8, 2011
    Posts:
    1,579
    Quaternions, Matrices, Linear Algebra(Vectors), Projections(matrices), trigonometry, calculus, physics, etc.

    These are the absolute minimum needed for a game engine yourself. That said, you can get solutions to these areas by a quick Google search to get started.

    I wouldn't be too worried about math though. Do you have experience with building and structuring large low level projects? Do you have experience with the countless subsystems working together in a game engine? It sounds silly, but some can't get a solid color window to appear. :p

    Math is the least of your worries, even if it's still a sizable one.
     
  3. goat

    goat

    Joined:
    Aug 24, 2009
    Posts:
    5,182
    I'd say a Bachelor's in Physics and Mathematics to even think of beginning and still using public domain libraries to begin the ports implementing the engine features.

    The math and physics needed can go all the way to PhD and IR&D level.
     
    Kiwasi likes this.
  4. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,327
    You need full and intuitive understanding of vector algebra and trigonometry. Sine/Cosine/etc. You'll need to know how to construct standard matrices, and knowing how to use quaternions will also help.

    Basically, if it takes a split-second for you to remember how to "calculate distance to a plane", "calculate normal for a face", "reflect a vector", "find angle between two vectors" and if you can derive on paper for ray/plane, ray/spehere, ray/box, ray/ray, sphere/sphere, sphere/box, ray/ray intersection queries without significant difficulty and if you can write a subroutine that cleanly slices arbitrary traingular mesh in a half using a plane (even without filling in resulting hole with triangles), I'd say you're good to go.
     
    Last edited: Feb 7, 2016
  5. RockoDyne

    RockoDyne

    Joined:
    Apr 10, 2014
    Posts:
    2,234
    Nine times out of ten the most you need is algebra 2 for some trig and matrix math. The other ten percent can frequently get away with less optimal, but simpler solutions (for quaternions for instance). Then every now and then there is something that takes more from computer science, your BSP trees and graph theory algorithms.
     
  6. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    It's worth mentioning that you need nothing at all of the above for a 3D engine dealing with quads. I should know, I published a game where the engine was developed by myself in 2D without quaternions or vectors or friends, and it was very, very fast.

    So, depends on what kind of game engine we're talking about. I mean, opengl is as easy as it gets and does kind of look after you.
     
    Kiwasi likes this.
  7. goat

    goat

    Joined:
    Aug 24, 2009
    Posts:
    5,182
    Using a game engine and writing a game engine are entirely two different things. If your game engine is going to be rudimentary then OK, but to compete in the future you will need much more advanced knowledge then today's state of the art.
     
  8. Neoptolemus

    Neoptolemus

    Joined:
    Jul 5, 2014
    Posts:
    52
    I suggest you start simple and build up knowledge, rather than buying a massive tome on calculus and just reading it.

    To draw a 3D model like a cube on screen it's actually pretty easy. Brush up on matrix and vector multiplication and learn the concepts behind local/model space, world space, view/camera space, screen space, frustums and so on.

    Once you're happy that you understand the steps to take a model defined with local coordinates and take it through the steps to project them onto the screen relative to the camera, then try adding a free-look camera and movement so you can view the model from different angles. For that you want trigonometry, so when you're ready, start reading up.

    Eventually you'll want to start delving deeper into shaders to handle dynamic lighting, and eventually post-process effects. That's when more advanced calculus comes in (depending on what you're trying to do), but don't worry about that for now as that's way down the line.

    Overall, from my personal experience, I would say that the maths isn't very hard. There's little that you wouldn't cover in high school to be honest. The real challenge comes in the WAY that maths is used, remembering that you're working within limited constraints (capability of the hardware). Over the years people have used relatively straight-forward maths in some really ingenious ways to create the draw dropping effects we see in games today, creating various theorems and algorithms on the way.
     
  9. Polywick-Studio

    Polywick-Studio

    Joined:
    Aug 13, 2014
    Posts:
    307
    The question should be: Who's maintaining the game engine?

    You: Need to know everything.
    Someone else: Just use it. Let the other guy who is maintaining the game engine handle the complex stuff.
     
  10. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    That's never going to be the OP. He's just too late. Engine freaks who get good enough *already did what they could*. This species of developer does not ask mundane questions. He or she has already got stuff moving in C++. That's mindset that's mandatory.

    I wrote a small path tracer for vita using "cascaded" render textures and showed Sony. They seemed to like it a lot, and I did this in Unity, but I did the whole engine thing before and that was unbidden, you just have to have a hunger for it, or a curiosity. You kind of need the inventor gene.

    If anyone's interested in the cascaded texture trick, I plan on writing a blog someday about my adventures in development as I only have time to go so far, so I want other people to look at my wacky adventures. I make these techniques up, it's a joy for experimenting and trying new things.

    I would suggest anyone really interested in engines go for experimenting. Think you can do something better? think out of the box and try it!
     
  11. Neoptolemus

    Neoptolemus

    Joined:
    Jul 5, 2014
    Posts:
    52
    I would disagree. As far as maths goes you would not need to know more than the next guy. What you will need undoubtedly is a very thorough understanding of both the maths AND the technology in use. That will come with time and dedication.

    However, what separates the leaders from the followers is that ability to think outside the box and use the same maths and technology that everyone else uses in a way nobody else thought of. Take Carmack's reverse for example, which made the stencil shadowing behind Doom 3 possible. All he did was change the approach (depth fail rather than depth pass), but he didn't use some advanced mathematical theorem or GPU feature that nobody else knew about.
     
    hippocoder likes this.
  12. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    To be fair Carmack's work is in Unity today. A lot of the lessons he came up with are pioneering techniques that everyone uses. The guy even shaped GPU evolution.

    There's not many Carmacks and he just lives on another plane of existence. Is he a genius? probably for a narrow subset of things - things he enjoys!

    Don't do this if you don't love it.