summaryrefslogtreecommitdiffstats
path: root/tests/manual/rhi/displacement/material_hull.hlsl
blob: 03b476f64f44bb5ed4b4b68424349fc8f633a80d (plain)
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
struct Input
{
    float2 uv : TEXCOORD0;
    float3 normal : TEXCOORD1;
    float4 position : SV_Position;
};

struct Output
{
    float3 position : POSITION;
    float2 uv : TEXCOORD0;
    float3 normal : TEXCOORD1;
};

struct ConstantData
{
    float edges[3] : SV_TessFactor;
    float inside : SV_InsideTessFactor;
};

cbuffer buf : register(b0)
{
    row_major float4x4 mvp : packoffset(c0);
    float displacementAmount : packoffset(c4);
    float tessInner : packoffset(c4.y);
    float tessOuter : packoffset(c4.z);
    int useTex : packoffset(c4.w);
};

ConstantData patchConstFunc(InputPatch<Input, 3> ip, uint PatchID : SV_PrimitiveID )
{
    ConstantData d;
    d.edges[0] = tessOuter;
    d.edges[1] = tessOuter;
    d.edges[2] = tessOuter;
    d.inside = tessInner;
    return d;
}

[domain("tri")]
[partitioning("integer")]
[outputtopology("triangle_cw")]
[outputcontrolpoints(3)]
[patchconstantfunc("patchConstFunc")]
Output main(InputPatch<Input, 3> patch, uint pointId : SV_OutputControlPointID, uint patchId : SV_PrimitiveID)
{
    Output output;
    output.position = patch[pointId].position;
    output.uv = patch[pointId].uv;
    output.normal = patch[pointId].normal;
    return output;
}