Skip to content

The Cool Stuff

Lilac edited this page Mar 15, 2022 · 10 revisions

Now that you (hopefully) understand what is happening, we can finally get on to the most exciting part. Unfortunately, this requires a bit of math, but don't worry! It's not too hard.

After undo your changes your file should look a bit like this,

#version 150

in vec3 Position;
in vec4 Color;
in vec2 UV0;
in ivec2 UV2;

uniform sampler2D Sampler2;
uniform mat4 ModelViewMat;
uniform mat4 ProjMat;
uniform float GameTime;

out float vertexDistance;
out vec4 vertexColor;
out vec2 texCoord0;

void main() {
    gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
    
    vertexColor = Color * texelFetch(Sampler2, UV2 / 16, 0);
    texCoord0 = UV0;
}

I also removed some unused variables as they were, well, not going to be used. You might notice a new variable, GameTime, this is explained wonderfull here, but essentially this is

Clone this wiki locally