2020-05-21 10:20:19 +00:00
|
|
|
// Copyright 2020 Google LLC
|
2024-01-15 19:12:06 +01:00
|
|
|
// Copyright 2023 Sascha Willems
|
2020-05-21 10:20:19 +00:00
|
|
|
|
|
|
|
|
struct UBO
|
|
|
|
|
{
|
2024-01-15 19:12:06 +01:00
|
|
|
float4x4 projection;
|
|
|
|
|
float4x4 model;
|
|
|
|
|
float4 lightPos;
|
|
|
|
|
float tessAlpha;
|
|
|
|
|
float tessStrength;
|
2020-05-21 10:20:19 +00:00
|
|
|
float tessLevel;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
cbuffer ubo : register(b0) { UBO ubo; }
|
|
|
|
|
|
|
|
|
|
struct VSOutput
|
|
|
|
|
{
|
|
|
|
|
[[vk::location(2)]] float4 Pos : POSITION;
|
|
|
|
|
[[vk::location(0)]] float3 Normal : NORMAL0;
|
|
|
|
|
[[vk::location(1)]] float2 UV : TEXCOORD0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct HSOutput
|
|
|
|
|
{
|
|
|
|
|
[[vk::location(2)]] float4 Pos : POSITION;
|
|
|
|
|
[[vk::location(0)]] float3 Normal : NORMAL0;
|
|
|
|
|
[[vk::location(1)]] float2 UV : TEXCOORD0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ConstantsHSOutput
|
|
|
|
|
{
|
|
|
|
|
float TessLevelOuter[3] : SV_TessFactor;
|
|
|
|
|
float TessLevelInner : SV_InsideTessFactor;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ConstantsHSOutput ConstantsHS(InputPatch<VSOutput, 3> patch, uint InvocationID : SV_PrimitiveID)
|
|
|
|
|
{
|
|
|
|
|
ConstantsHSOutput output = (ConstantsHSOutput)0;
|
|
|
|
|
output.TessLevelInner = ubo.tessLevel;
|
|
|
|
|
output.TessLevelOuter[0] = ubo.tessLevel;
|
|
|
|
|
output.TessLevelOuter[1] = ubo.tessLevel;
|
|
|
|
|
output.TessLevelOuter[2] = ubo.tessLevel;
|
|
|
|
|
return output;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[domain("tri")]
|
|
|
|
|
[partitioning("integer")]
|
2020-07-28 20:20:38 +02:00
|
|
|
[outputtopology("triangle_cw")]
|
2020-05-21 10:20:19 +00:00
|
|
|
[outputcontrolpoints(3)]
|
|
|
|
|
[patchconstantfunc("ConstantsHS")]
|
|
|
|
|
[maxtessfactor(20.0f)]
|
|
|
|
|
HSOutput main(InputPatch<VSOutput, 3> patch, uint InvocationID : SV_OutputControlPointID)
|
|
|
|
|
{
|
|
|
|
|
HSOutput output = (HSOutput)0;
|
|
|
|
|
output.Pos = patch[InvocationID].Pos;
|
|
|
|
|
output.Normal = patch[InvocationID].Normal;
|
|
|
|
|
output.UV = patch[InvocationID].UV;
|
|
|
|
|
return output;
|
|
|
|
|
}
|