yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

lucy96chenAdd implementations for resolveResource() to D3D12 and Vulkan backends (#2094)6528b1c7f

master
1.0 KiB54 linesraw
1// resolve-resource-shader.slang
2
3// Per-vertex attributes to be assembled from bound vertex buffers.
4struct AssembledVertex
5{
6    float3	position : POSITION;
7    float3	color    : COLOR;
8};
9
10// Output of the vertex shader, and input to the fragment shader.
11struct CoarseVertex
12{
13    float3 color;
14};
15
16// Output of the fragment shader
17struct Fragment
18{
19    float4 color;
20};
21
22// Vertex  Shader
23
24struct VertexStageOutput
25{
26    CoarseVertex    coarseVertex    : CoarseVertex;
27    float4          sv_position     : SV_Position;
28};
29
30[shader("vertex")]
31VertexStageOutput vertexMain(
32    AssembledVertex assembledVertex)
33{
34    VertexStageOutput output;
35
36    float3 position = assembledVertex.position;
37    float3 color    = assembledVertex.color;
38
39    output.coarseVertex.color = color;
40    output.sv_position = float4(position, 1.0);
41
42    return output;
43}
44
45// Fragment Shader
46
47[shader("fragment")]
48float4 fragmentMain(
49    CoarseVertex coarseVertex : CoarseVertex) : SV_Target
50{
51    float3 color = coarseVertex.color;
52
53    return float4(color, 1.0);
54}