48 lines
1.2 KiB
HLSL
48 lines
1.2 KiB
HLSL
sampler mainImage : register(s0);
|
|
matrix uWorldViewProjection;
|
|
|
|
struct VertexShaderInput
|
|
{
|
|
float4 Position : POSITION0;
|
|
float4 Color : COLOR0;
|
|
float3 TextureCoordinates : TEXCOORD0;
|
|
};
|
|
|
|
struct VertexShaderOutput
|
|
{
|
|
float4 Position : SV_POSITION;
|
|
float4 Color : COLOR0;
|
|
float3 TextureCoordinates : TEXCOORD0;
|
|
};
|
|
|
|
VertexShaderOutput VertexShaderFunction(in VertexShaderInput input)
|
|
{
|
|
VertexShaderOutput output = (VertexShaderOutput) 0;
|
|
float4 pos = mul(input.Position, uWorldViewProjection);
|
|
output.Position = pos;
|
|
output.Color = input.Color;
|
|
output.TextureCoordinates = input.TextureCoordinates;
|
|
|
|
return output;
|
|
}
|
|
|
|
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
|
|
{
|
|
float4 color = input.Color;
|
|
float2 coords = input.TextureCoordinates;
|
|
|
|
// Account for texture distortion artifacts.
|
|
coords.y = (coords.y - 0.5) / input.TextureCoordinates.z + 0.5;
|
|
|
|
float4 pixel = tex2D(mainImage, coords);
|
|
return color * pixel;
|
|
}
|
|
|
|
technique Technique1
|
|
{
|
|
pass AutoloadPass
|
|
{
|
|
VertexShader = compile vs_2_0 VertexShaderFunction();
|
|
PixelShader = compile ps_2_0 PixelShaderFunction();
|
|
}
|
|
} |