Texture tricks

DschoonmakerDschoonmaker Posts: 188Member

This is just some miscellaneous shader tricks I found, mostly using texture().

First, if you need a circle without adding extra mesh detail, you can do that in a shader:

ALPHA = 1.0-distance(UV,vec2(0.5));

or if you need alpha:

ALPHA = step(distance(UV,vec2(0.5)),0.5);

This is just a simple quad, but appears to be a circle. Plus, unlike a texture, it has endless detail. The circle is calculated per screen pixel.

If you've ever used a noise texture as a normal map, you might notice some artifacts:

You can smooth out the noise by using textureLod() instead of texture():

NORMALMAP = textureLod(noiseNormal,UV,lod).xyz;

The larger lod is, the smoother(and blurrier) the noise will look.

Masks are great for some things. If you need some noise without edges, you can multiply the circle mask by noise.

float mask = 1.0-distance(UV,vec2(0.5));
float noise = textureLod(noise1,UV,noiseLod).r;
ALPHA = mask*noise;

That could be useful for water/spray particles.

And using a more complicated mask with scrolling noise, you can get some nice fire:

(The fire doesn't look very good in the GIF, though)


  • SIsilicon28SIsilicon28 Posts: 647Moderator

    That is some very clever shader work. Good job! 👍🏽

  • cyberealitycybereality Posts: 837Moderator

    Nice tricks!

  • DschoonmakerDschoonmaker Posts: 188Member

    A big one I forgot: use alpha scissor with noise to make a dissolve effect. Plenty of people know this one, but it looks really nice, especially for stylized games.

  • DschoonmakerDschoonmaker Posts: 188Member

    Combining noise with circular UVs can make a ripple effect:

    These UVs are simple to make:

    • Make a cylinder(with UVs)
    • Scale the top vertices in
    • Scale down to zero on the Y/Z(whichever is up) axis
  • eyeEmotioneyeEmotion Posts: 83Member

    Do you have a video-tutorial of that flame effect?

  • DschoonmakerDschoonmaker Posts: 188Member

    I don't have any tutorials on the flame effect, but I suppose I could make one.

  • DschoonmakerDschoonmaker Posts: 188Member

    I will make a tutorial on the flames soon, I just want to refine them a little before I do. Right now, the fire is a flat plane, and I also want to add some little touches like heat waves.

Sign In or Register to comment.