Colored Dropshadow

For questions about using Classic.

Post » Sat Oct 12, 2013 9:19 pm

Hey guys,

Could someone please edit the dropshadow shader below to use rgb colors instead of just a black shadow? I don't have knowledge of shader code to do it myself. Thank you.


[code]
// Dropshadow blurred
// David Clark (edited by Louis Ferina, Jorge Fuente-Alba)
// PS 2.0

//#CROSS-SAMPLING : reads pixels it may be writing.
//#BORDER-MODE : samples pixels outside bounding box
//#PARAM float offsetX 5.0 : X Offset: X offset of dropshadow.
//#PARAM float offsetY 5.0 : Y Offset: Y offset of dropshadow.
//#PARAM float blur 2.5 : Blur : Blur amount of dropshadow.
//#PARAM float opacity 0.5 : Opacity : Opacity of dropshadow.


// Foreground texture
texture ForegroundTexture;

// Foreground sampler
sampler2D foreground = sampler_state {
Texture = (ForegroundTexture);
MinFilter = Point;
MagFilter = Point;
MipFilter = Point;
};

// Parameter variables
float offsetX;
float offsetY;
float pixelWidth;
float pixelHeight;
float blur;
float opacity;

// Effect function
float4 EffectProcess( float2 Tex : TEXCOORD0 ) : COLOR0
{
// Add the front and back pixels
float2 Tex2 = Tex;
Tex2.x -= offsetX * pixelWidth;
Tex2.y -= offsetY * pixelHeight;
float4 here = tex2D(foreground, Tex2.xy)*0.25;
float4 left = tex2D(foreground, float2(Tex2.x - (pixelWidth*blur), Tex2.y))*0.1875;
float4 right = tex2D(foreground, float2(Tex2.x + (pixelWidth*blur), Tex2.y))*0.1875;
float4 top = tex2D(foreground, float2(Tex2.x, Tex2.y - (pixelHeight*blur)))*0.1875;
float4 bottom = tex2D(foreground, float2(Tex2.x, Tex2.y + (pixelHeight*blur)))*0.1875;

float4 result = (here + left + right + top + bottom )* opacity;
float4 src = tex2D(foreground, Tex.xy);

result.rgb = 0;

return result * (1-src.a) + src;

}

// ConstructEffect
technique ConstructEffect
{
pass p0
{
VertexShader = null;
PixelShader = compile ps_2_0 EffectProcess();
}
}
[/code]
B
8
S
3
G
2
Posts: 46
Reputation: 1,592

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests