Add shaders re-implemented in HLSL
These were written against the shaders at revision eddd724e7.
There have been changes made since then, which will need to be mirrored.
See `data/hlsl/README.md` for the current status of each sample.
This commit is contained in:
parent
10a1ecaf7b
commit
cce75f1859
287 changed files with 11263 additions and 0 deletions
20
data/hlsl/pipelinestatistics/scene.frag
Normal file
20
data/hlsl/pipelinestatistics/scene.frag
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright 2020 Google LLC
|
||||
|
||||
struct VSOutput
|
||||
{
|
||||
[[vk::location(0)]] float3 Normal : NORMAL0;
|
||||
[[vk::location(1)]] float3 Color : COLOR0;
|
||||
[[vk::location(2)]] float3 ViewVec : TEXCOORD1;
|
||||
[[vk::location(3)]] float3 LightVec : TEXCOORD2;
|
||||
};
|
||||
|
||||
float4 main(VSOutput input) : SV_TARGET
|
||||
{
|
||||
float3 N = normalize(input.Normal);
|
||||
float3 L = normalize(input.LightVec);
|
||||
float3 V = normalize(input.ViewVec);
|
||||
float3 R = reflect(-L, N);
|
||||
float3 diffuse = max(dot(N, L), 0.0) * input.Color;
|
||||
float3 specular = pow(max(dot(R, V), 0.0), 8.0) * float3(0.75, 0.75, 0.75);
|
||||
return float4(diffuse + specular, 0.5);
|
||||
}
|
||||
52
data/hlsl/pipelinestatistics/scene.tesc
Normal file
52
data/hlsl/pipelinestatistics/scene.tesc
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
// Copyright 2020 Google LLC
|
||||
|
||||
struct VSOutput
|
||||
{
|
||||
float4 Pos : SV_POSITION;
|
||||
[[vk::location(0)]] float3 Normal : NORMAL0;
|
||||
[[vk::location(1)]] float3 Color : COLOR0;
|
||||
[[vk::location(2)]] float3 ViewVec : TEXCOORD1;
|
||||
[[vk::location(3)]] float3 LightVec : TEXCOORD2;
|
||||
};
|
||||
|
||||
struct HSOutput
|
||||
{
|
||||
float4 Pos : SV_POSITION;
|
||||
[[vk::location(0)]] float3 Normal : NORMAL0;
|
||||
[[vk::location(1)]] float3 Color : COLOR0;
|
||||
[[vk::location(2)]] float3 ViewVec : TEXCOORD1;
|
||||
[[vk::location(3)]] float3 LightVec : TEXCOORD2;
|
||||
};
|
||||
|
||||
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 = 2.0;
|
||||
output.TessLevelOuter[0] = 1.0;
|
||||
output.TessLevelOuter[1] = 1.0;
|
||||
output.TessLevelOuter[2] = 1.0;
|
||||
return output;
|
||||
}
|
||||
|
||||
[domain("tri")]
|
||||
[partitioning("integer")]
|
||||
[outputtopology("triangle_ccw")]
|
||||
[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.Color = patch[InvocationID].Color;
|
||||
output.ViewVec = patch[InvocationID].ViewVec;
|
||||
output.LightVec = patch[InvocationID].LightVec;
|
||||
return output;
|
||||
}
|
||||
39
data/hlsl/pipelinestatistics/scene.tese
Normal file
39
data/hlsl/pipelinestatistics/scene.tese
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright 2020 Google LLC
|
||||
|
||||
struct HSOutput
|
||||
{
|
||||
float4 Pos : SV_POSITION;
|
||||
[[vk::location(0)]] float3 Normal : NORMAL0;
|
||||
[[vk::location(1)]] float3 Color : COLOR0;
|
||||
[[vk::location(2)]] float3 ViewVec : TEXCOORD1;
|
||||
[[vk::location(3)]] float3 LightVec : TEXCOORD2;
|
||||
};
|
||||
|
||||
struct ConstantsHSOutput
|
||||
{
|
||||
float TessLevelOuter[3] : SV_TessFactor;
|
||||
float TessLevelInner : SV_InsideTessFactor;
|
||||
};
|
||||
|
||||
struct DSOutput
|
||||
{
|
||||
float4 Pos : SV_POSITION;
|
||||
[[vk::location(0)]] float3 Normal : NORMAL0;
|
||||
[[vk::location(1)]] float3 Color : COLOR0;
|
||||
[[vk::location(2)]] float3 ViewVec : TEXCOORD1;
|
||||
[[vk::location(3)]] float3 LightVec : TEXCOORD2;
|
||||
};
|
||||
|
||||
[domain("tri")]
|
||||
DSOutput main(ConstantsHSOutput input, float3 TessCoord : SV_DomainLocation, const OutputPatch<HSOutput, 3> patch)
|
||||
{
|
||||
DSOutput output = (DSOutput)0;
|
||||
output.Pos = (TessCoord.x * patch[2].Pos) +
|
||||
(TessCoord.y * patch[1].Pos) +
|
||||
(TessCoord.z * patch[0].Pos);
|
||||
output.Normal = TessCoord.x * patch[2].Normal + TessCoord.y * patch[1].Normal + TessCoord.z * patch[0].Normal;
|
||||
output.ViewVec = TessCoord.x * patch[2].ViewVec + TessCoord.y * patch[1].ViewVec + TessCoord.z * patch[0].ViewVec;
|
||||
output.LightVec = TessCoord.x * patch[2].LightVec + TessCoord.y * patch[1].LightVec + TessCoord.z * patch[0].LightVec;
|
||||
output.Color = patch[0].Color;
|
||||
return output;
|
||||
}
|
||||
48
data/hlsl/pipelinestatistics/scene.vert
Normal file
48
data/hlsl/pipelinestatistics/scene.vert
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
// Copyright 2020 Google LLC
|
||||
|
||||
struct VSInput
|
||||
{
|
||||
[[vk::location(0)]] float3 Pos : POSITION0;
|
||||
[[vk::location(1)]] float3 Normal : NORMAL0;
|
||||
[[vk::location(2)]] float3 Color : COLOR0;
|
||||
};
|
||||
|
||||
struct UBO
|
||||
{
|
||||
float4x4 projection;
|
||||
float4x4 modelview;
|
||||
float4 lightPos;
|
||||
};
|
||||
|
||||
cbuffer ubo : register(b0) { UBO ubo; }
|
||||
|
||||
struct VSOutput
|
||||
{
|
||||
float4 Pos : SV_POSITION;
|
||||
[[vk::location(0)]] float3 Normal : NORMAL0;
|
||||
[[vk::location(1)]] float3 Color : COLOR0;
|
||||
[[vk::location(2)]] float3 ViewVec : TEXCOORD1;
|
||||
[[vk::location(3)]] float3 LightVec : TEXCOORD2;
|
||||
};
|
||||
|
||||
struct PushConsts {
|
||||
float3 objPos;
|
||||
};
|
||||
[[vk::push_constant]] PushConsts pushConsts;
|
||||
|
||||
VSOutput main(VSInput input)
|
||||
{
|
||||
VSOutput output = (VSOutput)0;
|
||||
output.Normal = input.Normal;
|
||||
output.Color = input.Color;
|
||||
|
||||
float3 locPos = mul(ubo.modelview, float4(input.Pos, 1.0)).xyz;
|
||||
float3 worldPos = mul(ubo.modelview, float4(input.Pos + pushConsts.objPos, 1.0)).xyz;
|
||||
output.Pos = mul(ubo.projection, float4(worldPos, 1.0));
|
||||
|
||||
float4 pos = mul(ubo.modelview, float4(worldPos, 1.0));
|
||||
output.Normal = mul((float3x3)ubo.modelview, input.Normal);
|
||||
output.LightVec = ubo.lightPos.xyz - pos.xyz;
|
||||
output.ViewVec = -pos.xyz;
|
||||
return output;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue