forked from shader-slang/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtexture2d-gather.hlsl
48 lines (38 loc) · 994 Bytes
/
texture2d-gather.hlsl
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
//TEST(smoke):COMPARE_HLSL_RENDER:
//DISABLE_TEST(smoke):COMPARE_HLSL_RENDER:-mtl
//TEST_INPUT: Texture2D(size=16, content=chessboard, format=R32_FLOAT):name g_texture
//TEST_INPUT: Sampler :name g_sampler
Texture2D<float> g_texture;
SamplerState g_sampler;
cbuffer Uniforms
{
float4x4 modelViewProjection;
}
struct AssembledVertex
{
float3 position;
float3 color;
float2 uv;
};
// Vertex Shader
struct VertexStageInput
{
AssembledVertex assembledVertex : A;
};
struct VertexStageOutput
{
float4 color : COLOR;
float4 position : SV_Position;
};
VertexStageOutput vertexMain(VertexStageInput input)
{
VertexStageOutput output;
output.position = mul(modelViewProjection, float4(input.assembledVertex.position, 1.0));
output.color = float4(input.assembledVertex.color, 1.0f);
return output;
}
// Fragment Shader
float4 fragmentMain(VertexStageOutput input) : SV_Target
{
return g_texture.GatherRed(g_sampler, input.color.xy);
}