Flash Effect

For questions about using Classic.

Post » Thu May 21, 2009 4:06 pm

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:

[code:i3f5mved]
// 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!
B
77
S
49
G
25
Posts: 346
Reputation: 17,409

Post » Thu May 21, 2009 4:34 pm

If you want it to go pure white, here it is:
[code:2yoyurmx]// 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]
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Thu May 21, 2009 4:41 pm

You can also do this if you set the colour filter to black (so you get a black silhouette), then use the Invert shader.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Thu May 21, 2009 4:58 pm

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.
B
77
S
49
G
25
Posts: 346
Reputation: 17,409

Post » Thu May 21, 2009 5:12 pm

Damn, I thought that would have worked properly. :P
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests