News for hackers. Stuff that matters.

sokmastr

Re:Show HN: Svader – Create GPU-rendered Svelte components on Sunday December 15, 2024 @02:46AM (#42422159)
If the animation engine is capable of smoothly changing a value in JS, I think it would already integrate very well with Svader.

The way the reactive rerendering works, is that every time a change in the input parameters is detected it queues a requestAnimationFrame, so yes, it follows the browser refresh rate.

Since Svelte 5 is automatically able to track changes in values, both by reassignment as well as object mutation, anything that changes a value -- no matter if it's designed for Svelte or not -- should be able to integrate smoothly.

Re:Show HN: Svader – Create GPU-rendered Svelte components on Saturday December 14, 2024 @01:08PM (#42418530)
Yeah, I've been made aware that the examples don't work on iOS. I'm guessing there's a single underlying error that's messing with the navigation etc. since I believe SvelteKit does some JS-based optimizations around navigation. I'll have to look into this. Thanks for reporting!
Re:Show HN: Svader – Create GPU-rendered Svelte components on Saturday December 14, 2024 @11:42AM (#42418072)
That's weird since this very much is a completely plain <ul>. What OS and browser are you using? Which example is slow?
Re:Show HN: Svader – Create GPU-rendered Svelte components on Saturday December 14, 2024 @10:59AM (#42417832)
I haven't thought about it, but I'm open to the idea. What kind of animation engines do you have in mind?

Yes, the absence of 3D is very much a choice. I believe this need is already covered pretty well by existing libraries like three.js and threlte etc. These are relatively large and complex to use, because you essentially have to adopt the mental model of having a whole 3D scene or something like that. With Svader, the mental model is just that you have a canvas with an attached fragment shader, which paints the canvas with respect to some input parameters.

Re:Show HN: Svader – Create GPU-rendered Svelte components on Saturday December 14, 2024 @07:40AM (#42416727)
Talking about the slider specifically, I'm of course not advocating for going out and rewriting all sliders using shaders.

This is just an example of a place where you can use a shader to create a cool, interactive visual effect.

On the example site I've implemented the slider as a regular HTML slider element, and using a canvas to replace its visual appearance. Doing something like this, I don't believe there's anything in the way of getting all the accessibility benefits of a regular slider element, though I could be wrong, I'm no expert by any means.

Re:Show HN: Svader – Create GPU-rendered Svelte components on Saturday December 14, 2024 @07:27AM (#42416630)
Really cool idea with doing it as a web component.

There's also Pocket Shader which is pure JS: https://github.com/braebo/pocket-shader

Re:Show HN: Svader – Create GPU-rendered Svelte components on Saturday December 14, 2024 @07:22AM (#42416608)
Strange. I'll have to look into this.

Thanks for letting me know!

Re:Show HN: Svader – Create GPU-rendered Svelte components on Saturday December 14, 2024 @07:14AM (#42416570)
Even the the example at svader.vercel.app/hello-world/webgl/? Testing on the Safari browsers is currently a TODO, and the library is in general still experimental when it comes to wider browser support, but I would have expected at least the standard WebGL examples to work. Does it at least display the "WebGL not supported" message?

Show HN: Svader – Create GPU-rendered Svelte components

https://github.com/sockmaster27/svader

Svader is a library for rendering 2D shaders on Svelte websites, using either WebGL or WebGPU.It's streamlined for the specific use case of rendering 2D graphics using fragment shaders as an alternative to SVG or the JS canvas API, so it's not meant for doing 3D objects like three.js, for example.This started as something I needed for my own project, but I eventually decided to split it into a...

( Read More... | 42 comments | 53 points | on HN )