2010-03-15 19:13:51 +00:00
|
|
|
#ifdef SHADER_MODEL // make safe to include in resource file to enforce dependency
|
2009-06-19 20:24:18 +00:00
|
|
|
#if SHADER_MODEL >= 0x400
|
|
|
|
|
2009-02-06 19:15:15 +00:00
|
|
|
struct VS_INPUT
|
|
|
|
{
|
|
|
|
float4 p : POSITION;
|
|
|
|
float2 t : TEXCOORD0;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VS_OUTPUT
|
|
|
|
{
|
|
|
|
float4 p : SV_Position;
|
|
|
|
float2 t : TEXCOORD0;
|
|
|
|
};
|
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
Texture2D Texture;
|
|
|
|
SamplerState TextureSampler;
|
2009-02-06 19:15:15 +00:00
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
float4 sample_c(float2 uv)
|
|
|
|
{
|
|
|
|
return Texture.Sample(TextureSampler, uv);
|
2009-02-06 19:15:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct PS_INPUT
|
|
|
|
{
|
|
|
|
float4 p : SV_Position;
|
|
|
|
float2 t : TEXCOORD0;
|
|
|
|
};
|
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
struct PS_OUTPUT
|
2009-02-06 19:15:15 +00:00
|
|
|
{
|
2009-07-12 13:46:05 +00:00
|
|
|
float4 c : SV_Target0;
|
|
|
|
};
|
2009-02-06 19:15:15 +00:00
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
#elif SHADER_MODEL <= 0x300
|
2009-02-06 19:15:15 +00:00
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
struct VS_INPUT
|
|
|
|
{
|
|
|
|
float4 p : POSITION;
|
|
|
|
float2 t : TEXCOORD0;
|
|
|
|
};
|
2009-02-06 19:15:15 +00:00
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
struct VS_OUTPUT
|
|
|
|
{
|
|
|
|
float4 p : POSITION;
|
|
|
|
float2 t : TEXCOORD0;
|
|
|
|
};
|
2009-02-06 19:15:15 +00:00
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
struct PS_INPUT
|
|
|
|
{
|
2010-03-01 15:26:25 +00:00
|
|
|
#if SHADER_MODEL < 0x300
|
|
|
|
float4 p : TEXCOORD1;
|
|
|
|
#else
|
2009-07-12 13:46:05 +00:00
|
|
|
float4 p : VPOS;
|
2010-03-01 15:26:25 +00:00
|
|
|
#endif
|
2009-07-12 13:46:05 +00:00
|
|
|
float2 t : TEXCOORD0;
|
|
|
|
};
|
2009-02-06 19:15:15 +00:00
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
struct PS_OUTPUT
|
2009-02-06 19:15:15 +00:00
|
|
|
{
|
2009-07-12 13:46:05 +00:00
|
|
|
float4 c : COLOR;
|
|
|
|
};
|
|
|
|
|
|
|
|
sampler Texture : register(s0);
|
2009-02-06 19:15:15 +00:00
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
float4 sample_c(float2 uv)
|
|
|
|
{
|
|
|
|
return tex2D(Texture, uv);
|
2009-02-06 19:15:15 +00:00
|
|
|
}
|
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
VS_OUTPUT vs_main(VS_INPUT input)
|
2009-02-06 19:15:15 +00:00
|
|
|
{
|
2009-07-12 13:46:05 +00:00
|
|
|
VS_OUTPUT output;
|
|
|
|
|
|
|
|
output.p = input.p;
|
|
|
|
output.t = input.t;
|
2009-02-06 19:15:15 +00:00
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
return output;
|
2009-02-06 19:15:15 +00:00
|
|
|
}
|
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT ps_main0(PS_INPUT input)
|
2009-02-06 19:15:15 +00:00
|
|
|
{
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT output;
|
2009-02-06 19:15:15 +00:00
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
output.c = sample_c(input.t);
|
|
|
|
|
|
|
|
return output;
|
2009-02-06 19:15:15 +00:00
|
|
|
}
|
2009-05-22 23:23:38 +00:00
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
float4 ps_crt(PS_INPUT input, int i)
|
2009-05-22 23:23:38 +00:00
|
|
|
{
|
|
|
|
float4 mask[4] =
|
|
|
|
{
|
|
|
|
float4(1, 0, 0, 0),
|
|
|
|
float4(0, 1, 0, 0),
|
|
|
|
float4(0, 0, 1, 0),
|
|
|
|
float4(1, 1, 1, 0)
|
|
|
|
};
|
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
return sample_c(input.t) * saturate(mask[i] + 0.5f);
|
2009-05-22 23:23:38 +00:00
|
|
|
}
|
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
#if SHADER_MODEL >= 0x400
|
|
|
|
|
|
|
|
uint ps_main1(PS_INPUT input) : SV_Target0
|
2009-05-22 23:23:38 +00:00
|
|
|
{
|
2009-07-12 13:46:05 +00:00
|
|
|
float4 c = sample_c(input.t);
|
2009-05-22 23:23:38 +00:00
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
c.a *= 256.0f / 127; // hm, 0.5 won't give us 1.0 if we just multiply with 2
|
|
|
|
|
|
|
|
uint4 i = c * float4(0x001f, 0x03e0, 0x7c00, 0x8000);
|
|
|
|
|
|
|
|
return (i.x & 0x001f) | (i.y & 0x03e0) | (i.z & 0x7c00) | (i.w & 0x8000);
|
2009-05-22 23:23:38 +00:00
|
|
|
}
|
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT ps_main2(PS_INPUT input)
|
2009-05-22 23:23:38 +00:00
|
|
|
{
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT output;
|
|
|
|
|
|
|
|
clip(sample_c(input.t).a - 128.0f / 255); // >= 0x80 pass
|
|
|
|
|
|
|
|
output.c = 0;
|
2009-05-22 23:23:38 +00:00
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
return output;
|
2009-06-19 20:24:18 +00:00
|
|
|
}
|
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT ps_main3(PS_INPUT input)
|
2009-06-19 20:24:18 +00:00
|
|
|
{
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT output;
|
|
|
|
|
|
|
|
clip(127.95f / 255 - sample_c(input.t).a); // < 0x80 pass (== 0x80 should not pass)
|
|
|
|
|
|
|
|
output.c = 0;
|
2009-06-19 20:24:18 +00:00
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
return output;
|
|
|
|
}
|
2009-06-19 20:24:18 +00:00
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT ps_main4(PS_INPUT input)
|
2009-06-19 20:24:18 +00:00
|
|
|
{
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT output;
|
|
|
|
|
|
|
|
output.c = fmod(sample_c(input.t) * 255 + 0.5f, 256) / 255;
|
2009-06-19 20:24:18 +00:00
|
|
|
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT ps_main5(PS_INPUT input) // triangular
|
2009-06-19 20:24:18 +00:00
|
|
|
{
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT output;
|
|
|
|
|
|
|
|
uint4 p = (uint4)input.p;
|
|
|
|
|
|
|
|
// output.c = ps_crt(input, ((p.x + (p.y & 1) * 3) >> 1) % 3);
|
|
|
|
output.c = ps_crt(input, ((p.x + ((p.y >> 1) & 1) * 3) >> 1) % 3);
|
|
|
|
|
|
|
|
return output;
|
2009-06-19 20:24:18 +00:00
|
|
|
}
|
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT ps_main6(PS_INPUT input) // diagonal
|
2009-06-19 20:24:18 +00:00
|
|
|
{
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT output;
|
|
|
|
|
|
|
|
uint4 p = (uint4)input.p;
|
|
|
|
|
|
|
|
output.c = ps_crt(input, (p.x + (p.y % 3)) % 3);
|
|
|
|
|
|
|
|
return output;
|
2009-06-19 20:24:18 +00:00
|
|
|
}
|
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
#elif SHADER_MODEL <= 0x300
|
|
|
|
|
|
|
|
PS_OUTPUT ps_main1(PS_INPUT input)
|
2009-06-19 20:24:18 +00:00
|
|
|
{
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT output;
|
|
|
|
|
|
|
|
float4 c = sample_c(input.t);
|
|
|
|
|
|
|
|
c.a *= 128.0f / 255; // *= 0.5f is no good here, need to do this in order to get 0x80 for 1.0f (instead of 0x7f)
|
|
|
|
|
|
|
|
output.c = c;
|
2009-06-19 20:24:18 +00:00
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
return output;
|
2009-06-19 20:24:18 +00:00
|
|
|
}
|
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT ps_main2(PS_INPUT input)
|
2009-06-19 20:24:18 +00:00
|
|
|
{
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT output;
|
|
|
|
|
|
|
|
clip(sample_c(input.t).a - 255.0f / 255); // >= 0x80 pass
|
|
|
|
|
|
|
|
output.c = 0;
|
2009-06-19 20:24:18 +00:00
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
return output;
|
2009-06-19 20:24:18 +00:00
|
|
|
}
|
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT ps_main3(PS_INPUT input)
|
2009-06-19 20:24:18 +00:00
|
|
|
{
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT output;
|
|
|
|
|
|
|
|
clip(254.95f / 255 - sample_c(input.t).a); // < 0x80 pass (== 0x80 should not pass)
|
|
|
|
|
|
|
|
output.c = 0;
|
|
|
|
|
|
|
|
return output;
|
2009-06-19 20:24:18 +00:00
|
|
|
}
|
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT ps_main4(PS_INPUT input)
|
2009-06-19 20:24:18 +00:00
|
|
|
{
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT output;
|
|
|
|
|
|
|
|
output.c = 1;
|
2009-06-19 20:24:18 +00:00
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
return output;
|
2009-06-19 20:24:18 +00:00
|
|
|
}
|
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT ps_main5(PS_INPUT input) // triangular
|
2009-06-19 20:24:18 +00:00
|
|
|
{
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT output;
|
|
|
|
|
|
|
|
int4 p = (int4)input.p;
|
2009-06-19 20:24:18 +00:00
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
// output.c = ps_crt(input, ((p.x + (p.y % 2) * 3) / 2) % 3);
|
|
|
|
output.c = ps_crt(input, ((p.x + ((p.y / 2) % 2) * 3) / 2) % 3);
|
|
|
|
|
|
|
|
return output;
|
2009-06-19 20:24:18 +00:00
|
|
|
}
|
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT ps_main6(PS_INPUT input) // diagonal
|
2009-06-19 20:24:18 +00:00
|
|
|
{
|
2009-07-12 13:46:05 +00:00
|
|
|
PS_OUTPUT output;
|
|
|
|
|
|
|
|
int4 p = (int4)input.p;
|
2009-06-19 20:24:18 +00:00
|
|
|
|
2009-07-12 13:46:05 +00:00
|
|
|
output.c = ps_crt(input, (p.x + (p.y % 3)) % 3);
|
|
|
|
|
|
|
|
return output;
|
2009-06-19 20:24:18 +00:00
|
|
|
}
|
|
|
|
|
2010-03-15 19:13:51 +00:00
|
|
|
#endif
|
|
|
|
#endif
|