-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHS_Test.hlsl
77 lines (67 loc) · 2.01 KB
/
HS_Test.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
struct VS_CONTROL_POINT_OUTPUT
{
float3 viewPosition : POSITION;
float3 viewNormal : NORMAL;
float3 viewTangent : TANGENT;
float3 viewBitangent : BITANGENT;
float2 textureCoords : TEXCOORD;
float3 worldPosition : WORLDPOSITION;
float3 worldNormal : WORLDNORMAL;
float4 depthMapCoords : DEPTHTEXCOORD;
float4 position : SV_POSITION;
};
struct HS_CONTROL_POINT_OUTPUT
{
float3 viewPosition : POSITION;
float3 viewNormal : NORMAL;
float3 viewTangent : TANGENT;
float3 viewBitangent : BITANGENT;
float2 textureCoords : TEXCOORD;
float3 worldPosition : WORLDPOSITION;
float3 worldNormal : WORLDNORMAL;
float4 depthMapCoords : DEPTHTEXCOORD;
float4 position : SV_POSITION;
};
struct HS_CONSTANT_DATA_OUTPUT
{
float EdgeTessFactor[3] : SV_TessFactor;
float InsideTessFactor : SV_InsideTessFactor;
};
cbuffer tesselationData : register(b0)
{
float tesselationFactor;
};
#define NUM_CONTROL_POINTS 3
HS_CONSTANT_DATA_OUTPUT CalcHSPatchConstants(
InputPatch<VS_CONTROL_POINT_OUTPUT, NUM_CONTROL_POINTS> ip,
uint PatchID : SV_PrimitiveID)
{
HS_CONSTANT_DATA_OUTPUT Output;
Output.EdgeTessFactor[0] =
Output.EdgeTessFactor[1] =
Output.EdgeTessFactor[2] =
Output.InsideTessFactor = tesselationFactor;
return Output;
}
[domain("tri")]
[partitioning("fractional_odd")]
[outputtopology("triangle_cw")]
[outputcontrolpoints(3)]
[patchconstantfunc("CalcHSPatchConstants")]
HS_CONTROL_POINT_OUTPUT main(
InputPatch<VS_CONTROL_POINT_OUTPUT, NUM_CONTROL_POINTS> ip,
uint i : SV_OutputControlPointID,
uint PatchID : SV_PrimitiveID )
{
HS_CONTROL_POINT_OUTPUT Output;
Output.viewPosition = ip[i].viewPosition;
Output.viewNormal = ip[i].viewNormal;
Output.viewTangent = ip[i].viewTangent;
Output.viewBitangent = ip[i].viewBitangent;
Output.textureCoords = ip[i].textureCoords;
Output.worldPosition = ip[i].worldPosition;
Output.worldNormal = ip[i].worldNormal;
Output.depthMapCoords = ip[i].depthMapCoords;
Output.position = ip[i].position;
return Output;
}