mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 23:11:38 +00:00
[vulkan] Create shaders for alias deferred rendering
A simple (no uv output) vertex shader that still blends the two frames, and the relevant g-buffer fragment shader.
This commit is contained in:
parent
b08c3881b9
commit
64740b0f73
5 changed files with 81 additions and 5 deletions
|
@ -278,6 +278,10 @@ aliasv_src = $(vkshaderpath)/alias.vert
|
|||
aliasv_c = $(vkshaderpath)/alias.vert.spvc
|
||||
aliasf_src = $(vkshaderpath)/alias.frag
|
||||
aliasf_c = $(vkshaderpath)/alias.frag.spvc
|
||||
alias_depth_src = $(vkshaderpath)/alias_depth.vert
|
||||
alias_depth_c = $(vkshaderpath)/alias_depth.vert.spvc
|
||||
alias_gbuf_src = $(vkshaderpath)/alias_gbuf.frag
|
||||
alias_gbuf_c = $(vkshaderpath)/alias_gbuf.frag.spvc
|
||||
passthrough_src = $(vkshaderpath)/passthrough.vert
|
||||
passthrough_c = $(vkshaderpath)/passthrough.vert.spvc
|
||||
pushcolor_src = $(vkshaderpath)/pushcolor.frag
|
||||
|
@ -293,8 +297,12 @@ $(quakebspf_c): $(quakebspf_src)
|
|||
|
||||
$(aliasv_c): $(aliasv_src)
|
||||
|
||||
$(alias_depth_c): $(alias_depth_src)
|
||||
|
||||
$(aliasf_c): $(aliasf_src)
|
||||
|
||||
$(alias_gbuf_c): $(alias_gbuf_src)
|
||||
|
||||
$(passthrough_c): $(passthrough_src)
|
||||
|
||||
$(pushcolor_c): $(pushcolor_src)
|
||||
|
@ -305,7 +313,9 @@ vkshader_c = \
|
|||
$(quakebspv_c) \
|
||||
$(quakebspf_c) \
|
||||
$(aliasv_c) \
|
||||
$(alias_depth_c) \
|
||||
$(aliasf_c) \
|
||||
$(alias_gbuf_c) \
|
||||
$(passthrough_c) \
|
||||
$(pushcolor_c)
|
||||
|
||||
|
|
|
@ -278,7 +278,7 @@
|
|||
{
|
||||
stage = vertex;
|
||||
name = main;
|
||||
module = $builtin/alias.vert;
|
||||
module = $builtin/alias_depth.vert;
|
||||
},
|
||||
);
|
||||
vertexInput = {
|
||||
|
@ -321,7 +321,7 @@
|
|||
{
|
||||
stage = fragment;
|
||||
name = main;
|
||||
module = $builtin/alias.frag;
|
||||
module = $builtin/alias_gbuf.frag;
|
||||
specializationInfo = {
|
||||
mapEntries = (
|
||||
{ size = 4; offset = 0; constantID = 0; },
|
||||
|
@ -447,7 +447,7 @@
|
|||
{
|
||||
stage = vertex;
|
||||
name = main;
|
||||
module = $builtin/quakebsp.vert;
|
||||
module = $builtin/bsp_depth.vert;
|
||||
},
|
||||
);
|
||||
vertexInput = {
|
||||
|
@ -481,12 +481,12 @@
|
|||
{
|
||||
stage = vertex;
|
||||
name = main;
|
||||
module = $builtin/quakebsp.vert;
|
||||
module = $builtin/bsp_gbuf.vert;
|
||||
},
|
||||
{
|
||||
stage = fragment;
|
||||
name = main;
|
||||
module = $builtin/quakebsp.frag;
|
||||
module = $builtin/bsp_gbuf.frag;
|
||||
},
|
||||
);
|
||||
vertexInput = {
|
||||
|
|
|
@ -65,8 +65,12 @@ static
|
|||
static
|
||||
#include "libs/video/renderer/vulkan/shader/alias.vert.spvc"
|
||||
static
|
||||
#include "libs/video/renderer/vulkan/shader/alias_depth.vert.spvc"
|
||||
static
|
||||
#include "libs/video/renderer/vulkan/shader/alias.frag.spvc"
|
||||
static
|
||||
#include "libs/video/renderer/vulkan/shader/alias_gbuf.frag.spvc"
|
||||
static
|
||||
#include "libs/video/renderer/vulkan/shader/passthrough.vert.spvc"
|
||||
static
|
||||
#include "libs/video/renderer/vulkan/shader/pushcolor.frag.spvc"
|
||||
|
@ -83,7 +87,9 @@ static shaderdata_t builtin_shaders[] = {
|
|||
{ "quakebsp.vert", quakebsp_vert, sizeof (quakebsp_vert) },
|
||||
{ "quakebsp.frag", quakebsp_frag, sizeof (quakebsp_frag) },
|
||||
{ "alias.vert", alias_vert, sizeof (alias_vert) },
|
||||
{ "alias_depth.vert", alias_depth_vert, sizeof (alias_depth_vert) },
|
||||
{ "alias.frag", alias_frag, sizeof (alias_frag) },
|
||||
{ "alias_gbuf.frag", alias_gbuf_frag, sizeof (alias_gbuf_frag) },
|
||||
{ "passthrough.vert", passthrough_vert, sizeof (passthrough_vert) },
|
||||
{ "pushcolor.frag", pushcolor_frag, sizeof (pushcolor_frag) },
|
||||
{}
|
||||
|
|
28
libs/video/renderer/vulkan/shader/alias_depth.vert
Normal file
28
libs/video/renderer/vulkan/shader/alias_depth.vert
Normal file
|
@ -0,0 +1,28 @@
|
|||
#version 450
|
||||
|
||||
layout (set = 0, binding = 0) uniform Matrices {
|
||||
mat4 Projection;
|
||||
mat4 View;
|
||||
mat4 Sky;
|
||||
};
|
||||
|
||||
layout (push_constant) uniform PushConstants {
|
||||
mat4 Model;
|
||||
float blend;
|
||||
};
|
||||
|
||||
layout (location = 0) in vec4 vertexa;
|
||||
layout (location = 1) in vec3 normala;
|
||||
layout (location = 2) in vec4 vertexb;
|
||||
layout (location = 3) in vec3 normalb;
|
||||
|
||||
void
|
||||
main (void)
|
||||
{
|
||||
vec4 vertex;
|
||||
vec4 pos;
|
||||
|
||||
vertex = mix (vertexa, vertexb, blend);
|
||||
pos = (Model * vertex);
|
||||
gl_Position = Projection * (View * pos);
|
||||
}
|
32
libs/video/renderer/vulkan/shader/alias_gbuf.frag
Normal file
32
libs/video/renderer/vulkan/shader/alias_gbuf.frag
Normal file
|
@ -0,0 +1,32 @@
|
|||
#version 450
|
||||
layout (set = 0, binding = 2) uniform sampler2DArray Skin;
|
||||
|
||||
layout (push_constant) uniform PushConstants {
|
||||
layout (offset = 68)
|
||||
uint base_color;
|
||||
uint colorA;
|
||||
uint colorB;
|
||||
vec4 fog;
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
layout (location = 0) in vec2 st;
|
||||
layout (location = 1) in vec3 position;
|
||||
layout (location = 2) in vec3 normal;
|
||||
|
||||
layout (location = 0) out vec4 frag_color;
|
||||
layout (location = 1) out vec4 frag_normal;
|
||||
|
||||
void
|
||||
main (void)
|
||||
{
|
||||
vec4 c;
|
||||
int i;
|
||||
vec3 light = vec3 (0);
|
||||
c = texture (Skin, vec3 (st, 0)) * unpackUnorm4x8(base_color);
|
||||
c += texture (Skin, vec3 (st, 1)) * unpackUnorm4x8(colorA);
|
||||
c += texture (Skin, vec3 (st, 2)) * unpackUnorm4x8(colorB);
|
||||
|
||||
frag_color = c;
|
||||
frag_normal = vec4(normal, 0);
|
||||
}
|
Loading…
Reference in a new issue