problem about shader

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Lesommeil

I have seen the hollow knight main character shader when gets damaged and near death. It was really nice, and I want to know how to make it, but without proper idea. I am trying to copy hollow knight for learning purposes, so I want make the shader too.

What I say is black circle.
player is hurt

near death

Hope someone can give me any ideas, or just give me the code.
Also, I really want to learn shader to make a beautiful scene and to be a powerful shader programmer, so I want to get advice here for someone who wants to begin.
thank my middle school math teacher I am bad about math. but I love it since I was a child.

:bust_in_silhouette: Reply From: DaddyMonster

The little black circles floating upwards behind the character?

Now you absolutely can do that with a canvas item shader. You can multiply the UV, deduct 0.5 to put the origin in the centre and take the fract component, the use a smoothstep with a length to make circles and the circle offset, then use a hash function to randomise the length scalar of the circle, then you need to write a loop to check the floor ids of the surrounding boxes to allow overlap, then you’d need to times the circle origin by TIME to add the y movement…

If all that sounds a pain, well it is. Listen, just add particles, it’s a million times easier and will take someone a few minutes (obviously longer for a beginner but still, infinitely easier). Make gravity go the other way, randomise the scale and lifetime a bit and you’re done.

Here’s a tutorial:

This is really awesome and amazing for knowing.
And the tutorial is great!
Really appreciate you telling me this, I think I can finish it very nicely.

Lesommeil | 2022-07-24 15:01

You’re welcome!

I don’t want to put you off shaders though. Somettimes what you would think would be easy on a shader isn’t and vice versa.

I’d recommend you Google the Book of Shaders; a great resource. Take a look at the online tool ShaderToy for practice (it’s not Godot but it’s virtually identical) and have a look at the YouTube channel Art of Code. Do make sure you start with his beginner tutorials though, don’t try to go straight into the advanced stuff.

DaddyMonster | 2022-07-24 16:26