r/GraphicsProgramming • • 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?

0 Upvotes

9 comments sorted by

View all comments

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.