Live data from Hacker News

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

makingsoftware.com

81–90 of 93 posts

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

#81
post #73
post #49

Earlier quoted context omitted.

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.

They do, but would usually use more detailed geometry instead of doing everything in a fragment shader. For example, water would need geometry matching lakes and rivers, vertex shaders to move the geometry to make waves, and fragment shaders to make it look like water.

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

#82
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…

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

Not really! The difference is MoltenVK (and now KosmicKrisp) is officially supported and funded by Khronos itself.

DXVK, vkd3d on the other hand is propped up by dozens of passionate open-source contributors.

I'm drawing my lines not based on technicalities, but on the reality of the situation when it comes to how much the "controlling entity" of each API cares about supporting your platforms. And the fact is, Khronos has put time and money into supporting more platforms than Microsoft has.

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

#83
post #74
post #43

Earlier quoted context omitted.

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…

Agreed, and your had a more easy example at hand, XBox DirectX, versus the PC world.

The point is that many that argue Khronos APIs are portable, don't seem to have deal how portable they actually are in practice, just like POSIX is portable only to certain extent, or Web standards (which then many just ship Chrome with their app).

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

#85
post #36
post #33

Earlier quoted context omitted.

> Vulkan is an open _standard_ That too kinda depends on where you draw the line, the spec text is freely available but all development happens behind closed doors under strict NDA. From an outsiders perspective it doesn't feel very open to get completely stonewalled by Khronos on the status of a feature that debuted in DirectX or CUDA well over a year ago, they won't even confirm whether it's on their roadmap.

Sure, that's true and a pretty valid criticism of the system. My definition of open is that Khronos doesn't restrict (as far as I know) what platforms Vulkan can be implemented on. The same cannot be said for DX12 or Metal.

DirectX 12 headers seem to now be published under the MIT license, so I don't see a real difference from a "who is allowed to implement it" perspective.

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

#86
post #12

Obligatory "this painting is a mathematical formula, a big function on the x and y coordinates of each pixel" video from Iñigo Quilez. https://www.youtube.com/watch?v=8--5LwHRhjk

The one where he does a landscape is one of my favourite videos of all time.

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

#87

Shaders technically don't even know their X and Y coordinates by default unless you specifically provide those, just as you can provide other coordinates (such as U and V for surfaces) or other values in general (either varying / input attributes, like fragment coordinates typically are, or uniforms, which are the same for every invocation).

>Shaders technically don't even know their X and Y coordinates by default unless you specifically provide those im kind of a boomer regarding shaders but isnt gl_FragCoord always available?

No, that is OpenGL specific and only if using GLSL, other shading languages expect such values as explicit parameters, for example in WGSL it is @builtin(position) that you are to bind to a specific variable.

    @builtin(position) fragCoord: vec4f

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

#88
post #62
post #9

Does anyone have any resources for learning how to do very beautiful clean technical drawings like this? I have some art skill but not the kind that translates to such clean technical drawings with this nice personality. Would love to be able to make some for my own projects.

From the home page: Question: How do you make the illustrations? Answer: I get asked this more than anything else but honestly, I don't have a good answer. I make them by hand, in Figma. There's no secret - it's as complicated as it looks. The Advanced Edition of the book will include a tutorial explaining how I make them, where I get references and inspiration from.

lol I should've noticed that. Thanks for pointing it out.

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

#89
post #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…

Thanks, this helps. Do VBOs map 1:1 to meshes? Is there some point where I'm looping though meshes and sending every mesh to a VBO?

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

#90
post #80

Earlier quoted context omitted.

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.

That's being disingenuous. Of course a high level api has to be implemented in terms of hardware specifics, but you're implying, hopefully unintentionally, that that hardware interface is Metal, and it's not.

You can run Vulkan on Apple Silicon as natively as you can run Metal, even if some parts of it don't map too nicely to the hardware.

We only seriously say translate when we go from one high level API to another, just like we call some compilers transpilers even though literally everything is a compiler for something.

Post reply on HN