Moved shaders to new directory

This commit is contained in:
Sascha Willems 2023-05-09 21:03:02 +02:00
parent 0b3f8340e3
commit 99b226237a
1244 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,41 @@
// Copyright 2020 Google LLC
Texture2D textureColor : register(t1);
SamplerState samplerColor : register(s1);
struct VSOutput
{
[[vk::location(0)]] float4 ProjCoord : POSITION0;
};
float4 main(VSOutput input, bool FrontFacing : SV_IsFrontFace) : SV_TARGET
{
float4 tmp = (1.0 / input.ProjCoord.w).xxxx;
float4 projCoord = input.ProjCoord * tmp;
// Scale and bias
projCoord += float4(1.0, 1.0, 1.0, 1.0);
projCoord *= float4(0.5, 0.5, 0.5, 0.5);
// Slow single pass blur
// For demonstration purposes only
const float blurSize = 1.0 / 512.0;
float4 color = float4(float3(0.0, 0.0, 0.0), 1.);
if (FrontFacing)
{
// Only render mirrored scene on front facing (upper) side of mirror surface
float4 reflection = float4(0.0, 0.0, 0.0, 0.0);
for (int x = -3; x <= 3; x++)
{
for (int y = -3; y <= 3; y++)
{
reflection += textureColor.Sample(samplerColor, float2(projCoord.x + x * blurSize, projCoord.y + y * blurSize)) / 49.0;
}
}
color += reflection;
}
return color;
}

Binary file not shown.

View file

@ -0,0 +1,29 @@
// Copyright 2020 Google LLC
struct VSInput
{
[[vk::location(0)]] float3 Pos : POSITION0;
};
struct UBO
{
float4x4 projection;
float4x4 view;
float4x4 model;
};
cbuffer ubo : register(b0) { UBO ubo; }
struct VSOutput
{
float4 Pos : SV_POSITION;
[[vk::location(0)]] float4 ProjCoord : POSITION0;
};
VSOutput main(VSInput input)
{
VSOutput output = (VSOutput)0;
output.ProjCoord = mul(ubo.projection, mul(ubo.view, mul(ubo.model, float4(input.Pos.xyz, 1.0))));
output.Pos = output.ProjCoord;
return output;
}

Binary file not shown.

View file

@ -0,0 +1,26 @@
// Copyright 2020 Google LLC
struct VSOutput
{
[[vk::location(0)]] float3 Normal : NORMAL0;
[[vk::location(1)]] float3 Color : COLOR0;
[[vk::location(2)]] float3 EyePos : POSITION0;
[[vk::location(3)]] float3 LightVec : TEXCOORD2;
};
float4 main(VSOutput input) : SV_TARGET
{
float3 Eye = normalize(-input.EyePos);
float3 Reflected = normalize(reflect(-input.LightVec, input.Normal));
float4 IAmbient = float4(0.1, 0.1, 0.1, 1.0);
float4 IDiffuse = max(dot(input.Normal, input.LightVec), 0.0).xxxx;
float specular = 0.75;
float4 ISpecular = float4(0.0, 0.0, 0.0, 0.0);
if (dot(input.EyePos, input.Normal) < 0.0)
{
ISpecular = float4(0.5, 0.5, 0.5, 1.0) * pow(max(dot(Reflected, Eye), 0.0), 16.0) * specular;
}
return float4((IAmbient + IDiffuse) * float4(input.Color, 1.0) + ISpecular);
}

Binary file not shown.

View file

@ -0,0 +1,43 @@
// Copyright 2020 Google LLC
struct VSInput
{
[[vk::location(0)]] float4 Pos : POSITION0;
[[vk::location(1)]] float3 Color : COLOR0;
[[vk::location(2)]] float3 Normal : NORMAL0;
};
struct UBO
{
float4x4 projection;
float4x4 view;
float4x4 model;
float4 lightPos;
};
cbuffer ubo : register(b0) { UBO ubo; }
struct VSOutput
{
float4 Pos : SV_POSITION;
float ClipDistance : SV_ClipDistance0;
[[vk::location(0)]] float3 Normal : NORMAL0;
[[vk::location(1)]] float3 Color : COLOR0;
[[vk::location(2)]] float3 EyePos : POSITION0;
[[vk::location(3)]] float3 LightVec : TEXCOORD2;
};
VSOutput main(VSInput input)
{
VSOutput output = (VSOutput)0;
output.Normal = input.Normal;
output.Color = input.Color;
output.Pos = mul(ubo.projection, mul(ubo.view, mul(ubo.model, input.Pos)));
output.EyePos = mul(ubo.view, mul(ubo.model, input.Pos)).xyz;
output.LightVec = normalize(ubo.lightPos.xyz - output.EyePos);
// Clip against reflection plane
float4 clipPlane = float4(0.0, -1.0, 0.0, 1.5);
output.ClipDistance = dot(input.Pos, clipPlane);
return output;
}

Binary file not shown.

View file

@ -0,0 +1,9 @@
// Copyright 2020 Google LLC
Texture2D textureColor : register(t1);
SamplerState samplerColor : register(s1);
float4 main([[vk::location(0)]] float2 inUV : TEXCOORD0) : SV_TARGET
{
return textureColor.Sample(samplerColor, inUV);
}

Binary file not shown.

View file

@ -0,0 +1,15 @@
// Copyright 2020 Google LLC
struct VSOutput
{
float4 Pos : SV_POSITION;
[[vk::location(0)]] float2 UV : TEXCOORD0;
};
VSOutput main(uint VertexIndex : SV_VertexID)
{
VSOutput output = (VSOutput)0;
output.UV = float2((VertexIndex << 1) & 2, VertexIndex & 2);
output.Pos = float4(output.UV * 2.0f - 1.0f, 0.0f, 1.0f);
return output;
}

Binary file not shown.