r/GraphicsProgramming • u/ExcitingBig3309 • Jul 15 '24
Unity or OpenGL
I want to get into graphics programming. I know the math and am experienced with programming. I now want to get into Computer Graphics. Which is better to learn CG concepts, Unity or OpenGL?
5
u/susosusosuso Jul 15 '24
If you want to make a game: Unity. If you want to make a game engine then OpenGL and then direct3d 12, vulkan or metal
3
u/corysama Jul 15 '24
Here's the list of links I give everyone getting started in graphics programming in general.
The main thing you need to know is https://fgiesen.wordpress.com/2016/02/05/smart/
There's a lot to learn regardless of which API you use. Once you can do an animated character in a scene with lighting, shadows and basic full-screen post processing, you'll know how to proceed forward on your own from there.
https://realtimerendering.com/
https://google.github.io/filament/Filament.md.html
https://fgiesen.wordpress.com/2011/07/09/a-trip-through-the-graphics-pipeline-2011-index/
4
u/coding_guy_ Jul 15 '24
Unity is good if you want to learn just shaders. If you want to do the full pipeline opengl is better.
1
u/Curious_Associate904 Jul 16 '24
This sentence is about as sensible as "I want to get into architecture, a degree or lego?"
In all seriousness, and Thor on the old tubeule would back me up on this, writing game engines is not something that people do lightly, and if you're writing your own game engine you need a really good reason to do so.
1
u/zenoskip Jul 16 '24
Theres a great tutorial for Unity on raytracing which quickly lets you get the initial stuff over.
That being said, there are a lot more textbooks for OpenGL.
1
u/Klutzy-Bug-9481 Jul 15 '25
Hey I know I’m late to the party, but do both.
Learning unity to have a good understanding of the math and theory and than diving to the low level side of stuff with openGL and possibly making a raytracer.
With this you aren’t singling yourself out and can still make games with other people that don’t wanna nor don’t know how to use the APIs and you can still make a game engine with the ones that do. Also gives you the ability to have the skills for many jobs.
1
u/ArmmaH Jul 15 '24
It so happens that you can get the best of both worlds:
convenience and features of unity (import, mesh and texture formats, compression, serialization, editor, debugger, etc etc),
opengl using the unity Graphic API https://docs.unity3d.com/ScriptReference/Graphics.html
C# is easier than C++ as you dont have to worry about memory management either.
This is simply a layer / wrapper over opengl, it mostly follows opengl logic. You have most of the things you might need like blit, bind, draw, clear, etc.
If your final goal is to become a graphics programmer you should at some point get rid of those unity crutches and get to wriring everyting from scratch, but if you are just beginning your journey it can be overwhelming so I think this can help quickly experiment and iterate over popular techniques. Its realiatic to implement a major feature in a day this way using unity infrastructure and framework, instead of spending weeks chasing an obscure error, uninitialized memory, undefined behavior etc.
For more modern APIs like DX12 / VK this would not work and youd have to give up on unity and roll from scratch.
1
u/ArmmaH Jul 15 '24
There is also https://docs.unity3d.com/ScriptReference/Rendering.CommandBuffer.html, which isnt as close to opengl, but still can be very useful if you just want to do graphic techniques.
11
u/msqrt Jul 15 '24
Depends on what exactly you want to learn. If it's more on the math/theory side, Unity might be better as it lets you easily visualize things and focus on the concepts, but OpenGL will give you more of the programming side of things with handling buffers and such yourself. There are other options too, like writing your own software rasterizer (if you want to really know the full pipeline from .obj to pixel), or WebGPU which is a pretty nice new API -- there aren't as many resources available, but the API itself is quite a nice combo of a more modern design without going extremely verbose and low-level.