# Cool shaders with Vulkan

**URL:** https://discourse.gstreamer.org/t/cool-shaders-with-vulkan/3888
**Category:** Showcase and Tips
**Created:** [January 7, 2025, 3:03pm UTC](https://discourse.gstreamer.org/t/cool-shaders-with-vulkan/3888 "2025-01-07T15:03:15Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![YakoYakoYokuYoku](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/yakoyakoyokuyoku/32/1071_2.png) [@YakoYakoYokuYoku](https://discourse.gstreamer.org/u/YakoYakoYokuYoku)
#### Post date: [January 7, 2025, 3:03pm UTC](https://discourse.gstreamer.org/t/cool-shaders-with-vulkan/3888/1 "2025-01-07T15:03:15Z")

</div>

These are different effects that can be achieved with [`vulkanshaderspv`](https://gstreamer.freedesktop.org/documentation/vulkan/vulkanshaderspv.html?gi-language). Just compile a shader with `glslangValidator` or `glslc` and see it for yourself. Ah, for your info, as of now the textures are clamped, so keep that in mind. As of writing [syntax highlighting for GLSL wasn’t enabled yet](https://meta.discourse.org/t/posting-code-or-preformatted-text/188910), quite a bummer but won’t affect anything else whatsoever.

`gst-launch-1.0 videotestsrc num-buffers=300 ! vulkanupload ! vulkancolorconvert ! vulkanshaderspv fragment-location="waved.frag.spv" ! vulkandownload ! videoconvert ! webpenc animated=true preset=picture quality=70 ! queue ! filesink location=waved.webp`

```glsl
#version 450 core

layout(location = 0) in vec2 inTexCoord;

layout(set = 0, binding = 0) uniform ShaderFilter {
  float time;
  float width;
  float height;
};
layout(set = 0, binding = 1) uniform sampler2D inTexture;

layout(location = 0) out vec4 outColor;

void main()
{
  vec2 zoomed = (inTexCoord + vec2 (0.03125 - width / 2.0, 0.03125 - height / 2.0)) * 0.9;
  float r = sqrt (zoomed.x * zoomed.x + zoomed.y * zoomed.y);
  outColor = texture (inTexture, vec2 (r * sin (asin (sin (time)) / 2.0) + width / 2.0, r * cos (acos (cos (time)) / 2.0) + height / 2.0));
}

```

![waved](https://discourse.gstreamer.org/uploads/default/original/2X/3/31de591ee369d964f3e06bfb87f6aefd0f786e59.webp)

---

<div class="post-metadata">

### Author: ![YakoYakoYokuYoku](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/yakoyakoyokuyoku/32/1071_2.png) [@YakoYakoYokuYoku](https://discourse.gstreamer.org/u/YakoYakoYokuYoku)
#### Post date: [January 7, 2025, 3:03pm UTC](https://discourse.gstreamer.org/t/cool-shaders-with-vulkan/3888/2 "2025-01-07T15:03:52Z")

</div>

`gst-launch-1.0 videotestsrc num-buffers=300 ! vulkanupload ! vulkancolorconvert ! vulkanshaderspv fragment-location="tilted.frag.spv" ! vulkandownload ! videoconvert ! webpenc animated=true preset=picture quality=70 ! queue ! filesink location=tilted.webp`

```glsl
#version 450 core

#define PI 3.1415926538

layout(location = 0) in vec2 inTexCoord;

layout(set = 0, binding = 0) uniform ShaderFilter {
  float time;
  float width;
  float height;
};
layout(set = 0, binding = 1) uniform sampler2D inTexture;

layout(location = 0) out vec4 outColor;

void main()
{
  vec2 rxy = abs (vec2 (cos (PI * time / 5.0), sin (PI * time / 5.0)));
  mat2 rot;
  rot[0] = rxy;
  rot[1] = vec2 (-rxy.y, rxy.x);
  outColor = texture (inTexture, (inTexCoord - 0.5) * rot + 0.5);
}

```

![tilted](https://discourse.gstreamer.org/uploads/default/original/2X/2/29b2da6cff5042bc67dbd416c265075b3071bb92.webp)
