8 ms·
Actually we have the same problems and challenges in 3d as well. At the end 3d is result of a 2d image rendered with a projection matrix and others. Stroking is
by fatih-erikli 5y ago
Actually we have the same problems and challenges in 3d as well. At the end 3d is result of a 2d image rendered with a projection matrix and others. Stroking is difficult, for example. You need to combine little triangles to construct a line with miters in 3d, etc.
In my opinion, 3d graphics are harder than 2d for sure. WebGL API is dirty. There's a Webgl, Webgl2, and we're going to have another one: WebGPU, and hopefully it will make 3d easier. In 2d we just have 2d drawing context.
- moron4hire 5y ago>> WebGPU... hopefully... will make 3d easier. That is explicitly not a goal of the WebGPU working group. They have acknowledged that WebGPU will make 3D graphics programming in the browser significantly harder. But it will make supporting the 3D graphics API in the browser easier for the browser developers. So basically, because Apple took over a decade to finally unsqueeze their tight fingers enough to dedicate any developers to WebGL2 in Safari, instead of improving the site developer experience, the W3C has opted to take huge swaths of responsibility away from browser developers and foist it on site devs. The "hope" is that middle-tier libraries like Three.js and Babylon.js will hide the complexity away. I'm sure they will, and by all my experiences with them, will do a fine job of it. But it's certainly not the direction I hoped things would go.
- fatih-erikli 5y agoIn my opinion if we're going to have a stable and a consistent API, I'm totally ok if it's going to be significantly harder. I think we should not need a middle-tier library for creating 3d graphics. Most of the time We needed threejs or twgl for mapping the shader inputs (uniforms etc) with javascript. The rest of it is just pure matrix math, that we do in 2d graphics as well. It's worth to mention that they're also going to create another shading language. https://www.w3.org/TR/WGSL/ https://www.w3.org/TR/WGSL/
- esperent 5y agoThe API may get harder, but that's not a huge deal. Not saying that's a good thing, but APIs are far from the hardest thing in 3D graphics. In my experience using WebGL, the hardest thing is all the missing parts compared to modern APIs and the fact that, whenever you want to implement something, you can't use the newest techniques and have to go hunting around to find out how the game dev community used to do things 20 years ago. I would take a jump in API complexity in exchange for access to a modern graphics pipeline and I'm excited by the new opportunities WebGPU will afford my work.
- deleted 5y ago[deleted]
- bschwindHN 5y agoWebGPU is more explicit, but I wouldn't say it's significantly harder. Sure, if you just want to get a triangle on the screen, it's going to take more lines of code. But everyone builds their own abstractions over the base API, and once you get to that point it's about the same ease-of-use. And that knowledge from the WebGPU API can extend to the desktop with something like Rust's WGPU, where you can author a 3D app once and get a Vulkan, DirectX, Metal, _or_ OpenGL targeted version.
- Jasper_ 5y agoLine miters have no valid interpretation other than a view-dependent one -- the PostScript spec says that miter limit is based on curve angle, something which only makes sense in a flat, 2D perspective. Freya Holmér came up with a set of heuristics that work well enough for Shapes (I helped debug the math a bit there), but you first have to figure out what miter means in a 3 dimensional world, and it's not easy. But yes, you are generally correct. Maybe if I was writing this post today, I'd give it the title "why shapes are so much harder than textures". I also disagree that WebGPU is a worse spec than WebGL 1 and 2. I basically implement a WebGPU-like wrapper for WebGL today in my own WebGL projects, and it's made my life much easier, not harder. Though, full disclaimer, I am a contributor to the WebGPU spec.
- emilfihlman 5y ago>I also disagree that WebGPU is a worse spec than WebGL 1 and 2. I basically implement a WebGPU-like wrapper for WebGL today in my own WebGL projects, and it's made my life much easier, not harder. Though, full disclaimer, I am a contributor to the WebGPU spec. He hopes WebGPU would make things easier. He didn't say WebGPU is worse than WebGL.
- DonHopkins 5y agoI wondered what you meant by Shapes, so I googled "Freya Holmér Shapes" and found this, which is awesome -- thanks for the tip! Shapes: A real-time vector graphics library for Unity by Freya Holmér: https://acegikmo.com/shapes https://acegikmo.com/shapes >It has bothered me for a long time that for some reason, html5 canvas is better at drawing primitives than Unity. I know, right?!? I was quite frustrated by the fact that it was so much easier to draw 2d stuff with html5 canvas than with Unity, that I integrated a web browser with Unity and used it to do 2d data driven drawing (graphing, data visualization, text, and ui widgets) with JavaScript / canvas / d3 / etc, and then blitted the textures into Unity to display in UI overlays and 3d textures. One advantage to that approach is that you can use any of the zillions of excellent well-supported JavaScript libraries like d3 to do the 2d drawing. And I wanted to write as much of my Unity application in JavaScript as possible anyway, so it was easier to debug and (orders of magnitude) quicker to iterate changes (and possible to live-code). UnityJS description and discussion: https://news.ycombinator.com/item?id=22689040 https://news.ycombinator.com/item?id=22689040 Shapes looks really wonderful, and would have been perfect for some of my Unity projects, so I'll check it out and consider using it in the future!
- danielvaughn 5y agoI’ve never understood why the GPU isn’t leveraged for 2D/UI stuff. Isn’t it all fundamentally the same? Vectors and pixels?
- chrisseaton 5y agoThe GPU is used to render UI stuff in any modern system.
- danielvaughn 5y agoWhat I'd really love to see is a UI system that gives developers access to the GPU somehow, but I'm not sure what that would look like.
- ben-schaaf 5y agoLike Direct2D, QPainter (QT) and cairo (GTK)?
- kllrnohj 5y agoLike https://developer.android.com/reference/android/graphics/RuntimeShader https://developer.android.com/reference/android/graphics/Run... https://developer.android.com/about/versions/13/features#shaders https://developer.android.com/about/versions/13/features#sha... ?
- deleted 5y ago[deleted]
- resonious 5y agoI think it is. I see all kinds of 2D projects claiming to be "GPU accelerated" - for example GTK, KDE, web browsers. I'm not sure how much of the actual processing is done on the GPU, but it's enough to call it "accelerated"!
- ben-schaaf 5y agoBrowsers largely make use of the GPU for UI rendering. Direct2D, Cocoa, QT and GTK(4) are all hardware accelerated as well. So not really sure what you mean?