mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-22 20:41:20 +00:00
[vulkan] Create a water warp output pipeline
Although it works as intended (tested via hacking), it's not hooked up as the current frame buffer handling in r_screen is not readily compatible with how vulkan output is handled. This will need some thought to get working.
This commit is contained in:
parent
22615f25ab
commit
efc3443c61
5 changed files with 91 additions and 2 deletions
|
@ -359,8 +359,12 @@ passthrough_src = $(vkshaderpath)/passthrough.vert
|
|||
passthrough_c = $(vkshaderpath)/passthrough.vert.spvc
|
||||
fstriangle_src = $(vkshaderpath)/fstriangle.vert
|
||||
fstriangle_c = $(vkshaderpath)/fstriangle.vert.spvc
|
||||
fstrianglest_src = $(vkshaderpath)/fstrianglest.vert
|
||||
fstrianglest_c = $(vkshaderpath)/fstrianglest.vert.spvc
|
||||
pushcolor_src = $(vkshaderpath)/pushcolor.frag
|
||||
pushcolor_c = $(vkshaderpath)/pushcolor.frag.spvc
|
||||
waterwarp_src = $(vkshaderpath)/waterwarp.frag
|
||||
waterwarp_c = $(vkshaderpath)/waterwarp.frag.spvc
|
||||
|
||||
$(slice_vert_c): $(slice_vert_src)
|
||||
|
||||
|
@ -432,8 +436,12 @@ $(passthrough_c): $(passthrough_src)
|
|||
|
||||
$(fstriangle_c): $(fstriangle_src)
|
||||
|
||||
$(fstrianglest_c): $(fstrianglest_src)
|
||||
|
||||
$(pushcolor_c): $(pushcolor_src)
|
||||
|
||||
$(waterwarp_c): $(waterwarp_src)
|
||||
|
||||
vkshader_c = \
|
||||
$(slice_c) \
|
||||
$(glyphv_c) \
|
||||
|
@ -473,8 +481,10 @@ vkshader_c = \
|
|||
$(output_c) \
|
||||
$(passthrough_c) \
|
||||
$(fstriangle_c) \
|
||||
$(fstrianglest_c) \
|
||||
$(pushcolor_c) \
|
||||
$(shadow_c)
|
||||
$(shadow_c) \
|
||||
$(waterwarp_c)
|
||||
|
||||
V_VKGEN = $(V_VKGEN_@AM_V@)
|
||||
V_VKGEN_ = $(V_VKGEN_@AM_DEFAULT_V@)
|
||||
|
@ -532,6 +542,7 @@ EXTRA_DIST += \
|
|||
libs/video/renderer/vulkan/shader/lighting.frag \
|
||||
libs/video/renderer/vulkan/shader/passthrough.vert \
|
||||
libs/video/renderer/vulkan/shader/fstriangle.vert \
|
||||
libs/video/renderer/vulkan/shader/fstrianglest.vert \
|
||||
libs/video/renderer/vulkan/shader/partphysics.comp \
|
||||
libs/video/renderer/vulkan/shader/partupdate.comp \
|
||||
libs/video/renderer/vulkan/shader/particle.vert \
|
||||
|
@ -547,4 +558,5 @@ EXTRA_DIST += \
|
|||
libs/video/renderer/vulkan/shader/sprite_gbuf.frag \
|
||||
libs/video/renderer/vulkan/shader/twod_depth.frag \
|
||||
libs/video/renderer/vulkan/shader/twod.frag \
|
||||
libs/video/renderer/vulkan/shader/twod.vert
|
||||
libs/video/renderer/vulkan/shader/twod.vert \
|
||||
libs/video/renderer/vulkan/shader/waterwarp.frag
|
||||
|
|
|
@ -56,6 +56,16 @@
|
|||
output_layout = {
|
||||
setLayouts = (matrix_set, output_set);
|
||||
};
|
||||
waterwarp_layout = {
|
||||
@inherit = $properties.pipelineLayouts.output_layout;
|
||||
pushConstantRanges = (
|
||||
{
|
||||
stageFlags = fragment;
|
||||
offset = 0;
|
||||
size = "4";
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
depthStencil = {
|
||||
|
@ -152,6 +162,11 @@
|
|||
name = main;
|
||||
module = $builtin/fstriangle.vert;
|
||||
};
|
||||
vertexStageST = {
|
||||
stage = vertex;
|
||||
name = main;
|
||||
module = $builtin/fstrianglest.vert;
|
||||
};
|
||||
vertexInput = {
|
||||
bindings = ();
|
||||
attributes = ();
|
||||
|
@ -205,5 +220,18 @@
|
|||
);
|
||||
layout = output_layout;
|
||||
};
|
||||
waterwarp = {
|
||||
@inherit = $properties.pipelines.output_base;
|
||||
subpass = 0;
|
||||
stages = (
|
||||
$properties.fstriangle.vertexStageST,
|
||||
{
|
||||
stage = fragment;
|
||||
name = main;
|
||||
module = $builtin/waterwarp.frag;
|
||||
},
|
||||
);
|
||||
layout = waterwarp_layout;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -115,7 +115,11 @@ static
|
|||
static
|
||||
#include "libs/video/renderer/vulkan/shader/fstriangle.vert.spvc"
|
||||
static
|
||||
#include "libs/video/renderer/vulkan/shader/fstrianglest.vert.spvc"
|
||||
static
|
||||
#include "libs/video/renderer/vulkan/shader/pushcolor.frag.spvc"
|
||||
static
|
||||
#include "libs/video/renderer/vulkan/shader/waterwarp.frag.spvc"
|
||||
|
||||
typedef struct shaderdata_s {
|
||||
const char *name;
|
||||
|
@ -162,7 +166,9 @@ static shaderdata_t builtin_shaders[] = {
|
|||
{ "output.frag", output_frag, sizeof (output_frag) },
|
||||
{ "passthrough.vert", passthrough_vert, sizeof (passthrough_vert) },
|
||||
{ "fstriangle.vert", fstriangle_vert, sizeof (fstriangle_vert) },
|
||||
{ "fstrianglest.vert", fstrianglest_vert, sizeof (fstrianglest_vert) },
|
||||
{ "pushcolor.frag", pushcolor_frag, sizeof (pushcolor_frag) },
|
||||
{ "waterwarp.frag", waterwarp_frag, sizeof (waterwarp_frag) },
|
||||
{}
|
||||
};
|
||||
|
||||
|
|
12
libs/video/renderer/vulkan/shader/fstrianglest.vert
Normal file
12
libs/video/renderer/vulkan/shader/fstrianglest.vert
Normal file
|
@ -0,0 +1,12 @@
|
|||
#version 450
|
||||
|
||||
layout (location = 0) out vec2 st;
|
||||
|
||||
void
|
||||
main ()
|
||||
{
|
||||
float x = (gl_VertexIndex & 2);
|
||||
float y = (gl_VertexIndex & 1);
|
||||
gl_Position = vec4 (2, 4, 0, 1) * vec4 (x, y, 0, 1) - vec4 (1, 1, 0, 0);
|
||||
st = vec2(1, 2) * vec2(x, y);
|
||||
}
|
31
libs/video/renderer/vulkan/shader/waterwarp.frag
Normal file
31
libs/video/renderer/vulkan/shader/waterwarp.frag
Normal file
|
@ -0,0 +1,31 @@
|
|||
#version 450
|
||||
#extension GL_GOOGLE_include_directive : enable
|
||||
|
||||
layout (set = 0, binding = 0) uniform
|
||||
#include "matrices.h"
|
||||
;
|
||||
|
||||
layout (set = 1, binding = 0) uniform sampler2D Input;
|
||||
|
||||
layout (push_constant) uniform PushConstants {
|
||||
float time;
|
||||
};
|
||||
|
||||
layout (location = 0) in vec2 uv;
|
||||
|
||||
layout (location = 0) out vec4 frag_color;
|
||||
|
||||
const float S = 0.15625;
|
||||
const float F = 2.5;
|
||||
const float A = 0.01;
|
||||
const vec2 B = vec2 (1, 1);
|
||||
const float PI = 3.14159265;
|
||||
|
||||
void
|
||||
main (void)
|
||||
{
|
||||
vec2 st;
|
||||
st = uv * (1.0 - 2.0*A) + A * (B + sin ((time * S + F * uv.yx) * 2.0*PI));
|
||||
vec4 c = texture (Input, st);
|
||||
frag_color = c;//vec4(uv, c.x, 1);
|
||||
}
|
Loading…
Reference in a new issue