2009-04-19 18:07:22 +00:00
|
|
|
// Things 2D rendering shader
|
|
|
|
// Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
|
|
|
|
|
|
// Vertex input data
|
|
|
|
struct VertexData
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
float3 pos : POSITION;
|
|
|
|
float4 color : COLOR0;
|
|
|
|
float2 uv : TEXCOORD0;
|
2009-04-19 18:07:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Pixel input data
|
|
|
|
struct PixelData
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
float4 pos : POSITION;
|
|
|
|
float4 color : COLOR0;
|
|
|
|
float2 uv : TEXCOORD0;
|
2009-04-19 18:07:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Render settings
|
|
|
|
// w = transparency
|
|
|
|
float4 rendersettings;
|
|
|
|
|
2012-04-17 19:13:47 +00:00
|
|
|
//mxd. solid fill color. used in model wireframe rendering
|
|
|
|
float4 fillColor;
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Transform settings
|
|
|
|
float4x4 transformsettings;
|
|
|
|
|
|
|
|
// Texture1 input
|
|
|
|
texture texture1
|
|
|
|
<
|
2013-09-11 09:47:53 +00:00
|
|
|
string UIName = "Texture1";
|
|
|
|
string ResourceType = "2D";
|
2009-04-19 18:07:22 +00:00
|
|
|
>;
|
|
|
|
|
|
|
|
// Texture sampler settings
|
|
|
|
sampler2D texture1samp = sampler_state
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
Texture = <texture1>;
|
|
|
|
MagFilter = Linear;
|
|
|
|
MinFilter = Linear;
|
|
|
|
MipFilter = Linear;
|
2009-04-19 18:07:22 +00:00
|
|
|
AddressU = Wrap;
|
|
|
|
AddressV = Wrap;
|
|
|
|
MipMapLodBias = -0.9f;
|
|
|
|
};
|
|
|
|
|
2013-11-27 12:45:28 +00:00
|
|
|
//mxd. Texture sampler settings for sprite rendering
|
|
|
|
sampler2D texture1sprite = sampler_state
|
|
|
|
{
|
|
|
|
Texture = <texture1>;
|
|
|
|
MagFilter = Point;
|
|
|
|
MinFilter = Point;
|
|
|
|
MipFilter = Point;
|
|
|
|
AddressU = Clamp;
|
|
|
|
AddressV = Clamp;
|
|
|
|
MipMapLodBias = 0.0f;
|
|
|
|
};
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Transformation
|
|
|
|
PixelData vs_transform(VertexData vd)
|
|
|
|
{
|
|
|
|
PixelData pd = (PixelData)0;
|
|
|
|
pd.pos = mul(float4(vd.pos, 1.0f), transformsettings);
|
|
|
|
pd.color = vd.color;
|
|
|
|
pd.uv = vd.uv;
|
|
|
|
return pd;
|
|
|
|
}
|
|
|
|
|
2013-11-27 12:45:28 +00:00
|
|
|
//mxd. Pixel shader for sprite drawing
|
|
|
|
float4 ps_sprite(PixelData pd) : COLOR
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2013-11-27 12:45:28 +00:00
|
|
|
// Take this pixel's color
|
|
|
|
float4 c = tex2D(texture1sprite, pd.uv);
|
2014-09-11 21:53:31 +00:00
|
|
|
|
|
|
|
// Modulate it by selection color
|
2014-12-03 23:15:26 +00:00
|
|
|
if(pd.color.a > 0)
|
|
|
|
{
|
2014-09-11 21:53:31 +00:00
|
|
|
return float4((c.r + pd.color.r) / 2.0f, (c.g + pd.color.g) / 2.0f, (c.b + pd.color.b) / 2.0f, c.a * rendersettings.w * pd.color.a);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Or leave it as it is
|
|
|
|
return float4(c.rgb, c.a * rendersettings.w);
|
2013-11-27 12:45:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//mxd. Pixel shader for thing box and arrow drawing
|
|
|
|
float4 ps_thing(PixelData pd) : COLOR
|
|
|
|
{
|
|
|
|
// Take this pixel's color
|
2009-04-19 18:07:22 +00:00
|
|
|
float4 c = tex2D(texture1samp, pd.uv);
|
2013-11-27 12:45:28 +00:00
|
|
|
return float4(c.rgb, c.a * rendersettings.w) * pd.color;
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
2013-11-27 12:45:28 +00:00
|
|
|
//mxd. Pretty darn simple pixel shader for wireframe rendering :)
|
2014-12-03 23:15:26 +00:00
|
|
|
float4 ps_fill(PixelData pd) : COLOR
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
return fillColor;
|
2012-04-17 19:13:47 +00:00
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Technique for shader model 2.0
|
|
|
|
technique SM20
|
|
|
|
{
|
2013-11-27 12:45:28 +00:00
|
|
|
pass p0 //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
VertexShader = compile vs_2_0 vs_transform();
|
2013-11-27 12:45:28 +00:00
|
|
|
PixelShader = compile ps_2_0 ps_thing();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
2013-11-27 12:45:28 +00:00
|
|
|
|
|
|
|
pass p1 //mxd
|
|
|
|
{
|
|
|
|
VertexShader = compile vs_2_0 vs_transform();
|
|
|
|
PixelShader = compile ps_2_0 ps_sprite();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-11 21:53:31 +00:00
|
|
|
pass p2 //mxd
|
2012-04-17 19:13:47 +00:00
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
VertexShader = compile vs_2_0 vs_transform();
|
|
|
|
PixelShader = compile ps_2_0 ps_fill();
|
2012-04-17 19:13:47 +00:00
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|