blob: 6742e12fa98290c032b461af79097f121667f771 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
// Vertex and fragment shader to draw a textured quad on screen.
cbuffer Uniforms
{
int x;
int y;
int width;
int height;
int viewWidth;
int viewHeight;
Texture2D texture;
SamplerState sampler;
}
struct AssembledVertex
{
float3 position : POSITION;
};
struct Fragment
{
float4 color;
};
struct VertexStageOutput
{
float2 uv : UV;
float4 sv_position : SV_Position;
};
[shader("vertex")]
VertexStageOutput vertexMain(
AssembledVertex assembledVertex)
{
VertexStageOutput output;
float3 position = assembledVertex.position;
output.uv = position.xy;
output.sv_position.x = (x + position.x * width) / (float)viewWidth * 2.0f - 1.0f;
output.sv_position.y = -((y + position.y * height) / (float)viewHeight * 2.0f - 1.0f);
output.sv_position.z = 0.5;
output.sv_position.w = 1.0;
return output;
}
[shader("fragment")]
float4 fragmentMain(
float2 uv : UV) : SV_Target
{
return float4(texture.Sample(sampler, uv).xyz, 1.0);
}
|