git-svn-id: svn://db.shs.com.ru/libs@586 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
24
test/qglview/shaders/motion_blur.frag
Normal file
24
test/qglview/shaders/motion_blur.frag
Normal file
@@ -0,0 +1,24 @@
|
||||
#version 150
|
||||
|
||||
uniform sampler2D t0, ts;
|
||||
uniform vec2 dt;
|
||||
uniform float factor = 1.;
|
||||
uniform int steps = 8;
|
||||
|
||||
void main(void) {
|
||||
vec2 cdt = dt / steps;
|
||||
vec2 ct = qgl_FragTexture.xy;
|
||||
vec3 speed = texelFetch(ts, ivec2(gl_FragCoord.xy), 0).rgb * 256 * factor;
|
||||
int hsteps = steps / 2;
|
||||
ct -= speed.xy * cdt * hsteps;
|
||||
vec3 scol = vec3(0);//texture(t0, ct).rgb;
|
||||
float sum = 0.;
|
||||
for (int i = 0; i < steps; ++i) {
|
||||
ct += speed.xy * cdt;
|
||||
float mul = 1. - abs(i - hsteps) * 2. / steps;
|
||||
scol += texture(t0, ct).rgb * mul;
|
||||
sum += mul;
|
||||
}
|
||||
scol /= sum;
|
||||
qgl_FragData[0].rgb = scol;
|
||||
}
|
||||
Reference in New Issue
Block a user