Move shaders into glsl and hlsl directories
Move `data/shaders` to `data/shaders/glsl` Move `data/hlsl` to `data/shaders/hlsl` Fix up shader paths in the cpp files to point to the new glsl location. `data/shaders/hlsl/compile.py` still overwrites the glsl .spv files (for now). Issue: #723
This commit is contained in:
parent
cac1d2e850
commit
ca884587a4
1043 changed files with 1207 additions and 1201 deletions
42
data/shaders/hlsl/offscreen/mirror.frag
Normal file
42
data/shaders/hlsl/offscreen/mirror.frag
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
// Copyright 2020 Google LLC
|
||||
|
||||
Texture2D textureColor : register(t1);
|
||||
SamplerState samplerColor : register(s1);
|
||||
|
||||
struct VSOutput
|
||||
{
|
||||
[[vk::location(0)]] float2 UV : TEXCOORD0;
|
||||
[[vk::location(1)]] 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;
|
||||
}
|
||||
32
data/shaders/hlsl/offscreen/mirror.vert
Normal file
32
data/shaders/hlsl/offscreen/mirror.vert
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright 2020 Google LLC
|
||||
|
||||
struct VSInput
|
||||
{
|
||||
[[vk::location(0)]] float3 Pos : POSITION0;
|
||||
[[vk::location(1)]] float2 UV : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct UBO
|
||||
{
|
||||
float4x4 projection;
|
||||
float4x4 view;
|
||||
float4x4 model;
|
||||
};
|
||||
|
||||
cbuffer ubo : register(b0) { UBO ubo; }
|
||||
|
||||
struct VSOutput
|
||||
{
|
||||
float4 Pos : SV_POSITION;
|
||||
[[vk::location(0)]] float2 UV : TEXCOORD0;
|
||||
[[vk::location(1)]] float4 ProjCoord : POSITION0;
|
||||
};
|
||||
|
||||
VSOutput main(VSInput input)
|
||||
{
|
||||
VSOutput output = (VSOutput)0;
|
||||
output.UV = input.UV;
|
||||
output.ProjCoord = mul(ubo.projection, mul(ubo.view, mul(ubo.model, float4(input.Pos.xyz, 1.0))));
|
||||
output.Pos = output.ProjCoord;
|
||||
return output;
|
||||
}
|
||||
26
data/shaders/hlsl/offscreen/phong.frag
Normal file
26
data/shaders/hlsl/offscreen/phong.frag
Normal 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);
|
||||
}
|
||||
43
data/shaders/hlsl/offscreen/phong.vert
Normal file
43
data/shaders/hlsl/offscreen/phong.vert
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
// Copyright 2020 Google LLC
|
||||
|
||||
struct VSInput
|
||||
{
|
||||
[[vk::location(0)]] float4 Pos : POSITION0;
|
||||
[[vk::location(2)]] float3 Color : COLOR0;
|
||||
[[vk::location(3)]] 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;
|
||||
}
|
||||
9
data/shaders/hlsl/offscreen/quad.frag
Normal file
9
data/shaders/hlsl/offscreen/quad.frag
Normal 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);
|
||||
}
|
||||
28
data/shaders/hlsl/offscreen/quad.vert
Normal file
28
data/shaders/hlsl/offscreen/quad.vert
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2020 Google LLC
|
||||
|
||||
struct VSInput
|
||||
{
|
||||
[[vk::location(0)]] float3 Pos : POSITION0;
|
||||
[[vk::location(1)]] float2 UV : TEXCOORD0;
|
||||
};
|
||||
struct UBO
|
||||
{
|
||||
float4x4 projection;
|
||||
float4x4 model;
|
||||
};
|
||||
|
||||
cbuffer ubo : register(b0) { UBO ubo; }
|
||||
|
||||
struct VSOutput
|
||||
{
|
||||
float4 Pos : SV_POSITION;
|
||||
[[vk::location(0)]] float2 UV : TEXCOORD0;
|
||||
};
|
||||
|
||||
VSOutput main(VSInput input)
|
||||
{
|
||||
VSOutput output = (VSOutput)0;
|
||||
output.UV = input.UV;
|
||||
output.Pos = mul(ubo.projection, mul(ubo.model, float4(input.Pos.xyz, 1.0)));
|
||||
return output;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue