Flash Effect

This forum is currently in read-only mode.
  • I'm trying to make a shader to simply fill a sprite with white to duplicate an effect in older games where a sprite flashes when hit with a bullet. Seems like it should be easy, but since I have no idea what I'm doing I'm having a tough time figuring it out. I've modified the Black & White shader to try and get the effect but its not quite there:

    // Foreground texture
    texture ForegroundTexture;
    
    // Foreground sampler
    sampler2D foreground = sampler_state {
        Texture = (ForegroundTexture);
    
    };
    
    float4 EffectProcess( float2 Tex : TEXCOORD0 ) : COLOR0
    {
        float4 front = tex2D(foreground, Tex.xy);
        front.rgb = (front.r + front.g + front.b) * 64;
        return front;
    }
    
    // ConstructEffect
    technique ConstructEffect
    {
        pass p0
        {
            VertexShader = null;
            PixelShader = compile ps_2_0 EffectProcess();
        }
    }
    [/code:i3f5mved]  
    
    Appreciate any help!
  • If you want it to go pure white, here it is:

    // Flash
    // Linkman2004
    // PS 1.1
    // Sets every pixel to white
    
    // Foreground texture
    texture ForegroundTexture;
    
    // Foreground sampler
    sampler2D foreground = sampler_state {
        Texture = (ForegroundTexture);
        MinFilter = Point;
        MagFilter = Point;
        MipFilter = Point;
    };
    
    // Effect function
    float4 EffectProcess( float2 Tex : TEXCOORD0 ) : COLOR0
    {
        float4 front = tex2D(foreground, Tex.xy);
        front.rgb = 1;
        return front;
    }
    
    // ConstructEffect
    technique ConstructEffect
    {
        pass p0
        {
            VertexShader = null;
            PixelShader = compile ps_1_1 EffectProcess();
        }
    }
    [/code:2yoyurmx]
  • You can also do this if you set the colour filter to black (so you get a black silhouette), then use the Invert shader.

  • Linkman: I tried your code, but it seems to ignore the alpha, so I get a white square instead of a white silhouette

    Ashley: Thanks for the workaround. Slightley annoying to have to change the filter color every time, but it works. I'll use this for now but still looking for help on this shader. I'm trying to learn to write simple shaders so seeing the solution would also be benificial.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Damn, I thought that would have worked properly.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)