Creating your own Shaders

WayVes reads Shaders that follow the below hierarchy:


    Shader Name
    |   vertex
    |       | 1.vert
    |       | 2.vert
    |       .
    |       .
    |       .
    |   fragment
    |       | 1.frag
    |       | 2.frag
    |       .
    |       .
    |       .
                                                 

The pair of Vertex and Fragment Shaders get compiled and executed in the order in which they are numbered.

By using Shaders in this way, you can utilise the output of the 'previous' pass and consume it for some Post-Processing Effects


Uniforms WayVes provides several uniforms that can be consumed in a Shader.
PropertyDescription
uniform float timeValue of the current frame. When targeting 60 fps, the last frame within the first second should be 60. Supplied as a float for bypassing unnecessary type-casts
uniform vec2 resolutionThe Resolution of the View, where the resolution.x is windowWidth, and resolution.y is windowHeight
uniform sampler1D audioL1D Texture containing Audio data for the Left-mapped Audio Channel
uniform sampler1D audioR1D Texture containing Audio data for the Right-mapped Audio Channel
uniform int audioLSizeSize of the Left-mapped Audio Channel
uniform int audioRSizeSize of the Right-mapped Audio Channel
layout(binding = [0...atomicN], r32ui) uniform uimage2D atomicImageTexture[0...atomicN]2D unsigned integer Texture that is used for Atomic Image Load / Store operations. Specify the layout binding in increasing numbers starting from 0, and increase the value of N by 1 for each Atomic Texture you require
layout(binding = atomicN + [0...imageN], rgba32f) uniform restrict image2D imageTexture[0...imageN]2D 32-bit floating Texture that is used for arbitrary Image Load / Store operations. Specify the layout binding in increasing numbers starting from the number after the last Atomic Texture Binding Number used, and increase the value of N by 1 for each Image Texture you require
uniform sampler2D tex2D Texture that contains the output of the previous Fragment Shader pass. Available only for Shader Stages 2 and onwards

Minimal Fragment Shader Example; all Uniforms

#define version 430

in vec4 gl_FragCoord;

uniform float time;
uniform vec2 resolution;

uniform sampler2D tex; // Not available in 1.frag

uniform sampler1D audioL;
uniform int audioLSize;

uniform sampler1D audioR;
uniform int audioRSize;

layout(r32ui, binding = 0) uniform uimage2D atomicImageTexture0;

layout(binding = 1, rgba32f) uniform image2D imageTexture0;
layout(binding = 2, rgba32f) uniform image2D imageTexture1;

out vec4 FragColor;

void main()
{
}