Live data from Hacker News

Finding your home in game graphics programming

alextardif.com

71–80 of 128 posts

Re: Finding your home in game graphics programming

#71

Earlier quoted context omitted.

Not only is ray tracing the future of rendering, it's by far the best way to learn basic graphics programming theory, in 100% your own tiny code. I've literally taught a 12 year old this way from absolute scratch, and have been teaching it this way for over 20 years now; it's a bajillion times more upfront complexity to do a rasterisation engine from scratch, so in practice almost nobody does this, and we're back to…

Raytracing is one of those promised techniques that has always been "the future", just like fusion power. The actual future will most likely be various hybrid solutions that (among other things) also make use of the raytracing support in modern GPUs. The triangle rasterizer most likely won't go away, it's a too obvious optimization method, it will just be augmented with other specialized hardware units (like texture…

Hi floh, big fan! :) I agree, RT won't fully displace rasterisation, but the balance of rasterisation versus RT silicon usage will definitely shift over time, and at some point you have enough power for "legacy" rasterisation rendering via RT that it becomes not worth it to include in top end HW.

It's also possible that with high enough pixel density (e.g. 4K 27-32") and a bit of assistance from the tensor units, you can get better performance vs quality through non-uniform/irregular subsampling; a more extreme example of this is foveated rendering[0]. Something like an extension to current DLSS, more in the direction of compressed sensing[1].

[0] https://en.wikipedia.org/wiki/Foveated_rendering

[1] https://en.wikipedia.org/wiki/Compressed_sensing

Re: Finding your home in game graphics programming

#72
I've been trying to learn how to make games in my spare time on-and-off for 20 years (wow time does fly). Here's my postmortem to serve as a warning for younger versions of me.

My first mistake was underestimating how much math one needs to know. Spoiler: it's all math - mostly linear algebra. That's why any graphics / physics / gamedev book has at least one math chapter. You do need it for everything - from coloring something to making things move on the screen.

My second mistake was not making games. One would think that it would be an obvious thing to do, but it's so easy to underestimate the amount of time it takes to understand graphics programming (in retrospect, just the size and weight of the "Computer Graphics - Principles and Practice" book should have been a gigantic red flag). I ended up writing game engine code instead of game code. Being able to draw triangles on the screen is just not as satisfying for me as making cars chase each other and it also doesn't move the needle on getting a game out the door. In practice this translates to maybe reading "Programming Game AI" instead of "Real-Time Rendering" (given limited spare hours) or actually finishing "Nature of Code" instead of reading "Game Engine Architecture".

Arguably my biggest mistake was being stubborn, but not stubborn enough to persevere through all the crap. Early on I didn't want to use an engine because I generally like to understand things from first principles and I didn't understand how deep the rabbit hole went. It turns out that the first principles in game graphics are closer to a collection of progressively more horrible hacks on how to achieve realism in real time without ray tracing, because that's too slow, and how to patch all the side effects of that reality (don't drop a book on implementing shadows on your feet). People with PhDs describe these techniques in scientific looking papers, which then get discussed at large conferences, referenced in books, etc and normalized. Want to learn a new technique? Read the (dense) paper. Other people decide then to take the best hacks, accelerate them in hardware and expose them as APIs. Decades of optimizations and hacks built on top of each other pushed the entry bar higher and higher, to the point where the amount of complexity one needs to wrap their head around is just not realistic for a beginner, unless they are stubborn enough and diligent enough to persevere through all of it. I should have paid that $100 to use the Torque engine, instead of buying the OpenGL Reference Manual, OpenGL Superbible and the OpenGL Shading Manual.

Lastly I fell into the trap of buying the books, but not working on games, aka "all the gear but no f*cking idea". My shelf is filled with highly regarded books that I read and some I gave up on (because they were over my head). I released 0 games. That said it's a good way to discover gems like "The Ray Tracing Challenge" book. Learning new things is fun and addictive.

I came to the realization that I would have really benefited from having a mentor, a well defined and structured curriculum, and being a bit more humble about my own ability to jump into this field, but, most importantly, I should have just made games - crappy looking, never-going-to-make-money, but fun games. That's why learned to code in the first place, after all.

These days I am using Godot and am finding it easy to use, especially after spending all this time fiddling in the graphics world. However, having children greatly reduced the amount of time I can dedicate to this hobby.

It was rather painful and cathartic to type this out.

P.S. I tell myself I'll find time to read "Physically Based Rendering" (another book that would make a whole in the floor if dropped), "Realtime Collision Detection" (more fun math!) and the newest edition of "Real Time Rendering" (its website is a nice resource to find other graphics books to purchase and never read).

Re: Finding your home in game graphics programming

#73

Earlier quoted context omitted.

The guy is unconvincing. I don't believe RAM layout is that important. Of course it can affect perf, but slightly, not by 40%. For instance, Windows has ASLR (address space layout randomization) for security reasons, enabled by default. Microsoft would not do that if it would cost 40% of performance at random. However, there're quite a few random factors. Random choices made by C++ optimizers can contribute about 20%…

ASLR only randomizes a handful base addresses of code and data sections, heap, stack etc..., but it doesn't change how data items or functions are located relative to each other. Memory layout is most definitely important just because memory accesses have such a high latency. This cost may be hidden by prefetching and the cache hierarchy, but keeping the caches well fed is exactly why memory layout matters.

> Memory layout is most definitely important just because memory accesses have such a high latency

Indeed, but that’s not what the video is about. They don’t discuss how to implement cache friendly data structures.

They tell how small random differences introduced by the size of environment variables, and linking order, affect performance. The statement seems to base on that article: https://users.cs.northwestern.edu/~robby/courses/322-2013-sp... The problem with that article, it’s entirely based on one synthetic test. And that test is rather unnatural IMO, that’s not how people are usually writing performance-critical code.

Re: Finding your home in game graphics programming

#74
What should I do if I want to draw 2D lines? I just want to draw nice looking, efficient 2D lines. I am aware there are many high level engines and libraries that let you draw lines, but I have tried them all over many years and they are all bad. This is a serious plea - please help.

Re: Finding your home in game graphics programming

#75

What should I do if I want to draw 2D lines? I just want to draw nice looking, efficient 2D lines. I am aware there are many high level engines and libraries that let you draw lines, but I have tried them all over many years and they are all bad. This is a serious plea - please help.

Check out my free open source book "A bitmappers companion" its a reference book about 2d graphics algorithms with code examples in Rust. https://github.com/epilys/bitmappers-companion

Re: Finding your home in game graphics programming

#76
post #49
post #33

Earlier quoted context omitted.

IMO the article is better advice than the parent comment. Learning from Unreal or even Godot to write a basic renderer is pretty wild. It would be like telling someone who wants to make a model rocket that they should study the Falcon Heavy. Making a basic renderer in c++ is orders of magnitude simpler then trying to deconstruct a game engine that(according to google search) has over 2million lines of code.

If you want to be a rocket engineer indeed the Falcon Heavy is a better study reference than making a fresh design in your backyard. The hard part if learning is figuring out what you do not know. The easy part is reading a tutorial or API documentation.

I would say, a rocket engineer should definitely start with a simple rocket to be designed on their own - before proceeding to something modern and complex.

And I did not study rocket science, but in my CS studies we definitely started with the simple ("hello world") basics, too, before touching real systems, so I would think, they do likewise. Because it makes sense. How can you understand and design something complex, if you cannot even make a simple version of it?

Re: Finding your home in game graphics programming

#77

What should I do if I want to draw 2D lines? I just want to draw nice looking, efficient 2D lines. I am aware there are many high level engines and libraries that let you draw lines, but I have tried them all over many years and they are all bad. This is a serious plea - please help.

On Windows, the best way is often Direct2D https://docs.microsoft.com/en-us/windows/win32/direct2d/dire...

On Linux, you have to do that yourself. The best approach depends on requirements and target hardware.

The simplest case is when your lines are straight segments or polylines of them, you have decent GPU, and you don’t have weird requirements about line caps and joins. In that case, simply render a quad per segment, using 8x or 16x MSAA. Quality-wise, the results at these MSAA levels are surprisingly good. Performance-wise, modern PC-class GPUs (including thin laptops and CPU-integrated graphics in them) are usually OK at that use case even with 16x MSAA.

If MSAA is too slow on your hardware but you still want good quality AA, it’s harder to achieve but still doable. Here’s a relevant documentation from my graphics library for Raspberry Pi4: https://github.com/Const-me/Vrmac/blob/master/Vrmac/Draw/VAA...

Update: if you only need to support nVidia GPUs, they have a proprietary GL extension nv_path_renreding which does pretty much the same thing as Direct2D, but not exclusive to Windows.

Re: Finding your home in game graphics programming

#78

Earlier quoted context omitted.

The guy is unconvincing. I don't believe RAM layout is that important. Of course it can affect perf, but slightly, not by 40%. For instance, Windows has ASLR (address space layout randomization) for security reasons, enabled by default. Microsoft would not do that if it would cost 40% of performance at random. However, there're quite a few random factors. Random choices made by C++ optimizers can contribute about 20%…

ASLR only randomizes a handful base addresses of code and data sections, heap, stack etc..., but it doesn't change how data items or functions are located relative to each other. Memory layout is most definitely important just because memory accesses have such a high latency. This cost may be hidden by prefetching and the cache hierarchy, but keeping the caches well fed is exactly why memory layout matters.

You may be interested by FGASLR, which can do per-function random offsets

Re: Finding your home in game graphics programming

#79
Thanks for sharing! As someone who's not familiar with graphics programming, i would say recommending to start with DirectX is probably the wrong choice: it looks just as complicated as other solutions, but will lock you into the Windows ecosystem. In contrast, OpenGL/Vulkan are widely ported. Same story with the undecided recommendation for Unreal/Unity/Godot: only Godot in those three is free-software, and has an amazing community. Even if you end up using something else in production, it's probably the good place to start since you'll find friendly people and the source code to dig into in case you run into oddities.

As an aside, I was curious about "The technical interview [LEAKED]" but the linked article links itself to dropbox which won't let me download it without an account. If you really want to share that piece of content, maybe consider uploading a copy on your blog or Internet Archive? Thanks for the read!

Post reply on HN