From 20fdf676cf4f2c5eefb9237233336a8c96468ac8 Mon Sep 17 00:00:00 2001 From: deccer Date: Wed, 23 Nov 2022 23:43:13 +0100 Subject: [PATCH] Use shaders with include section to show off ShaderParser --- .../Swapchain.Assets/Shaders/Common.glsl | 14 ++++++++++++++ .../Swapchain.Assets/Shaders/FST.vs.glsl | 6 +++++- .../Swapchain.Assets/Shaders/Scene.vs.glsl | 19 +++++-------------- 3 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 examples/Swapchain/Swapchain.Assets/Shaders/Common.glsl diff --git a/examples/Swapchain/Swapchain.Assets/Shaders/Common.glsl b/examples/Swapchain/Swapchain.Assets/Shaders/Common.glsl new file mode 100644 index 0000000..5f4ff2c --- /dev/null +++ b/examples/Swapchain/Swapchain.Assets/Shaders/Common.glsl @@ -0,0 +1,14 @@ +layout(binding = 0, std140) uniform GpuConstants +{ + mat4 ViewProj; +}; + +struct GpuObject +{ + mat4 World; +}; + +layout(binding = 1, std430) readonly buffer ObjectBuffer +{ + GpuObject Objects[]; +} objectBuffer; diff --git a/examples/Swapchain/Swapchain.Assets/Shaders/FST.vs.glsl b/examples/Swapchain/Swapchain.Assets/Shaders/FST.vs.glsl index 5b86bec..f0dcb7e 100644 --- a/examples/Swapchain/Swapchain.Assets/Shaders/FST.vs.glsl +++ b/examples/Swapchain/Swapchain.Assets/Shaders/FST.vs.glsl @@ -1,6 +1,10 @@ #version 460 core -layout(location = 0) out vec2 fs_uv; +layout (location = 0) out gl_PerVertex +{ + vec4 gl_Position; +}; +layout(location = 1) out vec2 fs_uv; void main() { diff --git a/examples/Swapchain/Swapchain.Assets/Shaders/Scene.vs.glsl b/examples/Swapchain/Swapchain.Assets/Shaders/Scene.vs.glsl index 16434df..99629a9 100644 --- a/examples/Swapchain/Swapchain.Assets/Shaders/Scene.vs.glsl +++ b/examples/Swapchain/Swapchain.Assets/Shaders/Scene.vs.glsl @@ -5,25 +5,16 @@ layout(location = 1) in vec3 i_normal; layout(location = 2) in vec2 i_uv; layout(location = 3) in vec2 i_tangent; +layout (location = 0) out gl_PerVertex +{ + vec4 gl_Position; +}; layout(location = 0) out vec3 v_position; layout(location = 1) out vec3 v_normal; layout(location = 2) out vec2 v_uv; layout(location = 3) out flat int v_object_id; -layout(binding = 0, std140) uniform GpuConstants -{ - mat4 ViewProj; -}; - -struct GpuObject -{ - mat4 World; -}; - -layout(binding = 1, std430) readonly buffer ObjectBuffer -{ - GpuObject Objects[]; -} objectBuffer; +#include "Common.glsl" void main() {