Debian Codegraph @

tests/manual/rhi/displacement/material_hull.hlsl

raw
1 struct Input
2 {
3 float2 uv : TEXCOORD0;
4 float3 normal : TEXCOORD1;
5 float4 position : SV_Position;
6 };
7
8 struct Output
9 {
10 float3 position : POSITION;
11 float2 uv : TEXCOORD0;
12 float3 normal : TEXCOORD1;
13 };
14
15 struct ConstantData
16 {
17 float edges[3] : SV_TessFactor;
18 float inside : SV_InsideTessFactor;
19 };
20
21 cbuffer buf : register(b0)
22 {
23 row_major float4x4 mvp : packoffset(c0);
24 float displacementAmount : packoffset(c4);
25 float tessInner : packoffset(c4.y);
26 float tessOuter : packoffset(c4.z);
27 int useTex : packoffset(c4.w);
28 };
29
30 ConstantData patchConstFunc(InputPatch<Input, 3> ip, uint PatchID : SV_PrimitiveID )
31 {
32 ConstantData d;
33 d.edges[0] = tessOuter;
34 d.edges[1] = tessOuter;
35 d.edges[2] = tessOuter;
36 d.inside = tessInner;
37 return d;
38 }
39
40 [domain("tri")]
41 [partitioning("integer")]
42 [outputtopology("triangle_cw")]
43 [outputcontrolpoints(3)]
44 [patchconstantfunc("patchConstFunc")]
45 Output main(InputPatch<Input, 3> patch, uint pointId : SV_OutputControlPointID, uint patchId : SV_PrimitiveID)
46 {
47 Output output;
48 output.position = patch[pointId].position;
49 output.uv = patch[pointId].uv;
50 output.normal = patch[pointId].normal;
51 return output;
52 }