3
\$\begingroup\$

I'm working on a top-down 2D strategy game written in Java with LibGDX (though really for the purposes of this question I'll be using GLSL).

I want to give metallic materials in the game a shiny effect - but not a lightsource-based specular highlight or anything similar, I'm after a kind of global shine or shimmer, much like the effect on the word "King" in this logo from King under the Mountain:

Example animated gif with a shine passing over the letters of a logo

While I'm not looking for someone to implement this for me, as a bit of a newbie to shader programming, what kind of techniques or algorithms should I be looking at to give this kind of effect?

\$\endgroup\$
  • \$\begingroup\$ Those are usually animations. But if you want to make a realistic one, try a specular shader \$\endgroup\$ – Bálint Dec 7 '16 at 12:07
  • \$\begingroup\$ I guess I mean I'd like the animation-like effect in a shader without it being a specular shade or otherwise direction dependent \$\endgroup\$ – Ross Taylor-Turner Dec 7 '16 at 12:52
5
\$\begingroup\$

Well, a good approach would be to create a bit mask, where the time a specific pixel should be fully lit is indicated by the amount of red it contains. So for example a pixel would be completely black, if you wanted it to light up first, and it had 255 units of red, if you wanted it to light up the last.

Then you need to pass the time and this texture to your fragment shader, sample the fragment of the bitmask, get the difference between the value of the red channel and the remainder of time and 255 (this is so it's loops), and if the difference is less than a specific value, then make that pixel lighter.

You can also store stuff in the green and blue channel, like how bright that pixel should be.

\$\endgroup\$
  • \$\begingroup\$ That gives me some good pointers to make a start with, thanks! \$\endgroup\$ – Ross Taylor-Turner Dec 7 '16 at 13:28
  • \$\begingroup\$ @Ross could you mark this answer as correct? \$\endgroup\$ – Bálint Dec 10 '16 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.