UltimateZoneBuilder/Source/Resources/things2d.fx

76 lines
1.5 KiB
HLSL
Raw Normal View History

2007-10-21 04:07:36 +00:00
// Things 2D rendering shader
// Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
2008-05-18 11:43:28 +00:00
// Vertex input data
struct VertexData
{
float3 pos : POSITION;
float4 color : COLOR0;
float2 uv : TEXCOORD0;
};
2007-10-21 04:07:36 +00:00
// Pixel input data
struct PixelData
{
float4 pos : POSITION;
float4 color : COLOR0;
2007-10-21 04:07:36 +00:00
float2 uv : TEXCOORD0;
};
2008-05-18 11:43:28 +00:00
// Transform settings
float4x4 transformsettings;
2007-10-21 04:07:36 +00:00
// Texture1 input
texture texture1
<
string UIName = "Texture1";
string ResourceType = "2D";
>;
// Texture sampler settings
sampler2D texture1samp = sampler_state
{
Texture = <texture1>;
MagFilter = Linear;
MinFilter = Linear;
MipFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
2008-05-23 09:54:51 +00:00
MipMapLodBias = -0.9f;
2007-10-21 04:07:36 +00:00
};
2008-05-18 11:43:28 +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;
}
2007-10-21 04:07:36 +00:00
// Pixel shader for colored circle
float4 ps_circle(PixelData pd) : COLOR
{
// Texture pixel color
2007-10-21 04:07:36 +00:00
float4 c = tex2D(texture1samp, pd.uv);
// Use shinyness?
2008-05-23 09:54:51 +00:00
if(pd.uv.x < 0.4f)
{
float4 s = tex2D(texture1samp, pd.uv + float2(0.25f, 0.0f));
return float4(lerp(c.rgb * pd.color.rgb, s.rgb, s.a), c.a * pd.color.a);
}
else return c;
2007-10-21 04:07:36 +00:00
}
// Technique for shader model 2.0
technique SM20
{
pass p0
{
2008-05-18 11:43:28 +00:00
VertexShader = compile vs_2_0 vs_transform();
2007-10-21 04:07:36 +00:00
PixelShader = compile ps_2_0 ps_circle();
}
}