From bfab2d30420e9c7bcb65de9314618c7cbe0ad46e Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Sun, 26 Jan 2020 12:05:39 +0200 Subject: [PATCH] Rebuild shaders with glslang-tools 7.12.3352-10 --- .../refresh/vk/spirv/basic_color_quad_frag.c | 2 +- .../refresh/vk/spirv/basic_color_quad_vert.c | 2 +- src/client/refresh/vk/spirv/basic_frag.c | 2 +- src/client/refresh/vk/spirv/basic_vert.c | 2 +- src/client/refresh/vk/spirv/beam_vert.c | 2 +- src/client/refresh/vk/spirv/d_light_vert.c | 2 +- src/client/refresh/vk/spirv/model_frag.c | 2 +- src/client/refresh/vk/spirv/model_vert.c | 2 +- src/client/refresh/vk/spirv/nullmodel_vert.c | 2 +- src/client/refresh/vk/spirv/particle_vert.c | 2 +- .../refresh/vk/spirv/point_particle_frag.c | 2 +- .../refresh/vk/spirv/point_particle_vert.c | 2 +- .../refresh/vk/spirv/polygon_lmap_frag.c | 2 +- .../refresh/vk/spirv/polygon_lmap_vert.c | 2 +- src/client/refresh/vk/spirv/polygon_vert.c | 2 +- .../refresh/vk/spirv/polygon_warp_vert.c | 2 +- .../refresh/vk/spirv/postprocess_frag.c | 2 +- .../refresh/vk/spirv/postprocess_vert.c | 2 +- src/client/refresh/vk/spirv/shadows_vert.c | 2 +- src/client/refresh/vk/spirv/skybox_vert.c | 2 +- src/client/refresh/vk/spirv/sprite_vert.c | 2 +- src/client/refresh/vk/spirv/world_warp_frag.c | 2 +- src/client/refresh/vk/spirv/world_warp_vert.c | 2 +- stuff/shaders.sh | 25 +++++++++++++ stuff/shaders/basic.frag | 16 ++++++++ stuff/shaders/basic.vert | 30 +++++++++++++++ stuff/shaders/basic_color_quad.frag | 10 +++++ stuff/shaders/basic_color_quad.vert | 24 ++++++++++++ stuff/shaders/beam.vert | 25 +++++++++++++ stuff/shaders/d_light.vert | 21 +++++++++++ stuff/shaders/model.frag | 17 +++++++++ stuff/shaders/model.vert | 32 ++++++++++++++++ stuff/shaders/nullmodel.vert | 26 +++++++++++++ stuff/shaders/particle.vert | 26 +++++++++++++ stuff/shaders/point_particle.frag | 14 +++++++ stuff/shaders/point_particle.vert | 37 +++++++++++++++++++ stuff/shaders/polygon.vert | 30 +++++++++++++++ stuff/shaders/polygon_lmap.frag | 17 +++++++++ stuff/shaders/polygon_lmap.vert | 32 ++++++++++++++++ stuff/shaders/polygon_warp.vert | 34 +++++++++++++++++ stuff/shaders/postprocess.frag | 27 ++++++++++++++ stuff/shaders/postprocess.vert | 17 +++++++++ stuff/shaders/shadows.vert | 24 ++++++++++++ stuff/shaders/skybox.vert | 30 +++++++++++++++ stuff/shaders/sprite.vert | 26 +++++++++++++ stuff/shaders/world_warp.frag | 36 ++++++++++++++++++ stuff/shaders/world_warp.vert | 17 +++++++++ 47 files changed, 616 insertions(+), 23 deletions(-) create mode 100755 stuff/shaders.sh create mode 100644 stuff/shaders/basic.frag create mode 100644 stuff/shaders/basic.vert create mode 100644 stuff/shaders/basic_color_quad.frag create mode 100644 stuff/shaders/basic_color_quad.vert create mode 100644 stuff/shaders/beam.vert create mode 100644 stuff/shaders/d_light.vert create mode 100644 stuff/shaders/model.frag create mode 100644 stuff/shaders/model.vert create mode 100644 stuff/shaders/nullmodel.vert create mode 100644 stuff/shaders/particle.vert create mode 100644 stuff/shaders/point_particle.frag create mode 100644 stuff/shaders/point_particle.vert create mode 100644 stuff/shaders/polygon.vert create mode 100644 stuff/shaders/polygon_lmap.frag create mode 100644 stuff/shaders/polygon_lmap.vert create mode 100644 stuff/shaders/polygon_warp.vert create mode 100644 stuff/shaders/postprocess.frag create mode 100644 stuff/shaders/postprocess.vert create mode 100644 stuff/shaders/shadows.vert create mode 100644 stuff/shaders/skybox.vert create mode 100644 stuff/shaders/sprite.vert create mode 100644 stuff/shaders/world_warp.frag create mode 100644 stuff/shaders/world_warp.vert diff --git a/src/client/refresh/vk/spirv/basic_color_quad_frag.c b/src/client/refresh/vk/spirv/basic_color_quad_frag.c index 074f186a..1a004bab 100644 --- a/src/client/refresh/vk/spirv/basic_color_quad_frag.c +++ b/src/client/refresh/vk/spirv/basic_color_quad_frag.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t basic_color_quad_frag_spv[] = { 0x07230203,0x00010000,0x00080007,0x0000000d,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/src/client/refresh/vk/spirv/basic_color_quad_vert.c b/src/client/refresh/vk/spirv/basic_color_quad_vert.c index de354469..9850c5cc 100644 --- a/src/client/refresh/vk/spirv/basic_color_quad_vert.c +++ b/src/client/refresh/vk/spirv/basic_color_quad_vert.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t basic_color_quad_vert_spv[] = { 0x07230203,0x00010000,0x00080007,0x00000032,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/src/client/refresh/vk/spirv/basic_frag.c b/src/client/refresh/vk/spirv/basic_frag.c index 6cc0ac44..4ff3ac4e 100644 --- a/src/client/refresh/vk/spirv/basic_frag.c +++ b/src/client/refresh/vk/spirv/basic_frag.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t basic_frag_spv[] = { 0x07230203,0x00010000,0x00080007,0x00000025,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/src/client/refresh/vk/spirv/basic_vert.c b/src/client/refresh/vk/spirv/basic_vert.c index 614c44bb..9c287979 100644 --- a/src/client/refresh/vk/spirv/basic_vert.c +++ b/src/client/refresh/vk/spirv/basic_vert.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t basic_vert_spv[] = { 0x07230203,0x00010000,0x00080007,0x0000003e,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/src/client/refresh/vk/spirv/beam_vert.c b/src/client/refresh/vk/spirv/beam_vert.c index f59409bf..55692033 100644 --- a/src/client/refresh/vk/spirv/beam_vert.c +++ b/src/client/refresh/vk/spirv/beam_vert.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t beam_vert_spv[] = { 0x07230203,0x00010000,0x00080007,0x00000027,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/src/client/refresh/vk/spirv/d_light_vert.c b/src/client/refresh/vk/spirv/d_light_vert.c index 482383b3..9963f8ec 100644 --- a/src/client/refresh/vk/spirv/d_light_vert.c +++ b/src/client/refresh/vk/spirv/d_light_vert.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t d_light_vert_spv[] = { 0x07230203,0x00010000,0x00080007,0x00000027,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/src/client/refresh/vk/spirv/model_frag.c b/src/client/refresh/vk/spirv/model_frag.c index 2c742954..cb33c5bb 100644 --- a/src/client/refresh/vk/spirv/model_frag.c +++ b/src/client/refresh/vk/spirv/model_frag.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t model_frag_spv[] = { 0x07230203,0x00010000,0x00080007,0x00000028,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/src/client/refresh/vk/spirv/model_vert.c b/src/client/refresh/vk/spirv/model_vert.c index 2cb0b605..aa076c69 100644 --- a/src/client/refresh/vk/spirv/model_vert.c +++ b/src/client/refresh/vk/spirv/model_vert.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t model_vert_spv[] = { 0x07230203,0x00010000,0x00080007,0x00000037,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/src/client/refresh/vk/spirv/nullmodel_vert.c b/src/client/refresh/vk/spirv/nullmodel_vert.c index e09d20ea..8a052498 100644 --- a/src/client/refresh/vk/spirv/nullmodel_vert.c +++ b/src/client/refresh/vk/spirv/nullmodel_vert.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t nullmodel_vert_spv[] = { 0x07230203,0x00010000,0x00080007,0x0000002e,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/src/client/refresh/vk/spirv/particle_vert.c b/src/client/refresh/vk/spirv/particle_vert.c index 2c5e6ed9..5f216198 100644 --- a/src/client/refresh/vk/spirv/particle_vert.c +++ b/src/client/refresh/vk/spirv/particle_vert.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t particle_vert_spv[] = { 0x07230203,0x00010000,0x00080007,0x0000002d,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/src/client/refresh/vk/spirv/point_particle_frag.c b/src/client/refresh/vk/spirv/point_particle_frag.c index 8069b178..d23d38e5 100644 --- a/src/client/refresh/vk/spirv/point_particle_frag.c +++ b/src/client/refresh/vk/spirv/point_particle_frag.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t point_particle_frag_spv[] = { 0x07230203,0x00010000,0x00080007,0x00000020,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/src/client/refresh/vk/spirv/point_particle_vert.c b/src/client/refresh/vk/spirv/point_particle_vert.c index 1651a09d..eb10b001 100644 --- a/src/client/refresh/vk/spirv/point_particle_vert.c +++ b/src/client/refresh/vk/spirv/point_particle_vert.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t point_particle_vert_spv[] = { 0x07230203,0x00010000,0x00080007,0x00000055,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/src/client/refresh/vk/spirv/polygon_lmap_frag.c b/src/client/refresh/vk/spirv/polygon_lmap_frag.c index 2ebcd331..0d2e767b 100644 --- a/src/client/refresh/vk/spirv/polygon_lmap_frag.c +++ b/src/client/refresh/vk/spirv/polygon_lmap_frag.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t polygon_lmap_frag_spv[] = { 0x07230203,0x00010000,0x00080007,0x00000029,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/src/client/refresh/vk/spirv/polygon_lmap_vert.c b/src/client/refresh/vk/spirv/polygon_lmap_vert.c index 20c06a21..6dbfdfdf 100644 --- a/src/client/refresh/vk/spirv/polygon_lmap_vert.c +++ b/src/client/refresh/vk/spirv/polygon_lmap_vert.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t polygon_lmap_vert_spv[] = { 0x07230203,0x00010000,0x00080007,0x00000036,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/src/client/refresh/vk/spirv/polygon_vert.c b/src/client/refresh/vk/spirv/polygon_vert.c index 7602ddea..69650799 100644 --- a/src/client/refresh/vk/spirv/polygon_vert.c +++ b/src/client/refresh/vk/spirv/polygon_vert.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t polygon_vert_spv[] = { 0x07230203,0x00010000,0x00080007,0x00000030,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/src/client/refresh/vk/spirv/polygon_warp_vert.c b/src/client/refresh/vk/spirv/polygon_warp_vert.c index d8a0dc71..aa94cd3f 100644 --- a/src/client/refresh/vk/spirv/polygon_warp_vert.c +++ b/src/client/refresh/vk/spirv/polygon_warp_vert.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t polygon_warp_vert_spv[] = { 0x07230203,0x00010000,0x00080007,0x00000058,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/src/client/refresh/vk/spirv/postprocess_frag.c b/src/client/refresh/vk/spirv/postprocess_frag.c index 24e10bc2..c2ab6651 100644 --- a/src/client/refresh/vk/spirv/postprocess_frag.c +++ b/src/client/refresh/vk/spirv/postprocess_frag.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t postprocess_frag_spv[] = { 0x07230203,0x00010000,0x00080007,0x00000033,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/src/client/refresh/vk/spirv/postprocess_vert.c b/src/client/refresh/vk/spirv/postprocess_vert.c index c7c2d313..d3afdf42 100644 --- a/src/client/refresh/vk/spirv/postprocess_vert.c +++ b/src/client/refresh/vk/spirv/postprocess_vert.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t postprocess_vert_spv[] = { 0x07230203,0x00010000,0x00080007,0x00000029,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/src/client/refresh/vk/spirv/shadows_vert.c b/src/client/refresh/vk/spirv/shadows_vert.c index 1cd5ddf6..626d345a 100644 --- a/src/client/refresh/vk/spirv/shadows_vert.c +++ b/src/client/refresh/vk/spirv/shadows_vert.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t shadows_vert_spv[] = { 0x07230203,0x00010000,0x00080007,0x0000002b,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/src/client/refresh/vk/spirv/skybox_vert.c b/src/client/refresh/vk/spirv/skybox_vert.c index 8746821d..241f2297 100644 --- a/src/client/refresh/vk/spirv/skybox_vert.c +++ b/src/client/refresh/vk/spirv/skybox_vert.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t skybox_vert_spv[] = { 0x07230203,0x00010000,0x00080007,0x00000032,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/src/client/refresh/vk/spirv/sprite_vert.c b/src/client/refresh/vk/spirv/sprite_vert.c index 50ccf739..0fc4c3ef 100644 --- a/src/client/refresh/vk/spirv/sprite_vert.c +++ b/src/client/refresh/vk/spirv/sprite_vert.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t sprite_vert_spv[] = { 0x07230203,0x00010000,0x00080007,0x0000002f,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/src/client/refresh/vk/spirv/world_warp_frag.c b/src/client/refresh/vk/spirv/world_warp_frag.c index 90ab1e95..8cc02a3d 100644 --- a/src/client/refresh/vk/spirv/world_warp_frag.c +++ b/src/client/refresh/vk/spirv/world_warp_frag.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t world_warp_frag_spv[] = { 0x07230203,0x00010000,0x00080007,0x00000078,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/src/client/refresh/vk/spirv/world_warp_vert.c b/src/client/refresh/vk/spirv/world_warp_vert.c index 48438f79..924bfdd6 100644 --- a/src/client/refresh/vk/spirv/world_warp_vert.c +++ b/src/client/refresh/vk/spirv/world_warp_vert.c @@ -1,4 +1,4 @@ - // 7.12.3294 + // 7.12.3352 #pragma once const uint32_t world_warp_vert_spv[] = { 0x07230203,0x00010000,0x00080007,0x00000024,0x00000000,0x00020011,0x00000001,0x0006000b, diff --git a/stuff/shaders.sh b/stuff/shaders.sh new file mode 100755 index 00000000..bb08840b --- /dev/null +++ b/stuff/shaders.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +glslangValidator --variable-name basic_vert_spv -V shaders/basic.vert -o ../src/client/refresh/vk/spirv/basic_vert.c +glslangValidator --variable-name basic_frag_spv -V shaders/basic.frag -o ../src/client/refresh/vk/spirv/basic_frag.c +glslangValidator --variable-name basic_color_quad_vert_spv -V shaders/basic_color_quad.vert -o ../src/client/refresh/vk/spirv/basic_color_quad_vert.c +glslangValidator --variable-name basic_color_quad_frag_spv -V shaders/basic_color_quad.frag -o ../src/client/refresh/vk/spirv/basic_color_quad_frag.c +glslangValidator --variable-name model_vert_spv -V shaders/model.vert -o ../src/client/refresh/vk/spirv/model_vert.c +glslangValidator --variable-name model_frag_spv -V shaders/model.frag -o ../src/client/refresh/vk/spirv/model_frag.c +glslangValidator --variable-name nullmodel_vert_spv -V shaders/nullmodel.vert -o ../src/client/refresh/vk/spirv/nullmodel_vert.c +glslangValidator --variable-name particle_vert_spv -V shaders/particle.vert -o ../src/client/refresh/vk/spirv/particle_vert.c +glslangValidator --variable-name point_particle_vert_spv -V shaders/point_particle.vert -o ../src/client/refresh/vk/spirv/point_particle_vert.c +glslangValidator --variable-name point_particle_frag_spv -V shaders/point_particle.frag -o ../src/client/refresh/vk/spirv/point_particle_frag.c +glslangValidator --variable-name sprite_vert_spv -V shaders/sprite.vert -o ../src/client/refresh/vk/spirv/sprite_vert.c +glslangValidator --variable-name beam_vert_spv -V shaders/beam.vert -o ../src/client/refresh/vk/spirv/beam_vert.c +glslangValidator --variable-name skybox_vert_spv -V shaders/skybox.vert -o ../src/client/refresh/vk/spirv/skybox_vert.c +glslangValidator --variable-name d_light_vert_spv -V shaders/d_light.vert -o ../src/client/refresh/vk/spirv/d_light_vert.c +glslangValidator --variable-name polygon_vert_spv -V shaders/polygon.vert -o ../src/client/refresh/vk/spirv/polygon_vert.c +glslangValidator --variable-name polygon_lmap_vert_spv -V shaders/polygon_lmap.vert -o ../src/client/refresh/vk/spirv/polygon_lmap_vert.c +glslangValidator --variable-name polygon_lmap_frag_spv -V shaders/polygon_lmap.frag -o ../src/client/refresh/vk/spirv/polygon_lmap_frag.c +glslangValidator --variable-name polygon_warp_vert_spv -V shaders/polygon_warp.vert -o ../src/client/refresh/vk/spirv/polygon_warp_vert.c +glslangValidator --variable-name shadows_vert_spv -V shaders/shadows.vert -o ../src/client/refresh/vk/spirv/shadows_vert.c +glslangValidator --variable-name postprocess_vert_spv -V shaders/postprocess.vert -o ../src/client/refresh/vk/spirv/postprocess_vert.c +glslangValidator --variable-name postprocess_frag_spv -V shaders/postprocess.frag -o ../src/client/refresh/vk/spirv/postprocess_frag.c +glslangValidator --variable-name world_warp_vert_spv -V shaders/world_warp.vert -o ../src/client/refresh/vk/spirv/world_warp_vert.c +glslangValidator --variable-name world_warp_frag_spv -V shaders/world_warp.frag -o ../src/client/refresh/vk/spirv/world_warp_frag.c diff --git a/stuff/shaders/basic.frag b/stuff/shaders/basic.frag new file mode 100644 index 00000000..562d9bc8 --- /dev/null +++ b/stuff/shaders/basic.frag @@ -0,0 +1,16 @@ +#version 450 + +layout(set = 0, binding = 0) uniform sampler2D sTexture; + +layout(location = 0) in vec2 texCoord; +layout(location = 1) in vec4 color; +layout(location = 2) in float aTreshold; + +layout(location = 0) out vec4 fragmentColor; + +void main() +{ + fragmentColor = texture(sTexture, texCoord) * color; + if(fragmentColor.a < aTreshold) + discard; +} diff --git a/stuff/shaders/basic.vert b/stuff/shaders/basic.vert new file mode 100644 index 00000000..42083991 --- /dev/null +++ b/stuff/shaders/basic.vert @@ -0,0 +1,30 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +// normalized offset and scale +layout(set = 1, binding = 0) uniform imageTransform +{ + vec2 offset; + vec2 scale; + vec2 uvOffset; + vec2 uvScale; +} it; + +layout(location = 0) in vec2 inVertex; +layout(location = 1) in vec2 inTexCoord; + +layout(location = 0) out vec2 texCoord; +layout(location = 1) out vec4 color; +layout(location = 2) out float aTreshold; + +out gl_PerVertex { + vec4 gl_Position; +}; + +void main() { + vec2 vPos = inVertex.xy * it.scale - (vec2(1.0) - it.scale); + gl_Position = vec4(vPos + it.offset * 2.0, 0.0, 1.0); + texCoord = inTexCoord.xy * it.uvScale + it.uvOffset; + color = vec4(1.0, 1.0, 1.0, 1.0); + aTreshold = 0.666; +} diff --git a/stuff/shaders/basic_color_quad.frag b/stuff/shaders/basic_color_quad.frag new file mode 100644 index 00000000..aec28c45 --- /dev/null +++ b/stuff/shaders/basic_color_quad.frag @@ -0,0 +1,10 @@ +#version 450 + +layout(location = 0) in vec4 color; + +layout(location = 0) out vec4 fragmentColor; + +void main() +{ + fragmentColor = color; +} diff --git a/stuff/shaders/basic_color_quad.vert b/stuff/shaders/basic_color_quad.vert new file mode 100644 index 00000000..dd4b67b5 --- /dev/null +++ b/stuff/shaders/basic_color_quad.vert @@ -0,0 +1,24 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +// normalized offset and scale +layout(set = 0, binding = 0) uniform imageTransform +{ + vec2 offset; + vec2 scale; + vec4 color; +} it; + +layout(location = 0) in vec2 inVertex; + +layout(location = 0) out vec4 color; + +out gl_PerVertex { + vec4 gl_Position; +}; + +void main() { + vec2 vPos = inVertex.xy * it.scale - (vec2(1.0) - it.scale); + gl_Position = vec4(vPos + it.offset * 2.0, 0.0, 1.0); + color = it.color; +} diff --git a/stuff/shaders/beam.vert b/stuff/shaders/beam.vert new file mode 100644 index 00000000..5d107bf2 --- /dev/null +++ b/stuff/shaders/beam.vert @@ -0,0 +1,25 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 inVertex; + +layout(push_constant) uniform PushConstant +{ + mat4 mvpMatrix; +} pc; + +layout(binding = 0) uniform UniformBufferObject +{ + vec4 color; +} ubo; + +layout(location = 0) out vec4 color; + +out gl_PerVertex { + vec4 gl_Position; +}; + +void main() { + gl_Position = pc.mvpMatrix * vec4(inVertex, 1.0); + color = ubo.color; +} diff --git a/stuff/shaders/d_light.vert b/stuff/shaders/d_light.vert new file mode 100644 index 00000000..cda70b43 --- /dev/null +++ b/stuff/shaders/d_light.vert @@ -0,0 +1,21 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 inVertex; +layout(location = 1) in vec3 inColor; + +layout(binding = 0) uniform UniformBufferObject +{ + mat4 mvpMatrix; +} ubo; + +layout(location = 0) out vec4 color; + +out gl_PerVertex { + vec4 gl_Position; +}; + +void main() { + gl_Position = ubo.mvpMatrix * vec4(inVertex, 1.0); + color = vec4(inColor, 1.0); +} diff --git a/stuff/shaders/model.frag b/stuff/shaders/model.frag new file mode 100644 index 00000000..11332440 --- /dev/null +++ b/stuff/shaders/model.frag @@ -0,0 +1,17 @@ +#version 450 + +layout(set = 0, binding = 0) uniform sampler2D sTexture; + +layout(location = 0) in vec4 color; +layout(location = 1) in vec2 texCoord; +layout(location = 2) in flat int textured; + +layout(location = 0) out vec4 fragmentColor; + +void main() +{ + if(textured != 0) + fragmentColor = texture(sTexture, texCoord) * clamp(color, 0.0, 1.0); + else + fragmentColor = color; +} diff --git a/stuff/shaders/model.vert b/stuff/shaders/model.vert new file mode 100644 index 00000000..f728e25f --- /dev/null +++ b/stuff/shaders/model.vert @@ -0,0 +1,32 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 inVertex; +layout(location = 1) in vec4 inColor; +layout(location = 2) in vec2 inTexCoord; + +layout(push_constant) uniform PushConstant +{ + mat4 vpMatrix; +} pc; + +layout(set = 1, binding = 0) uniform UniformBufferObject +{ + mat4 model; + int textured; +} ubo; + +layout(location = 0) out vec4 color; +layout(location = 1) out vec2 texCoord; +layout(location = 2) out int textured; + +out gl_PerVertex { + vec4 gl_Position; +}; + +void main() { + gl_Position = pc.vpMatrix * ubo.model * vec4(inVertex, 1.0); + color = inColor; + texCoord = inTexCoord; + textured = ubo.textured; +} diff --git a/stuff/shaders/nullmodel.vert b/stuff/shaders/nullmodel.vert new file mode 100644 index 00000000..ca696770 --- /dev/null +++ b/stuff/shaders/nullmodel.vert @@ -0,0 +1,26 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 inVertex; +layout(location = 1) in vec3 inColor; + +layout(push_constant) uniform PushConstant +{ + mat4 vpMatrix; +} pc; + +layout(binding = 0) uniform UniformBufferObject +{ + mat4 model; +} ubo; + +layout(location = 0) out vec4 color; + +out gl_PerVertex { + vec4 gl_Position; +}; + +void main() { + gl_Position = pc.vpMatrix * ubo.model * vec4(inVertex, 1.0); + color = vec4(inColor, 1.0); +} diff --git a/stuff/shaders/particle.vert b/stuff/shaders/particle.vert new file mode 100644 index 00000000..785b555e --- /dev/null +++ b/stuff/shaders/particle.vert @@ -0,0 +1,26 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 inVertex; +layout(location = 1) in vec4 inColor; +layout(location = 2) in vec2 inTexCoord; + +layout(push_constant) uniform PushConstant +{ + mat4 mvpMatrix; +} pc; + +layout(location = 0) out vec2 texCoord; +layout(location = 1) out vec4 color; +layout(location = 2) out float aTreshold; + +out gl_PerVertex { + vec4 gl_Position; +}; + +void main() { + gl_Position = pc.mvpMatrix * vec4(inVertex, 1.0); + texCoord = inTexCoord; + color = inColor; + aTreshold = 0.0; +} diff --git a/stuff/shaders/point_particle.frag b/stuff/shaders/point_particle.frag new file mode 100644 index 00000000..f47c881d --- /dev/null +++ b/stuff/shaders/point_particle.frag @@ -0,0 +1,14 @@ +#version 450 + +layout(location = 0) in vec4 color; + +layout(location = 0) out vec4 fragmentColor; + +void main() +{ + vec2 cxy = 2.0 * gl_PointCoord - 1.0; + if(dot(cxy, cxy) > 1.0) + discard; + + fragmentColor = color; +} diff --git a/stuff/shaders/point_particle.vert b/stuff/shaders/point_particle.vert new file mode 100644 index 00000000..ab407448 --- /dev/null +++ b/stuff/shaders/point_particle.vert @@ -0,0 +1,37 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 inVertex; +layout(location = 1) in vec4 inColor; + +layout(push_constant) uniform PushConstant +{ + mat4 mvpMatrix; +} pc; + +layout(binding = 0) uniform UniformBufferObject +{ + float pointSize; + float pointScale; + float minPointSize; + float maxPointSize; + float att_a; + float att_b; + float att_c; +} ubo; + +layout(location = 0) out vec4 color; + +out gl_PerVertex { + vec4 gl_Position; + float gl_PointSize; +}; + +void main() { + gl_Position = pc.mvpMatrix * vec4(inVertex, 1.0); + + float dist_atten = ubo.pointScale / (ubo.att_a + ubo.att_b * gl_Position.w + ubo.att_c * gl_Position.w * gl_Position.w); + gl_PointSize = clamp(ubo.pointScale * ubo.pointSize * sqrt(dist_atten), ubo.minPointSize, ubo.maxPointSize); + + color = inColor; +} diff --git a/stuff/shaders/polygon.vert b/stuff/shaders/polygon.vert new file mode 100644 index 00000000..120a52fc --- /dev/null +++ b/stuff/shaders/polygon.vert @@ -0,0 +1,30 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 inVertex; +layout(location = 1) in vec2 inTexCoord; + +layout(push_constant) uniform PushConstant +{ + mat4 mvpMatrix; +} pc; + +layout(set = 1, binding = 0) uniform UniformBufferObject +{ + vec4 color; +} ubo; + +layout(location = 0) out vec2 texCoord; +layout(location = 1) out vec4 color; +layout(location = 2) out float aTreshold; + +out gl_PerVertex { + vec4 gl_Position; +}; + +void main() { + gl_Position = pc.mvpMatrix * vec4(inVertex, 1.0); + texCoord = inTexCoord; + color = ubo.color; + aTreshold = 0.0; +} diff --git a/stuff/shaders/polygon_lmap.frag b/stuff/shaders/polygon_lmap.frag new file mode 100644 index 00000000..cd43691c --- /dev/null +++ b/stuff/shaders/polygon_lmap.frag @@ -0,0 +1,17 @@ +#version 450 + +layout(set = 0, binding = 0) uniform sampler2D sTexture; +layout(set = 2, binding = 0) uniform sampler2D sLightmap; + +layout(location = 0) in vec2 texCoord; +layout(location = 1) in vec2 texCoordLmap; +layout(location = 2) in float viewLightmaps; + +layout(location = 0) out vec4 fragmentColor; + +void main() +{ + vec4 color = texture(sTexture, texCoord); + vec4 light = texture(sLightmap, texCoordLmap); + fragmentColor = (1.0 - viewLightmaps) * color * light + viewLightmaps * light; +} diff --git a/stuff/shaders/polygon_lmap.vert b/stuff/shaders/polygon_lmap.vert new file mode 100644 index 00000000..88882e5d --- /dev/null +++ b/stuff/shaders/polygon_lmap.vert @@ -0,0 +1,32 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 inVertex; +layout(location = 1) in vec2 inTexCoord; +layout(location = 2) in vec2 inTexCoordLmap; + +layout(push_constant) uniform PushConstant +{ + mat4 vpMatrix; +} pc; + +layout(set = 1, binding = 0) uniform UniformBufferObject +{ + mat4 model; + float viewLightmaps; +} ubo; + +layout(location = 0) out vec2 texCoord; +layout(location = 1) out vec2 texCoordLmap; +layout(location = 2) out float viewLightmaps; + +out gl_PerVertex { + vec4 gl_Position; +}; + +void main() { + gl_Position = pc.vpMatrix * ubo.model * vec4(inVertex, 1.0); + texCoord = inTexCoord; + texCoordLmap = inTexCoordLmap; + viewLightmaps = ubo.viewLightmaps; +} diff --git a/stuff/shaders/polygon_warp.vert b/stuff/shaders/polygon_warp.vert new file mode 100644 index 00000000..609a2c02 --- /dev/null +++ b/stuff/shaders/polygon_warp.vert @@ -0,0 +1,34 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 inVertex; +layout(location = 1) in vec2 inTexCoord; + +layout(push_constant) uniform PushConstant +{ + mat4 vpMatrix; +} pc; + +layout(set = 1, binding = 0) uniform UniformBufferObject +{ + mat4 model; + vec4 color; + float time; + float scroll; +} ubo; + +layout(location = 0) out vec2 texCoord; +layout(location = 1) out vec4 color; +layout(location = 2) out float aTreshold; + +out gl_PerVertex { + vec4 gl_Position; +}; + +void main() { + gl_Position = pc.vpMatrix * ubo.model * vec4(inVertex, 1.0); + texCoord = inTexCoord + vec2(sin(2.0 * ubo.time + inTexCoord.y * 3.28), sin(2.0 * ubo.time + inTexCoord.x * 3.28)) * 0.05; + texCoord.x += ubo.scroll; + color = ubo.color; + aTreshold = 0.0; +} diff --git a/stuff/shaders/postprocess.frag b/stuff/shaders/postprocess.frag new file mode 100644 index 00000000..f5c21a35 --- /dev/null +++ b/stuff/shaders/postprocess.frag @@ -0,0 +1,27 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(push_constant) uniform PushConstant +{ + float postprocess; + float gamma; +} pc; + +layout(set = 0, binding = 0) uniform sampler2D sTexture; + +layout(location = 0) in vec2 texCoord; +layout(location = 0) out vec4 fragmentColor; + +void main() +{ + // apply any additional world-only postprocessing effects here (if enabled) + if (pc.postprocess > 0.0) + { + //gamma + color intensity bump + fragmentColor = vec4(pow(texture(sTexture, texCoord).rgb * 1.5, vec3(pc.gamma)), 1.0); + } + else + { + fragmentColor = texture(sTexture, texCoord); + } +} diff --git a/stuff/shaders/postprocess.vert b/stuff/shaders/postprocess.vert new file mode 100644 index 00000000..438e62e0 --- /dev/null +++ b/stuff/shaders/postprocess.vert @@ -0,0 +1,17 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +// rendering a fullscreen quad (which is actually just a huge triangle) +// source: https://www.saschawillems.de/blog/2016/08/13/vulkan-tutorial-on-rendering-a-fullscreen-quad-without-buffers/ + +out gl_PerVertex { + vec4 gl_Position; +}; + +layout(location = 0) out vec2 texCoord; + +void main() +{ + texCoord = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2); + gl_Position = vec4(texCoord * 2.0f + -1.0f, 0.0f, 1.0f); +} diff --git a/stuff/shaders/shadows.vert b/stuff/shaders/shadows.vert new file mode 100644 index 00000000..24fbae93 --- /dev/null +++ b/stuff/shaders/shadows.vert @@ -0,0 +1,24 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 inVertex; +layout(location = 0) out vec4 color; + +layout(push_constant) uniform PushConstant +{ + mat4 vpMatrix; +} pc; + +layout(binding = 0) uniform UniformBufferObject +{ + mat4 model; +} ubo; + +out gl_PerVertex { + vec4 gl_Position; +}; + +void main() { + gl_Position = pc.vpMatrix * ubo.model * vec4(inVertex, 1.0); + color = vec4(0.0, 0.0, 0.0, 0.5); +} diff --git a/stuff/shaders/skybox.vert b/stuff/shaders/skybox.vert new file mode 100644 index 00000000..348777c0 --- /dev/null +++ b/stuff/shaders/skybox.vert @@ -0,0 +1,30 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 inVertex; +layout(location = 1) in vec2 inTexCoord; + +layout(push_constant) uniform PushConstant +{ + mat4 vpMatrix; +} pc; + +layout(set = 1, binding = 0) uniform UniformBufferObject +{ + mat4 model; +} ubo; + +layout(location = 0) out vec2 texCoord; +layout(location = 1) out vec4 color; +layout(location = 2) out float aTreshold; + +out gl_PerVertex { + vec4 gl_Position; +}; + +void main() { + gl_Position = pc.vpMatrix * ubo.model * vec4(inVertex, 1.0); + texCoord = inTexCoord; + color = vec4(1.0, 1.0, 1.0, 1.0); + aTreshold = 0.0; +} diff --git a/stuff/shaders/sprite.vert b/stuff/shaders/sprite.vert new file mode 100644 index 00000000..f42a66c6 --- /dev/null +++ b/stuff/shaders/sprite.vert @@ -0,0 +1,26 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +layout(location = 0) in vec3 inVertex; +layout(location = 1) in vec2 inTexCoord; + +layout(push_constant) uniform PushConstant +{ + mat4 mvpMatrix; + float alpha; +} pc; + +layout(location = 0) out vec2 texCoord; +layout(location = 1) out vec4 color; +layout(location = 2) out float aTreshold; + +out gl_PerVertex { + vec4 gl_Position; +}; + +void main() { + gl_Position = pc.mvpMatrix * vec4(inVertex, 1.0); + texCoord = inTexCoord; + color = vec4(1.0, 1.0, 1.0, pc.alpha); + aTreshold = 0.0666; +} diff --git a/stuff/shaders/world_warp.frag b/stuff/shaders/world_warp.frag new file mode 100644 index 00000000..984bc434 --- /dev/null +++ b/stuff/shaders/world_warp.frag @@ -0,0 +1,36 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +// Underwater screen warp effect similar to what software renderer provides + +layout(push_constant) uniform PushConstant +{ + float time; + float scale; + float scrWidth; + float scrHeight; +} pc; + +layout(set = 0, binding = 0) uniform sampler2D sTexture; + +layout(location = 0) out vec4 fragmentColor; + +#define PI 3.1415 + +void main() +{ + vec2 uv = vec2(gl_FragCoord.x / pc.scrWidth, gl_FragCoord.y / pc.scrHeight); + + if (pc.time > 0) + { + float sx = pc.scale - abs(pc.scrWidth / 2.0 - gl_FragCoord.x) * 2.0 / pc.scrWidth; + float sy = pc.scale - abs(pc.scrHeight / 2.0 - gl_FragCoord.y) * 2.0 / pc.scrHeight; + float xShift = 2.0 * pc.time + uv.y * PI * 10; + float yShift = 2.0 * pc.time + uv.x * PI * 10; + vec2 distortion = vec2(sin(xShift) * sx, sin(yShift) * sy) * 0.00666; + + uv += distortion; + } + + fragmentColor = texture(sTexture, uv); +} diff --git a/stuff/shaders/world_warp.vert b/stuff/shaders/world_warp.vert new file mode 100644 index 00000000..e09723ba --- /dev/null +++ b/stuff/shaders/world_warp.vert @@ -0,0 +1,17 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable + +out gl_PerVertex { + vec4 gl_Position; +}; + +void main() +{ + vec4 positions[3] = { + vec4(-1.0f, -1.0f, 0.0f, 1.0f), + vec4(3.0f, -1.0f, 0.0f, 1.0f), + vec4(-1.0f, 3.0f, 0.0f, 1.0f) + }; + + gl_Position = positions[gl_VertexIndex % 3]; +}