working shader
This commit is contained in:
parent
07685fcd9c
commit
be8e56cf27
3 changed files with 32 additions and 202 deletions
|
@ -7,60 +7,46 @@
|
|||
#define PS_SHADERMODEL ps_4_0_level_9_1
|
||||
#endif
|
||||
float2 TexelSize; // should be (1f/textureSize.X, 1f/textureSize.Y)
|
||||
int shadow;
|
||||
int BorderSize;
|
||||
float R;
|
||||
float G;
|
||||
float B;
|
||||
|
||||
Texture2D SpriteTexture;
|
||||
sampler2D SpriteTextureSampler = sampler_state
|
||||
{
|
||||
Texture = <SpriteTexture>;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 Color : COLOR0;
|
||||
float2 TextureCoordinates : TEXCOORD0;
|
||||
};
|
||||
|
||||
sampler ColorMapSampler = sampler_state
|
||||
{
|
||||
Texture = <ColorMap>;
|
||||
MinFilter = Linear;
|
||||
MagFilter = Linear;
|
||||
MipFilter = Linear;
|
||||
AddressU = Clamp;
|
||||
AddressV = Clamp;
|
||||
};
|
||||
|
||||
|
||||
float4 MainPS(VertexShaderOutput input) : COLOR
|
||||
{
|
||||
float4 color = tex2D(ColorMapSampler, input.TextureCoordinates);
|
||||
float2 offsetX = float2(TexelSize.x, 0);
|
||||
float2 offsetY = { 0, TexelSize.y };
|
||||
float4 color = tex2D(SpriteTextureSampler, input.TextureCoordinates);
|
||||
|
||||
if (color.a > 0)
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
float2 offsetd1 = { TexelSize.x, TexelSize.y };
|
||||
float2 offsetd2 = { -TexelSize.x, -TexelSize.y };
|
||||
float2 offsetd3 = { TexelSize.x, -TexelSize.y };
|
||||
float2 offsetd4 = { -TexelSize.x, TexelSize.y };
|
||||
float2 offsetX = float2(TexelSize.x, 0);
|
||||
float2 offsetY = float2( 0, TexelSize.y );
|
||||
|
||||
if (color.a == 0)
|
||||
{
|
||||
for (int i = 1; i < 16; i++)
|
||||
for (int i = 1; i < 10; i++)
|
||||
{
|
||||
if (i<=BorderSize)
|
||||
{
|
||||
float4 c1 = tex2D(ColorMapSampler, input.TextureCoordinates + offsetX*i);
|
||||
float4 c2 = tex2D(ColorMapSampler, input.TextureCoordinates - offsetX*i);
|
||||
float4 c3 = tex2D(ColorMapSampler, input.TextureCoordinates + offsetY*i);
|
||||
float4 c4 = tex2D(ColorMapSampler, input.TextureCoordinates - offsetY*i);
|
||||
|
||||
float4 d1 = tex2D(ColorMapSampler, input.TextureCoordinates - offsetd1*i);
|
||||
float4 d2 = tex2D(ColorMapSampler, input.TextureCoordinates - offsetd2*i);
|
||||
float4 d3 = tex2D(ColorMapSampler, input.TextureCoordinates - offsetd3*i);
|
||||
float4 d4 = tex2D(ColorMapSampler, input.TextureCoordinates - offsetd4*i);
|
||||
float4 c1 = tex2D(SpriteTextureSampler, input.TextureCoordinates + offsetX*i);
|
||||
float4 c2 = tex2D(SpriteTextureSampler, input.TextureCoordinates - offsetX*i);
|
||||
float4 c3 = tex2D(SpriteTextureSampler, input.TextureCoordinates + offsetY*i);
|
||||
float4 c4 = tex2D(SpriteTextureSampler, input.TextureCoordinates - offsetY*i);
|
||||
float4 d1 = tex2D(SpriteTextureSampler, input.TextureCoordinates - (offsetX+offsetY)*i);
|
||||
float4 d2 = tex2D(SpriteTextureSampler, input.TextureCoordinates + (offsetX+offsetY)*i);
|
||||
float4 d3 = tex2D(SpriteTextureSampler, input.TextureCoordinates - (offsetX-offsetY)*i);
|
||||
float4 d4 = tex2D(SpriteTextureSampler, input.TextureCoordinates - (-offsetX+offsetY)*i);
|
||||
|
||||
if (color.a != c1.a || color.a != c2.a|| color.a != c3.a|| color.a != c4.a
|
||||
|| color.a != d1.a
|
||||
|
@ -76,9 +62,6 @@ if (color.a == 0)
|
|||
}
|
||||
}
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
return color;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue