Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
Pulsing rainbow glow effect - Gideros Forum

Pulsing rainbow glow effect

hgy29hgy29 Maintainer
edited November 2017 in Code snippets
Another shader I've just made and which might be useful below. It creates an animated rainbow colored glow around a Bitmap sprite. I made it for my platformer game to show that the player is allmighty (as when Mario takes a star).
If you use it in your games, it would be great if you could acknowledge me.

Here is the code (GLSL, that its all platforms except WinRT)
local shaderV=[[
attribute highp vec3 vVertex;
attribute mediump vec2 vTexCoord;
uniform highp mat4 vMatrix;
varying mediump vec2 fTexCoord;
void main() {
  vec4 vertex = vec4(vVertex,1.0);
  gl_Position = vMatrix*vertex;
local scanlinesF=[[
uniform lowp sampler2D fTexture;
varying mediump vec2 fTexCoord;
uniform mediump vec4 fTextureSize;
uniform mediump float fTime;
lowp vec3 hsv2rgb(vec3 c) {
  lowp vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
  lowp vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
  return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
void main() {
 mediump vec4 pixel=texture2D(fTexture, fTexCoord);
 mediump vec4 frag=pixel; 
 mediump vec2 centerDir=normalize((fTextureSize.xy/2.0-fTexCoord)/fTextureSize.xy)*fTextureSize.zw;
 for (int k=-5;k<=5;k++)
	frag=frag+texture2D(fTexture, fTexCoord-centerDir*float(k));
 if (frag.a<=0.0) discard;
 if (pixel.a>=1.0)
	gl_FragColor = pixel;
	gl_FragColor = vec4(hsv2rgb(vec3(frag.a/2.0+fTime*2.0,0.7,1.0)),frag.a);
local result,reply=pcall(Shader.new,shaderV,scanlinesF,Shader.FLAG_FROM_CODE,{
	{name="vTexCoord",type=Shader.DFLOAT,mult=2,slot=2,offset=0}, })
if not result then print("Shader Compilation error:"..reply) end
291 x 237 - 37K
+1 -1 (+7 / -0 ) Share on Facebook


Sign In or Register to comment.