Live data from Hacker News

Shaders: How to draw high fidelity graphics with just x and y coordinates

makingsoftware.com

71–80 of 93 posts

Re: Shaders: How to draw high fidelity graphics with just x and y coordinates

#72

I see lots of shader related videos but to me the worst part of GPU code is that the setup is archaic and hard to understand. Does anyone have a good resource for the stages such as: - What kind of data formats do I design to pipe into the GPU? Describe like i'm five texcels, arrays, buffers, etc. - describe the difference between the data formats of traditional 3D workflow and more modern compute shader data formats…

Shameless plug, but I wrote some blog posts because I had a lot of the same questions. In my case, I wanted to learn the WebGL APIs, so I wrote two posts:

* https://avikdas.com/2020/07/08/barebones-webgl-in-75-lines-o...

* https://avikdas.com/2020/07/21/barebones-3d-rendering-with-w...

I still go back to them myself to refresh my memory. It's funny that I called this a lot of boilerplate, but Vulkan is known to have even more.

This won't answer all your questions, but maybe it'll answer some of them.

Re: Shaders: How to draw high fidelity graphics with just x and y coordinates

#73
post #49
post #16

That, I think, is the most unintuitive part about writing fragment shaders. The idea that you take a couple of coordinates and output a color. Compared to traditional drawing, as with a pen and paper, you have to think in reverse. For example if you want to draw a square with a pen, you put your pen where the square is, draw the outlines, than fill it up, with a shader, for each pixel, you look at where you are, calc…

I'd say the unintuive part is mostly a problem only if you abuse fragment shaders for something they weren't meant to be used for. All the fancy drawings that people make on shadertoy are cool tricks but you would very rarely do something like that in any practical use case. Fragment shaders weren't meant to be used for making arbitrary drawings that's why you have high level graphic APIs and content creation softwar…

Don't games make arbitrary drawings using fragment shaders all the time? Clouds, water lava, slime, explosions etc.

Re: Shaders: How to draw high fidelity graphics with just x and y coordinates

#74
post #43

Earlier quoted context omitted.

The Vulkan specification is Open Source. Many Vulkan implementations are not. Vulkan also isn't built on D3D at all, and only MoltenVK (an open-source implementation for Apple platforms) is built on Metal. (Edit: It appears Mesa also now has KosmicKrisp as a Vulkan translation layer for extremely recent (≤5 years) Mac devices.) > WebGPU is available as both a C++ (Dawn) and a Rust (WGPU) library. WebGPU is implemente…

Depends on which extensions, things is with Khronos APIs people always forget to mention the extension spaghetti that makes many use cases proprietary to a specific implementation.

DirectX also suffers from it, to a lesser degree. There are important HLSL intrinsics that are vendor-dependent ( https://github.com/Microsoft/DirectXShaderCompiler/wiki/Wave... or https://github.com/NVIDIA/nvapi/blob/main/nvHLSLExtns.h ).

Microsoft used to be more proactive. It pressured vendors to have rough feature parity with each other and then released the "harmonized" baseline as the next DirectX version. But as with many things, Microsoft dropped the ball there. The most recent DirectX revision is more than 4 years old, and it doesn't look like there's going to be a new one any time soon.

The only truly unified API is Metal, for obvious reasons.

Re: Shaders: How to draw high fidelity graphics with just x and y coordinates

#76
post #24

Nice article, though the diagram showing [OpenGL] [WebGL] [WebGPU] being built on Vulkan and then from Vulkan to D3D12 and Metal is wrong. WebGL and WebGPU go directly to D3D and Metal, they do not go through Vulkan first Also, Vulkan is labeled as Open Source. It is not open source. The are other mistakes in that area as well. It claims WebGPU is limited to Browsers. It is, not. WebGPU is available as both a C++ (Da…

To elaborate on this, Vulkan is an open _standard_ whose many implementations (user mode driver) may or may not be open source. Vulkan is just a header file, it's up to the various independent hardware vendors (IHVs) to implement it for their platform. Also a small correction: Vulkan actually _does_ run Apple platforms (via Vulkan-to-Metal translation) using MoltenVK and the new KosmicKrisp driver, and it works quite…

If you're going to claim MoltenVk = Vulkan on Mac then you might as well claim Wine / Proton = DirectX on Linux.

Re: Shaders: How to draw high fidelity graphics with just x and y coordinates

#77

For anyone looking for some IDEs to tinker around with shaders: * shadertoy - in-browser, the most popular and easiest to get started with * Shadron - my personal preference due to ease of use and high capability, but a bit niche * SHADERed - the UX can take a bit of getting used to, but it gets the job done * KodeLife - heard of it, never tried it

Godot has a shader editor and the effects are updated in real time; another option.

Re: Shaders: How to draw high fidelity graphics with just x and y coordinates

#80
post #24

Earlier quoted context omitted.

To elaborate on this, Vulkan is an open _standard_ whose many implementations (user mode driver) may or may not be open source. Vulkan is just a header file, it's up to the various independent hardware vendors (IHVs) to implement it for their platform. Also a small correction: Vulkan actually _does_ run Apple platforms (via Vulkan-to-Metal translation) using MoltenVK and the new KosmicKrisp driver, and it works quite…

Vulkan also runs on Apple Silicon without translation on linux

It actually requires translation everywhere. GPUs have their own internal API that Vulkan, OpenGL, DirectX, etc. translate into. That is what drivers do.
Post reply on HN