16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-09-01 15:09:18 +02:00

opengl 3.3 renderer shaders

This commit is contained in:
tmj-fstate
2020-02-21 22:50:52 +01:00
parent 7ba6383c75
commit 6b1ab6c125
47 changed files with 1620 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
in vec2 f_coords;
layout(location = 0) out vec4 out_color;
#texture (color_tex, 0, RGB)
uniform sampler2D color_tex;
#texture (velocity_tex, 1, RG)
uniform sampler2D velocity_tex;
#include <common>
void main()
{
vec2 texelSize = 1.0 / vec2(textureSize(color_tex, 0));
vec2 velocity = texture(velocity_tex, f_coords).rg * param[0].r;
float speed = length(velocity / texelSize);
int nSamples = clamp(int(speed), 1, 64);
vec4 oResult = texture(color_tex, f_coords);
for (int i = 1; i < nSamples; ++i)
{
vec2 offset = velocity * (float(i) / float(nSamples - 1) - 0.5);
oResult += texture(color_tex, f_coords + offset);
}
oResult /= float(nSamples);
out_color = oResult;
}