Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2014-10-13 #73

Merged
merged 51 commits into from
Oct 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
99bedc5
Fix index page for Internet Explorer
brianchirls Jul 29, 2014
ec5c111
Work-around for lack of video texture support in Internet Explorer #68
brianchirls Jul 29, 2014
f3f93b6
Optimize enum validator
brianchirls Jul 31, 2014
5877ca8
Re-factor input set-up and validation in preparation for #40
brianchirls Jul 31, 2014
fe969d6
Better/more unit tests for blocking reserved names
brianchirls Jul 31, 2014
448e374
Transform `.inputs()` no longer reports methods
brianchirls Jul 31, 2014
76f1103
Fix mirror image example link; use robot instead
brianchirls Jul 31, 2014
451ed9b
Fix case-insensitive enum validation
brianchirls Jul 31, 2014
3c104a8
Validate Transform Node inputs #40, with unit tests
brianchirls Jul 31, 2014
ed33adf
Bug Fix: Secondary WebGL target was failing to render
brianchirls Aug 1, 2014
407d08f
Clean junk out of chroma key shader
brianchirls Aug 3, 2014
57d40e2
Retain `id` property on destroyed nodes
brianchirls Aug 4, 2014
de7fc6a
Bug Fix: target `.input` is now a method, not a property.
brianchirls Aug 4, 2014
6de7ccb
Bug fix: One unit test was not cleaning up after itself
brianchirls Aug 4, 2014
08641a7
Added utility methods to Seriously for detecting whether an object is…
brianchirls Aug 4, 2014
613b81c
Bug fix: Blur was not rendering when amount <= 0.1
brianchirls Aug 5, 2014
d17df66
Bug Fix: Secondary WebGL targets were rendering at wrong size/aspect …
brianchirls Aug 6, 2014
c737217
Fixed texture shape/size in mirror effect
brianchirls Aug 7, 2014
36be46b
Fixed undeclared variable in index.html
brianchirls Aug 7, 2014
eb27f55
Remove branching from split shader #69
brianchirls Aug 8, 2014
2d1b428
Make Linear Transfer example work in IE11 ('input' event not supported)
brianchirls Aug 8, 2014
ac87477
More robust handling of lost WebGL test context
brianchirls Aug 11, 2014
766cdbd
Added unit test for Chroma Key effect
brianchirls Aug 11, 2014
e775126
Remove redundant memory copy in Array source
brianchirls Aug 11, 2014
7ded096
Remove junk comments from TV Glitch shader
brianchirls Aug 11, 2014
95fef92
Removed unnecessary code in EffectNode constructor
brianchirls Aug 12, 2014
f00994c
Improvements to emboss effect
brianchirls Aug 12, 2014
d0531d4
Remove unnecessary resize code from Expression effect
brianchirls Aug 12, 2014
6259ec2
Fix broken hex values for color input elements
brianchirls Aug 12, 2014
332fce4
Added Crop effect with example
brianchirls Aug 15, 2014
71b681b
Change enum input setup and validation
brianchirls Aug 19, 2014
bed62bd
Make sure asynchronous unit tests don't leak plugins
brianchirls Aug 19, 2014
716f9b1
Bug fix: Sizing wasn't working for Layers effect when sizeMode set to…
brianchirls Aug 19, 2014
bb62707
Refactor Chroma Key effect to remove branching #69
brianchirls Aug 20, 2014
c74e77e
Default input values work for transform nodes (#59)
brianchirls Aug 20, 2014
80470ed
Don't use magic number for WebGL error code (#68)
brianchirls Aug 20, 2014
0578a57
Remove unnecessary variable initialization
brianchirls Aug 21, 2014
d9a5c39
Log a warning when creating a target node with a target that's alread…
brianchirls Aug 21, 2014
85ec912
Don't make functions in a loop
brianchirls Aug 21, 2014
21315dc
Bug fix: OpenGL blendFuncSeparate didn't support ZERO
brianchirls Aug 22, 2014
932b61b
Added Pixelate effect
brianchirls Aug 26, 2014
a933d75
Added unit tests for video source
brianchirls Sep 9, 2014
5bbd8be
Merge branch 'video-texture-workaround' into develop #68
brianchirls Sep 9, 2014
3bc49f9
Refactor video rendering
brianchirls Sep 11, 2014
f0a9892
Updated three.js to v68
brianchirls Oct 8, 2014
1948d15
Implemented pluggable target node types #60
brianchirls Oct 12, 2014
b1e5ca0
Target plugin for Three.js texture #61
brianchirls Oct 12, 2014
bd5dbf2
Clean up Three.js Target example code #61
brianchirls Oct 12, 2014
e98dea0
Remove some junk from Three.js Target example code #61
brianchirls Oct 12, 2014
e368754
Removed unused variable from threejs-target example
brianchirls Oct 13, 2014
899c181
Fix lost context unit test in IE11
brianchirls Oct 13, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Full documentation is in progress at the [wiki](https://github.com/brianchirls/S
- Color Generator
- [Color Cube](http://www.youtube.com/watch?v=rfQ8rKGTVlg&t=24m30s)
- Color Select
- Crop
- [Daltonize](http://www.daltonize.org/p/about.html)
- Directional Blur
- Displacement Map
Expand All @@ -59,6 +60,7 @@ Full documentation is in progress at the [wiki](https://github.com/brianchirls/S
- Mirror
- Night Vision
- Panorama
- Pixelate
- Polar Coordinates
- Ripple
- Scanlines
Expand Down
1 change: 1 addition & 0 deletions effects/seriously.blend.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
nativeBlendModes = {
normal: ['FUNC_ADD', 'SRC_ALPHA', 'ONE_MINUS_SRC_ALPHA', 'SRC_ALPHA', 'DST_ALPHA']/*,
add: ['FUNC_ADD', 'SRC_ALPHA', 'ONE_MINUS_SRC_ALPHA', 'SRC_ALPHA', 'DST_ALPHA']*/
//todo: multiply, screen
},
identity = new Float32Array([
1, 0, 0, 0,
Expand Down
22 changes: 6 additions & 16 deletions effects/seriously.blur.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,7 @@ http://v002.info/plugins/v002-blurs/
inputScale: 1,
resolution: [this.width, this.height],
transform: identity,
direction: null,
projection: new Float32Array([
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
])
direction: null
};

return {
Expand Down Expand Up @@ -90,16 +84,16 @@ http://v002.info/plugins/v002-blurs/
'attribute vec2 texCoord;',

'uniform vec2 resolution;',
'uniform mat4 projection;',
'uniform mat4 transform;',

'varying vec2 vTexCoord;',

'uniform vec2 direction;',
'uniform float amount;',
'uniform float inputScale;',

'const vec2 zero = vec2(0.0, 0.0);',

'varying vec2 vTexCoord;',

'#ifdef USE_VARYINGS',
'vec2 one;',
'vec2 amount1;',
Expand Down Expand Up @@ -131,7 +125,7 @@ http://v002.info/plugins/v002-blurs/
' if (inputScale < 1.0) {',
' one -= 1.0 / resolution;',
' }',
//' one *= inputScale;',

' vTexCoord = max(zero, min(one, texCoord.st * inputScale));',
' amount1 = direction * (inputScale * amount * 5.0 / resolution);',

Expand Down Expand Up @@ -162,9 +156,6 @@ http://v002.info/plugins/v002-blurs/
'varying vec2 vTexCoord;',

'uniform sampler2D source;',
'uniform float angle;',
'uniform float amount;',
'uniform float inputScale;',

'#ifdef USE_VARYINGS',
'varying vec2 vTexCoord1;',
Expand Down Expand Up @@ -235,14 +226,13 @@ http://v002.info/plugins/v002-blurs/

//vertical pass
uniforms.direction = vertical;
uniforms.source = fbVertical.texture;
uniforms.source = fbHorizontal.texture;
parent(shader, model, uniforms, frameBuffer);
return;
}

loopUniforms.amount = amount;
loopUniforms.source = this.inputs.source.texture;
loopUniforms.projection[0] = this.height / this.width;

for (i = 0; i < passes.length; i++) {
pass = Math.min(1, passes[i] / amount);
Expand Down
86 changes: 41 additions & 45 deletions effects/seriously.chroma.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@
}(this, function (Seriously) {
'use strict';

/* experimental chroma key algorithm
todo: see if we can minimize branching
todo: calculate HSL of screen color outside shader
/*
experimental chroma key algorithm
todo: try allowing some color despill on opaque pixels
todo: add different modes?
todo: rename parameters
*/

Seriously.plugin('chroma', {
commonShader: true,
shader: function (inputs, shaderSource) {
shaderSource.vertex = [
'precision mediump float;',
Expand All @@ -44,12 +42,10 @@
'varying vec3 screenPrimary;',

'void main(void) {',
' float fmin = min(min(screen.r, screen.g), screen.b); //Min. value of RGB',
' float fmax = max(max(screen.r, screen.g), screen.b); //Max. value of RGB',
' float fmin = min(min(screen.r, screen.g), screen.b);', //Min. value of RGB
' float fmax = max(max(screen.r, screen.g), screen.b);', //Max. value of RGB
' float secondaryComponents;',

//' luminance = (fmax + fmin) / 2.0; // Luminance',
//' screenSat = fmax - fmin; // Saturation',
' screenPrimary = step(fmax, screen.rgb);',
' secondaryComponents = dot(1.0 - screenPrimary, screen.rgb);',
' screenSat = fmax - mix(secondaryComponents - fmin, secondaryComponents / 2.0, balance);',
Expand All @@ -66,6 +62,7 @@
'}'
].join('\n');
shaderSource.fragment = [
this.inputs.mask ? '#define MASK' : '',
'precision mediump float;',

'varying vec2 vTexCoord;',
Expand All @@ -81,52 +78,51 @@
'varying float screenSat;',
'varying vec3 screenPrimary;',

'vec4 sourcePixel;',
'void main(void) {',
' float pixelSat, secondaryComponents;',
' vec4 sourcePixel = texture2D(source, vTexCoord);',

'const mat3 yuv = mat3(',
' 54.213, 182.376, 18.411,',
' -54.213, -182.376, 236.589,',
' 200.787, -182.376, -18.411',
');',
' float fmin = min(min(sourcePixel.r, sourcePixel.g), sourcePixel.b);', //Min. value of RGB
' float fmax = max(max(sourcePixel.r, sourcePixel.g), sourcePixel.b);', //Max. value of RGB
// luminance = fmax

'float round(float n) {',
' return floor(n) + step(0.5, fract(n));',
'}',
' vec3 pixelPrimary = step(fmax, sourcePixel.rgb);',

'void main(void) {',
' float pixelSat, luminance, secondaryComponents;',
' vec3 pixelPrimary;',
' vec4 pixel = vec4(0.0);',
' sourcePixel = texture2D(source, vTexCoord);',

' float fmin = min(min(sourcePixel.r, sourcePixel.g), sourcePixel.b); //Min. value of RGB',
' float fmax = max(max(sourcePixel.r, sourcePixel.g), sourcePixel.b); //Max. value of RGB',
//' float delta = fmax - fmin; //Delta RGB value',

//' luminance = (fmax + fmin) / 2.0; // Luminance',
//' luminance = dot(vec3(0.3, 0.59, 0.11), sourcePixel.rgb); // Luminance',
' luminance = fmax; // Luminance',
' pixelPrimary = step(fmax, sourcePixel.rgb);',
//' pixelSat = delta; // Saturation',
' secondaryComponents = dot(1.0 - pixelPrimary, sourcePixel.rgb);',
' pixelSat = fmax - mix(secondaryComponents - fmin, secondaryComponents / 2.0, balance);', // Saturation
' if (pixelSat < 0.1 || luminance < 0.1 || any(notEqual(pixelPrimary, screenPrimary))) {',

// solid pixel if primary color component is not the same as the screen color
' float diffPrimary = dot(abs(pixelPrimary - screenPrimary), vec3(1.0));',
' float solid = step(1.0, step(pixelSat, 0.1) + step(fmax, 0.1) + diffPrimary);',

/*
Semi-transparent pixel if the primary component matches but if saturation is less
than that of screen color. Otherwise totally transparent
*/
' float alpha = max(0.0, 1.0 - pixelSat / screenSat);',
' alpha = smoothstep(clipBlack, clipWhite, alpha);',
' vec4 semiTransparentPixel = vec4((sourcePixel.rgb - (1.0 - alpha) * screen.rgb * screenWeight) / alpha, alpha);',

' vec4 pixel = mix(semiTransparentPixel, sourcePixel, solid);',

/*
Old branching code
' if (pixelSat < 0.1 || fmax < 0.1 || any(notEqual(pixelPrimary, screenPrimary))) {',
' pixel = sourcePixel;',
//' pixel = vec4(1.0);',

' } else if (pixelSat < screenSat) {',
' float alpha = 1.0 - pixelSat / screenSat;',
' float alpha = max(0.0, 1.0 - pixelSat / screenSat);',
' alpha = smoothstep(clipBlack, clipWhite, alpha);',
//' float despill = alpha / screenWeight;',
' pixel = vec4((sourcePixel.rgb - (1.0 - alpha) * screen.rgb * screenWeight) / alpha, alpha);',
//' pixel = vec4(vec3(alpha), 1.0);',
' }',
//*/

' if (mask) {',
' gl_FragColor = vec4(vec3(pixel.a), 1.0);',
' } else {',
' gl_FragColor = pixel;',
' }',

'#ifdef MASK',
' gl_FragColor = vec4(vec3(pixel.a), 1.0);',
'#else',
' gl_FragColor = pixel;',
'#endif',
'}'
].join('\n');
return shaderSource;
Expand Down Expand Up @@ -172,9 +168,9 @@
mask: {
type: 'boolean',
defaultValue: false,
uniform: 'mask'
uniform: 'mask',
shaderDirty: true
}

},
title: 'Chroma Key',
description: ''
Expand Down
158 changes: 158 additions & 0 deletions effects/seriously.crop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/* global define, require */
(function (root, factory) {
'use strict';

if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['seriously'], factory);
} else if (typeof exports === 'object') {
// Node/CommonJS
factory(require('seriously'));
} else {
if (!root.Seriously) {
root.Seriously = { plugin: function (name, opt) { this[name] = opt; } };
}
factory(root.Seriously);
}
}(this, function (Seriously) {
'use strict';

Seriously.plugin('crop', function () {
var me = this;

// custom resize method
function resize() {
var width = 1,
height = 1,
source = me.inputs.source,
target,
i;

if (me.source) {
width = me.source.width;
height = me.source.height;
} else if (me.sources && me.sources.source) {
width = me.sources.source.width;
height = me.sources.source.height;
}

width = width - me.inputs.left - me.inputs.right;
height = height - me.inputs.top - me.inputs.bottom;

width = Math.max(1, Math.floor(width));
height = Math.max(1, Math.floor(height));


if (me.width !== width || me.height !== height) {
me.width = width;
me.height = height;

me.uniforms.resolution[0] = width;
me.uniforms.resolution[1] = height;

if (me.frameBuffer) {
me.frameBuffer.resize(me.width, me.height);
}

me.emit('resize');
me.setDirty();
}

for (i = 0; i < me.targets.length; i++) {
target = me.targets[i];
target.resize();
if (target.setTransformDirty) {
target.setTransformDirty();
}
}
}

me.resize = resize;

return {
commonShader: true,
shader: function (inputs, shaderSource) {
shaderSource.vertex = [
'precision mediump float;',

'attribute vec4 position;',
'attribute vec2 texCoord;',

'uniform vec2 resolution;',
'uniform mat4 transform;',

'uniform float top;',
'uniform float left;',
'uniform float bottom;',
'uniform float right;',

'varying vec2 vTexCoord;',

'const vec2 ZERO = vec2(0.0);',
'const vec2 ONE = vec2(1.0);',

'void main(void) {',
// first convert to screen space
' vec4 screenPosition = vec4(position.xy * resolution / 2.0, position.z, position.w);',
' screenPosition = transform * screenPosition;',

// convert back to OpenGL coords
' gl_Position.xy = screenPosition.xy * 2.0 / resolution;',
' gl_Position.z = screenPosition.z * 2.0 / (resolution.x / resolution.y);',
' gl_Position.w = screenPosition.w;',

' vec2 dim = resolution + vec2(right + left, bottom + top);',
' vec2 scale = dim / resolution;',
' vec2 offset = vec2(left, bottom) / resolution;',

' vTexCoord = max(ZERO, (texCoord + offset) / scale);',
'}\n'
].join('\n');
return shaderSource;
},
inputs: {
source: {
type: 'image',
uniform: 'source',
update: resize
},
top: {
type: 'number',
uniform: 'top',
min: 0,
step: 1,
update: resize,
defaultValue: 0
},
left: {
type: 'number',
uniform: 'left',
min: 0,
step: 1,
update: resize,
defaultValue: 0
},
bottom: {
type: 'number',
uniform: 'bottom',
min: 0,
step: 1,
update: resize,
defaultValue: 0
},
right: {
type: 'number',
uniform: 'right',
min: 0,
step: 1,
update: resize,
defaultValue: 0
}
}
};
},
{
inPlace: true,
title: 'Crop'
});
}));
Loading