Skip to content

Commit 808f6b6

Browse files
author
Matthew Shotton
committed
added dreamfade efffect, added Array.from polyfill
1 parent c43d547 commit 808f6b6

9 files changed

+16691
-396
lines changed

dist/videocontext.commonjs2.js

+8,319-195
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/videocontext.commonjs2.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/videocontext.js

+8,319-195
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/videocontext.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"devDependencies": {
1919
"babel-core": "^5.6.5",
2020
"babel-loader": "^5.1.4",
21+
"babel-polyfill": "^6.16.0",
2122
"chai": "3.4.1",
2223
"eslint-loader": "^1.4.0",
2324
"http-server": "^0.8.5",

src/Definitions/definitions.js

+3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ import aaf_video_position from "./aaf_video_position.js";
1616
import aaf_video_crop from "./aaf_video_crop.js";
1717
import staticDissolve from "./staticDissolve.js";
1818
import staticEffect from "./staticEffect.js";
19+
import dreamfade from "./dreamfade.js";
20+
1921

2022
let DEFINITIONS = {
2123
AAF_VIDEO_SCALE: aaf_video_scale,
2224
CROSSFADE: crossfade,
25+
DREAMFADE: dreamfade,
2326
HORIZONTAL_WIPE:horizontalWipe,
2427
VERTICAL_WIPE:verticalWipe,
2528
RANDOM_DISSOLVE:randomDissolve,

src/Definitions/dreamfade.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
let dreamfade = {
2+
"title":"Dream-Fade",
3+
"description": "A wobbly dream effect. Typically used as a transistion.",
4+
"vertexShader" : "\
5+
attribute vec2 a_position;\
6+
attribute vec2 a_texCoord;\
7+
varying vec2 v_texCoord;\
8+
void main() {\
9+
gl_Position = vec4(vec2(2.0,2.0)*a_position-vec2(1.0, 1.0), 0.0, 1.0);\
10+
v_texCoord = a_texCoord;\
11+
}",
12+
"fragmentShader" : "\
13+
precision mediump float;\
14+
uniform sampler2D u_image_a;\
15+
uniform sampler2D u_image_b;\
16+
uniform float mix;\
17+
varying vec2 v_texCoord;\
18+
varying float v_mix;\
19+
void main(){\
20+
float wobble = 1.0 - abs((mix*2.0)-1.0);\
21+
vec2 pos = vec2(v_texCoord[0] + ((sin(v_texCoord[1]*(10.0*wobble*3.14) + wobble*10.0)/13.0)), v_texCoord[1]);\
22+
vec4 color_a = texture2D(u_image_a, pos);\
23+
vec4 color_b = texture2D(u_image_b, pos);\
24+
color_a[0] *= mix;\
25+
color_a[1] *= mix;\
26+
color_a[2] *= mix;\
27+
color_a[3] *= mix;\
28+
color_b[0] *= (1.0 - mix);\
29+
color_b[1] *= (1.0 - mix);\
30+
color_b[2] *= (1.0 - mix);\
31+
color_b[3] *= (1.0 - mix);\
32+
gl_FragColor = color_a + color_b;\
33+
}",
34+
"properties":{
35+
"mix":{"type":"uniform", "value":0.0}
36+
},
37+
"inputs":["u_image_a","u_image_b"]
38+
};
39+
40+
export default dreamfade;

src/Definitions/staticEffect.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,22 @@ let staticEffect = {
1313
precision mediump float;\
1414
uniform sampler2D u_image;\
1515
uniform float currentTime;\
16+
uniform float amount;\
1617
varying vec2 v_texCoord;\
1718
uniform vec3 weight;\
1819
float rand(vec2 co, float currentTime){\
1920
return fract(sin(dot(co.xy,vec2(12.9898,78.233))+currentTime) * 43758.5453);\
2021
}\
2122
void main(){\
2223
vec4 color = texture2D(u_image, v_texCoord);\
23-
color[0] = color[0] + (2.0*(clamp(rand(v_texCoord, currentTime), 0.01, 1.001)-0.5)) * weight[0];\
24-
color[1] = color[1] + (2.0*(clamp(rand(v_texCoord, currentTime), 0.01, 1.001)-0.5)) * weight[1];\
25-
color[2] = color[2] + (2.0*(clamp(rand(v_texCoord, currentTime), 0.01, 1.001)-0.5)) * weight[2];\
24+
color[0] = color[0] + (2.0*(clamp(rand(v_texCoord, currentTime), 0.01, 1.001)-0.5)) * weight[0] * amount;\
25+
color[1] = color[1] + (2.0*(clamp(rand(v_texCoord, currentTime), 0.01, 1.001)-0.5)) * weight[1] * amount;\
26+
color[2] = color[2] + (2.0*(clamp(rand(v_texCoord, currentTime), 0.01, 1.001)-0.5)) * weight[2] *amount;\
2627
gl_FragColor = color;\
2728
}",
2829
"properties":{
29-
"weight":{"type":"uniform", "value":[1.0,1.0,1.0]}
30+
"weight":{"type":"uniform", "value":[1.0,1.0,1.0]},
31+
"amount":{"type":"uniform", "amount":1.0}
3032
},
3133
"inputs":["u_image"]
3234
};

src/videocontext.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//Matthew Shotton, R&D User Experience,© BBC 2015
22

3+
import "babel-polyfill";
34
import VideoNode from "./SourceNodes/videonode.js";
45
import ImageNode from "./SourceNodes/imagenode.js";
56
import CanvasNode from "./SourceNodes/canvasnode.js";

0 commit comments

Comments
 (0)