HN user

ux

1,919 karma
Posts50
Comments87
View on HN
blog.pkh.me 7mo ago

A series of tricks and techniques I learned doing tiny GLSL demos

ux
3pts0
blog.pkh.me 8mo ago

Text rendering and effects using GPU-computed distances

ux
19pts0
blog.pkh.me 9mo ago

Fast calculation of the distance to cubic Bezier curves on the GPU

ux
157pts33
blog.pkh.me 9mo ago

Code golfing a tiny demo using maths and a pinch of insanity

ux
107pts22
blog.pkh.me 12mo ago

Perfecting anti-aliasing on signed distance functions

ux
5pts0
blog.pkh.me 1y ago

The current technology is not ready for proper blending

ux
5pts0
blog.pkh.me 1y ago

Sharing everything I could understand about gradient noise

ux
137pts8
blog.pkh.me 2y ago

Fixing the iterative damping interpolation in video games

ux
127pts53
nopeforge.org 2y ago

Nope Forge Release 2024.0

ux
2pts0
www.nope-foundry.org 2y ago

Nope Foundry Release 2023.4

ux
2pts0
www.nope-foundry.org 2y ago

Show HN: Nope Foundry, a FOSS framework for motion design, 2D compos and VFX

ux
5pts2
blog.pkh.me 3y ago

Hacking window titles to help OBS

ux
3pts0
blog.pkh.me 3y ago

Improving color quantization heuristics

ux
18pts2
blog.pkh.me 3y ago

Porting OkLab colorspace to integer arithmetic

ux
1pts0
blog.pkh.me 3y ago

GCC undefined behaviors are getting wild

ux
9pts3
blog.pkh.me 3y ago

Figuring out round, floor and ceil with integer division

ux
74pts27
blog.pkh.me 3y ago

Investigating why Steam started picking a random font

ux
4pts0
blog.pkh.me 3y ago

Exploring intricate execution mysteries by reversing a crackme

ux
1pts0
blog.pkh.me 3y ago

Deconstructing Bézier Curves

ux
105pts35
blog.pkh.me 3y ago

Invert a function using Newton iterations

ux
1pts0
blog.pkh.me 3y ago

From Roots to Polynomials

ux
1pts0
blog.pkh.me 4y ago

Saving a restic backup the hard way

ux
7pts2
blog.pkh.me 5y ago

The most useful math formulas

ux
6pts0
www.openra.net 5y ago

OpenRA Release 20210321 (and new website)

ux
106pts10
blog.pkh.me 5y ago

Building a Competitive Ladder for OpenRA

ux
2pts0
blog.pkh.me 5y ago

Finding Specific Multimedia Samples

ux
1pts0
blog.pkh.me 5y ago

Story of Debugging a Crash in MPD

ux
2pts0
blog.vjeux.com 6y ago

Make the Game Easy

ux
1pts0
www.openra.net 6y ago

OpenRA Release 20191117

ux
1pts0
www.youtube.com 6y ago

OpenRA Patch Spotlight: Release 20191117

ux
1pts0

Thanks for putting this together.

I'm glad it reaches an audience :)

Only critique is.. if you're sharing to teach, your compact/one line [460] char GLSL code is a poor delivery mechanism.

Understandable. Though, the demos are here to illustrate "what you can do with the trick I'm sharing". It's like, I'm teaching you how to do watercolor, and illustrate it with some paintings you won't be able to perform just with that knowledge. They're meant to inspire you to create. You're not looking at a tutorial, you're looking at art.

What's a good way to get started learning to build/customize shaders with GLSL?

I gave some directions and resources in a comment here, it might help you: https://www.reddit.com/r/GraphicsProgramming/comments/1pgqis...

And GLSL syntax looks a bit tedious to be honest, but I'd love to dive in.

With the vectorization everywhere, it's surprisingly convenient given how simple the syntax is. I personally just miss some sinpi/cospi/etc, and/or a PI and TAU constant.

What you described in your first message seemed similar to the approach used in the degree N root solving algorithm by Cem Yuksel; splitting the curve in simpler segments, then bisect into them. I'd be happy to explore what you suggested, but I'm not mathematically literate, so I'll be honest with you; what you're saying here is complete gibberish to me, and it's very hard to follow your point. It will take me weeks to figure out your suggestion and make a call as to whether it's actually simpler or more performant than what is proposed in the article.

Finding the sign of the distance has been extremely challenging to me in many ways, so I'm very curious about the approach you're presenting. The snippet you shared has a "a³-bcd ≤ 0" formula which is all I get without more context. Can you elaborate on it or provide resources?

The winding number logic is usually super involved, especially when multiple sub-shapes start overlap and subtracting each other. Is this covered or orthogonal to what you are talking about?

Ah nice for noticing d!=0 is d>0. Not sure how I missed the multiplication to get rid of the vector form; I guess I was too obsessed with the x-x trick...

I added your changes to the Shadertoy version with your HN nickname. I'll integrate it to the original later.

Thanks!

This is not equivalent; the `a` in `c.r+=w*a` is different, you need the original untouched w. The mountain looses its crack with your version.

But! You can save 1 char by replacing w with a:

    g -= a*=w,
    c += a*d*9.+...
    a = min(...),
    c.r += w*a*a*.2,
So thank you for the idea!

Yeah. If you want implicit conversion, you need to specify a constructor like float(cond), but that would be longer than the ternary form. I thought about using a vec3() but vec3(...).x is still too long and using the vec3 directly doesn't look viable. Declaring a bool adds more characters as well. There is also step() giving the same number of chars: a=step(.001,h), but it's not more optimal: https://iquilezles.org/articles/gpuconditionals/

If you see a way to make it shorter, feel free to share :)

Ah, someone reported this to me today, but I must admit I have no idea how to address the issue. Currently the canvas animations are stopped when out of context, but yeah they have to be loaded.

The code on the blog is pretty simple and naive (I'm not a webdev): https://github.com/ubitux/scripts/blob/main/share/blog/shade...

Any suggestion on how to address the issue is welcome.

Note: I don't have any Windows machine to test with

Hehe, thanks. The thing is, it could hardly have been prerecorded animations :D

I don't know if you tried before, but compressing noise is particularly hard, so 16 videos would have been quite too much of bandwidth. The total size of the shaders is something around 70kB (not minimized) for endless lossless videos, and since I had to write them anyway if I were doing records of them, it was really a no-brainer to embed them to be honest.

What an impressive and thorough deep dive.

Thanks!

Have any of you ever gotten lost tweaking fade functions to get that perfect wave-like look?

You cannot use anything for the fade function, because you likely want the derivative (and potentially the second derivative) to be 0. See https://gist.github.com/KdotJPG/417d62708c76d53972f006cb906f... for making different ones. I personally never tried anything else than the hermite and the quintic.

1. depends if you're in the physics main loop or not; in Godot for example the physics main loop is based on the project configuration, not correlated with the display (I could have expanded on that in the article)

2. You can know the targeted frame rate, you can also infer it by averaging the delta times at runtime (not reliable but maybe more accurate on a slow machine?)

3. In my graph, I did pick random delta between 15 and 120 fps IIRC; the point was to simulate what could roughly happen with random lag spikes

As the delta time converges to 0, the lerp coefficient is going to converge to 0 as well, meaning it won't move. Said differently, if time stops the interpolation as well. You may enter into the realm of floating point accuracy issues at some point with low values, but I'm curious of what specific scenario you have in mind here?

Author's here.

I'm not sure why this is posted here, but please note that this was written more than 10 years ago, and a lot of things changed since then. It's important to take this article from an historical perspective, keeping in mind that it was written by someone with "interests" in the matter (as much as I wanted to be objective, let's not lie to ourselves, I was a FFmpeg developer first). The popularity of this article played an important role in "public's opinion" (it's my most popular article ever).

Nowadays, even though I've been distant to the project for years now, I can say the situation changed in a good way (from my perspective). The projects are unified again because people from both sides made difficult compromises. I think it would make sense to focus on how the issue was resolved rather that why it was so bad. This fire is extinguished, let's work on keeping things as peaceful as we can.

For the record, I mostly left FFmpeg development years ago. And while it wasn't the only factor, the merge effort and overall tension actually drained me pretty badly at that time. Of course, this is also true for several people from both sides, and surprising to no one the project(s) lost many developers in the process.

The multimedia community is plagued with drama like this, but this one was particularly destructive. We can certainly take lessons from this, but I'll leave that to the historians.

Thanks, yeah the visualization was fun to do. I'll eventually try to cleanup the script I did in a hurry and submit to the research repo along with the others.

WRT to the viewport mess on mobile, I'm not sure what's going on. I did set the width=device-width thingy in the header, and the <video> has a width of 800 (container is 900), but it doesn't seem to honor that for some reason. Webdev definitely isn't my thing, so I haven't looked into it much yet. If someone has a suggestion I'm happy to give it a chance. The same happened in the Bézier article I wrote a while ago, and I agree it's annoying.

I still use Flash 4 years ago

Blending done in perceptual (sRGB) space

Oh please don't say that. The sRGB transfer function may be somehow roughly correlated with how we perceive lightness, but it's in no way a perceptual space.

Floating point operations are not deterministic in other situations: https://randomascii.wordpress.com/2013/07/16/floating-point-...

This can be terribly hard to manage in tests if you don't have a threshold infrastructure in place (which is hard and sometimes impossible to setup if you don't want to preserve huge references).

Also, and this is a bit off topic, even if I remained in the float domain for my use case, I would have to re-implement the lib math routines anyway (in my case cbrt and pow) because they are not implemented the same in all the libc, making them again victim to non determinism.

So far I observed better performance with integer arithmetic anyway, but that's not the reason that motivated me.

Also note that there are other situations were you may want to keep integers; typically in the kernel, or on arch were the floating point is not optimal or even available.