Shader galore

This commit is contained in:
Michele 2021-01-09 00:38:19 +00:00
parent 519b7518ff
commit 07685fcd9c
62 changed files with 496 additions and 266 deletions

View file

@ -3021,6 +3021,12 @@
/processorParam:TextureFormat=Color
/build:overlays/zigzag-hieroglyph.png
#begin shaders/OutlineShader.fx
/importer:EffectImporter
/processor:EffectProcessor
/processorParam:DebugMode=Auto
/build:shaders/OutlineShader.fx
#begin tiles/tile01.png
/importer:TextureImporter
/processor:TextureProcessor

View file

@ -0,0 +1,92 @@
#if OPENGL
#define SV_POSITION POSITION
#define VS_SHADERMODEL vs_3_0
#define PS_SHADERMODEL ps_3_0
#else
#define VS_SHADERMODEL vs_4_0_level_9_1
#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 };
float2 offsetd1 = { TexelSize.x, TexelSize.y };
float2 offsetd2 = { -TexelSize.x, -TexelSize.y };
float2 offsetd3 = { TexelSize.x, -TexelSize.y };
float2 offsetd4 = { -TexelSize.x, TexelSize.y };
if (color.a == 0)
{
for (int i = 1; i < 16; 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);
if (color.a != c1.a || color.a != c2.a|| color.a != c3.a|| color.a != c4.a
|| color.a != d1.a
|| color.a != d2.a
|| color.a != d3.a
|| color.a != d4.a
)
{
color.r=R;
color.g=G;
color.b=B;
color.a=1;
}
}
}
return color;
}
return color;
}
technique SpriteDrawing
{
pass P0
{
PixelShader = compile PS_SHADERMODEL MainPS();
}
};