vulkan: update example shaders

This commit is contained in:
Wim Taymans 2022-06-01 12:19:40 +02:00
parent 80f317344e
commit 9493dafe44
4 changed files with 83 additions and 0 deletions

View file

@ -0,0 +1,39 @@
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 p = fragCoord.xy/iResolution.xy;
vec4 col = texture(iChannel0, p);
//Desaturate
if(p.x<.25)
{
col = vec4( (col.r+col.g+col.b)/3. );
}
//Invert
else if (p.x<.5)
{
col = vec4(1.) - texture(iChannel0, p);
}
//Chromatic aberration
else if (p.x<.75)
{
vec2 offset = vec2(.01,.0);
col.r = texture(iChannel0, p+offset.xy).r;
col.g = texture(iChannel0, p ).g;
col.b = texture(iChannel0, p+offset.yx).b;
}
//Color switching
else
{
col.rgb = texture(iChannel0, p).brg;
}
//Line
if( mod(abs(p.x+.5/iResolution.y),.25)<0.5/iResolution.y )
col = vec4(1.);
fragColor = col;
}

View file

@ -0,0 +1,44 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
#define WORKGROUP_SIZE 32
layout (local_size_x = WORKGROUP_SIZE, local_size_y = WORKGROUP_SIZE, local_size_z = 1 ) in;
layout(rgba32f, set = 0, binding = 0) uniform image2D resultImage;
layout(set = 0, binding = 1) uniform sampler2D iChannel0;
layout( push_constant ) uniform Constants {
float time;
int frame;
int width;
int height;
} PushConstant;
float iTime;
int iFrame;
vec3 iResolution;
vec4 iMouse;
void mainImage( out vec4 fragColor, in vec2 fragCoord );
void main()
{
iTime = PushConstant.time;
iFrame = PushConstant.frame;
iResolution = vec3(float(PushConstant.width), float(PushConstant.height), 0.0);
iMouse = vec4(0.0, 0.0, 0.0, 0.0);
vec2 coord = vec2(float(gl_GlobalInvocationID.x),
iResolution.y - float(gl_GlobalInvocationID.y));
vec4 outColor;
if(coord.x >= iResolution.x || coord.y >= iResolution.y)
return;
mainImage(outColor, coord);
imageStore(resultImage, ivec2(gl_GlobalInvocationID.xy), outColor);
}
//#include "smearcam.comp"
#include "filter-color.comp"
//#include "filter-ripple.comp"

Binary file not shown.

Binary file not shown.