Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The most popular modern graphics (GPU) APIs are DirectX 12 (Microsoft), Metal (Apple), and Vulkan (Khronos Group).

Targeting all three can be tough, hence WebGPU which lets you write to a single API. Support on non-web runtimes have been appearing as well, so you're not necessarily limited to the browser (e.g. https://github.com/samdauwe/webgpu-native-examples).

Good read: https://surma.dev/things/webgpu/

Tutorial for learning Vulkan: https://www.vulkan.org/learn#vulkan-tutorials



To be honest though, if you are just starting out and don't have experience on things like homogeneous coordinates, shaders, and the basics of real-time rendering, just learn damn OpenGL. learnopengl.com is the titular "bible" site and you will learn most of the basic concepts there.

I really do not recommend DX11 / DX12 / Vulkan / WebGPU, just because of the fact that they don't have that much good learning resources compared to OpenGL. Even DX (though more widely used in the gaming industry) doesn't have that much material compared to OpenGL. People often point at RasterTek's tutorials (https://www.rastertek.com/tutindex.html) for DX stuff, but the explanations are much more sparse compared to LearnOpenGL and they often just dump lines of code at you without any high-level explanation. And I especially do not recommend Vulkan (or DX12), because it's a hell of an unfriendly API that exposes too much of the underlying GPU hardware for the programmer to manage (especially with synchronization). Writing Vulkan in a naive way will probably give you less performance than what you will achieve with naive OpenGL / DX11. And using Vulkan in an optimal way isn't something that's explained in any Vulkan book or tutorial you can find online/offline: they generally teach how to do simple stuff (like drawing a triangle, which is essentially what learnvulkan.com does), but do not really teach you with the more important architectural decisions when writing a performant renderer (this I am currently struggling, and searching through blogs/papers/videos as much as possible).


This, OpenGL (ES) 3 is the one; VAO is the last feature!


this is super helpful! I'm a self taught web dev that wants to dive into 3d graphics programmer, but its super difficult to find material that doesnt assume a lot of pre req I have no idea about. its difficult to figure out what to even learn. its like not knowing what I don't know situation here.


Reality check: WebGPU is not shipping yet. Browser supports varies - dev preview (Chrome), far from preview with big missing pieces (Firefox), tumbleweeds (Safari [1]). If it's anything like WebGL, it might take many years after shipping to be a good dev target (tooling, major browser bugs and regressions, missing support depending on end-user hw, Safari lagging other browsers by 5 years like with WebGL 2, etc).

WebGL 2 on other hand works today and is about the only way to do portable 3d (unless you use higher level engines). .

[1] apparently a preview appeared in Safari tech preview releases in 2019 when Apple was trying to argue for more Metal style API design in WebGPU, but since disappeared from there. https://developer.apple.com/forums/thread/692979


Forgot to mention: also the WebGPU spec itself is unfinished.


samdauwe's work is fantastic. We're using WebGPU in Mach engine, and also have quite a large set of examples for how to use WebGPU from Zig[0] that are pretty much standalone (only use our engine for windowing/input), may be a bit easier for folks to run (zero-fuss installation, you can cross compile seamlessly to any OS, etc.):

[0] https://machengine.org/gpu/


links to the github examples are all busted: https://github.com/hexops/mach-examples/tree/main/cubemap

also, for a cross-platform tool i expected that clicking the images would take me to live demos that work in a browser, not mp4 and png files.


Thanks - we're in the process of redoing the whole site so I didn't notice those were busted. Fixed now :)

Our browser support is still a work in progress (and browsers don't support WebGPU yet), so we primarily run on windows/linux/macOS natively right now. Once that improves we will replace them with actual browser demos.


Are you into graphics? Vulkan and DX 12 are not what you start with to learn modern graphics programming. One thing, you should realize by modern they mean use modern graphics pipeline programming instead of an immediate mode API. So “Modern OpenGL” is modern graphics programming and actually it is sufficient for many cases but not for AAA real-time graphics but learning DX11 or Modern OpenGL is the right place to start.


worth mentioning that Vulkan is the only API that runs on all three major platforms. Natively on Windows and Linux, via MoltenVK on MacOS.


Vulkan has a lot going for it these days, but IMO the problem with its future is that (a) it's too verbose to use without an abstraction on top and (b) vendors won't stop pushing their native APIs as a competitive advantage (Microsoft still pushing DirectX - often getting features a year or two ahead of Vulkan, Apple is pushing Metal, GNM[X] from Sony, etc.)

I think this means the future of graphics APIs is software abstractions around the truly native APIs (DirectX, Metal, etc.) - things like WebGPU, sokol_gfx, SDL's new GPU abstraction, and Sebastian Aaltonen's stuff.


Shame though that by the time you've gotten your first cross-platform triangle on screen in Vulkan you'd already be finished covering Windows and macOS via D3D11 and Metal, and with fewer total lines of code ;)

(D3D11 is not a typo, unfortunately D3D12 isn't that much better than Vulkan in that regard)


I know you mean major desktop platforms, but in terms of market share for real time 3D applications, mobile and console dwarf Mac and Linux.


Yeah, but mobile means Linux and Apple, and console means Windows, BSD, and whatever Switch is, Vulkan works across pretty much all of that. Actually, considering Zink exists, OpenGL may be the most universal...


Zero Vulkan or OpenGL on PlayStation and XBox.

On the Switch if your really want the full 3D capabilities, NVN is the answer.


Middleware runs on more platforms, with more friendly tooling.


Middleware is a better option, given consoles support, and being the way studios have always dealt with multiple API support.


Is “Middleware” the name of a graphics library? Or are you talking in general, saying that using an intermediate library is better than using the platform’s API?


An intermediate library like Ogre3D, or more full blown engines like Unreal/Unity/Open3D and so forth.

All of them use the platform's API to take advantage of all features, while providing a more high level of 3D programming concepts.


I understood this to mean things like Unity


That’s a bit of an over generalization. Many studios do not, and many more have not always used middle ware to deal with multiple APIs.


Sure, many studios also only do console exclusives, while other studios specialize in porting services, for example.


> Targeting all three can be tough, hence WebGPU which lets you write to a single API.

And which doesn't exist (except behind a flag, will probably ship in Chrome 113). And the spec already has over 1500 issues (over 300 still open).

So... It's not "targeting three graphics APIs is tough, target just WebGPU". It's "here's a third incompatible graphics API for the web (after Canvas and WebGL), and people may expect you to also support it an addition to non-web APIs"


You can already use WebGPU today, if you're targeting something other than the browser. There's already game engines & graphics libraries being made thru one of the WebGPU implementations, and you can always start using it now after some setup. wgpu (Firefox's) for Rust or Dawn (Chrome's) for C/C++/Zig.


> You can already use WebGPU today, if you're targeting something other than the browser.

Why would I?

> There's already game engines & graphics libraries being made thru one of the WebGPU implementations, and you can always start using it now after some setup

Again, what's the point? Just to say "oh look I can"?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: