2 * Copyright (c) 2003-2006 jMonkeyEngine
\r
3 * All rights reserved.
\r
5 * Redistribution and use in source and binary forms, with or without
\r
6 * modification, are permitted provided that the following conditions are
\r
9 * * Redistributions of source code must retain the above copyright
\r
10 * notice, this list of conditions and the following disclaimer.
\r
12 * * Redistributions in binary form must reproduce the above copyright
\r
13 * notice, this list of conditions and the following disclaimer in the
\r
14 * documentation and/or other materials provided with the distribution.
\r
16 * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
\r
17 * may be used to endorse or promote products derived from this software
\r
18 * without specific prior written permission.
\r
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
\r
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
\r
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
\r
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
\r
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
\r
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
\r
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
\r
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
\r
28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
\r
29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
\r
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
33 uniform sampler2D screenTexture;
\r
35 varying vec4 viewCoords;
\r
36 varying vec2 velocity;
\r
40 // sample scene texture along direction of motion
\r
41 const float samples = 16.0;
\r
42 const float w = 1.0 / samples; // sample weight
\r
44 vec2 projCoord = viewCoords.xy / viewCoords.q;
\r
45 projCoord = (projCoord + vec2(1.0)) * vec2(0.5);
\r
47 vec4 a = vec4(0.0); // accumulator - fixed4
\r
49 for(i=0; i<int(samples); i+=1) {
\r
50 float t = float(i) / (samples-1.0);
\r
51 a = a + texture2D(screenTexture, projCoord + velocity * vec2(t) ) * vec4(w);
\r