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
56
data/hlsl/viewportarray/multiview.geom
Normal file
56
data/hlsl/viewportarray/multiview.geom
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
// Copyright 2020 Google LLC
|
||||
|
||||
struct UBO
|
||||
{
|
||||
float4x4 projection[2];
|
||||
float4x4 modelview[2];
|
||||
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;
|
||||
};
|
||||
|
||||
struct GSOutput
|
||||
{
|
||||
float4 Pos : SV_POSITION;
|
||||
uint ViewportIndex : SV_ViewportArrayIndex;
|
||||
uint PrimitiveID : SV_PrimitiveID;
|
||||
[[vk::location(0)]] float3 Normal : NORMAL0;
|
||||
[[vk::location(1)]] float3 Color : COLOR0;
|
||||
[[vk::location(2)]] float3 ViewVec : TEXCOOR1;
|
||||
[[vk::location(3)]] float3 LightVec : TEXCOOR2;
|
||||
};
|
||||
|
||||
[maxvertexcount(3)]
|
||||
[instance(2)]
|
||||
void main(triangle VSOutput input[3], inout TriangleStream<GSOutput> outStream, uint InvocationID : SV_GSInstanceID, uint PrimitiveID : SV_PrimitiveID)
|
||||
{
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
GSOutput output = (GSOutput)0;
|
||||
output.Normal = mul((float3x3)ubo.modelview[InvocationID], input[i].Normal);
|
||||
output.Color = input[i].Color;
|
||||
|
||||
float4 pos = input[i].Pos;
|
||||
float4 worldPos = mul(ubo.modelview[InvocationID], pos);
|
||||
|
||||
float3 lPos = mul(ubo.modelview[InvocationID], ubo.lightPos).xyz;
|
||||
output.LightVec = lPos - worldPos.xyz;
|
||||
output.ViewVec = -worldPos.xyz;
|
||||
|
||||
output.Pos = mul(ubo.projection[InvocationID], worldPos);
|
||||
|
||||
// Set the viewport index that the vertex will be emitted to
|
||||
output.ViewportIndex = InvocationID;
|
||||
output.PrimitiveID = PrimitiveID;
|
||||
outStream.Append( output );
|
||||
}
|
||||
|
||||
outStream.RestartStrip();
|
||||
}
|
||||
21
data/hlsl/viewportarray/scene.frag
Normal file
21
data/hlsl/viewportarray/scene.frag
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2020 Google LLC
|
||||
|
||||
struct GSOutput
|
||||
{
|
||||
[[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(GSOutput input) : SV_TARGET
|
||||
{
|
||||
float3 N = normalize(input.Normal);
|
||||
float3 L = normalize(input.LightVec);
|
||||
float3 V = normalize(input.ViewVec);
|
||||
float3 R = reflect(-L, N);
|
||||
float3 ambient = float3(0.1, 0.1, 0.1);
|
||||
float3 diffuse = max(dot(N, L), 0.0) * float3(1.0, 1.0, 1.0);
|
||||
float3 specular = pow(max(dot(R, V), 0.0), 16.0) * float3(0.75, 0.75, 0.75);
|
||||
return float4((ambient + diffuse) * input.Color.rgb + specular, 1.0);
|
||||
}
|
||||
24
data/hlsl/viewportarray/scene.vert
Normal file
24
data/hlsl/viewportarray/scene.vert
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// 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 VSOutput
|
||||
{
|
||||
float4 Pos : SV_POSITION;
|
||||
[[vk::location(0)]] float3 Normal : NORMAL0;
|
||||
[[vk::location(1)]] float3 Color : COLOR0;
|
||||
};
|
||||
|
||||
VSOutput main(VSInput input)
|
||||
{
|
||||
VSOutput output = (VSOutput)0;
|
||||
output.Color = input.Color;
|
||||
output.Normal = input.Normal;
|
||||
output.Pos = float4(input.Pos.xyz, 1.0);
|
||||
return output;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue