forked from LukasBanana/LLGL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.hlsl
More file actions
61 lines (44 loc) · 826 Bytes
/
Example.hlsl
File metadata and controls
61 lines (44 loc) · 826 Bytes
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
53
54
55
56
57
58
// HLSL model shader
// VERTEX SHADER
cbuffer Settings : register(b2)
{
float4x4 wvpMatrix;
};
struct InputVS
{
float3 position : POSITION;
};
struct OutputVS
{
float4 position : SV_Position;
};
OutputVS VS(InputVS inp)
{
OutputVS outp;
outp.position = mul(wvpMatrix, float4(inp.position, 1));
return outp;
}
// GEOMETRY SHADER
[maxvertexcount(9)]
void GS(triangle OutputVS inp[3], inout TriangleStream<OutputVS> stream)
{
OutputVS outp;
// Generate 3 instances
for (int i = 0; i < 3; ++i)
{
// Generate 3 vertices for each triangle
for (int j = 0; j < 3; ++j)
{
outp = inp[j];
outp.position.x += (float(i) - 1.0)*4.0;
outp.position.w = 8.0;
stream.Append(outp);
}
stream.RestartStrip();
}
}
// PIXEL SHADER
float4 PS(OutputVS inp) : SV_Target
{
return float4(0, 1, 0, 1);
}