Skip to content

Commit

Permalink
Merge pull request #58 from brianchirls/develop
Browse files Browse the repository at this point in the history
Release 2014-05-06
  • Loading branch information
brianchirls committed May 6, 2014
2 parents 3b39bc0 + b866879 commit 3b8394b
Show file tree
Hide file tree
Showing 73 changed files with 4,003 additions and 311 deletions.
34 changes: 34 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Contributing to Seriously.js #

Contributions are welcome, whether new core features, effects, bug fixes or examples. Please follow these guidelines.

## Workflow ##
* All contributions should be based off the latest `develop` branch, and pull requests must be submitted to `develop`. Any pull requests to `master` will be rejected.
* Create a separate branch for each patch or feature
* Any modifications to the core script must pass unit tests. Whenever possible, especially for new features, please add a test.
* New features or effects should have an example.
* Any copied assets (e.g. images, shaders or code) should have the appropriate license and credit allowing for their use in this repository.
* When refactoring existing code, make sure all relevant examples still work or are updated to work.
* If a patch is relevant to a [GitHub issue](https://github.com/brianchirls/Seriously.js/issues?state=open), please reference the issue number with a hash in the commit message.
* All Javascript code should follow the style guide below

## Code Style ##
* Indent with tabs, not spaces
* No trailing spaces
* Single quotes for strings
* Spaces around binary operators (e.g. `a + b`, not `a+b`), but not unary ones
* `if`, `while`, `try`, etc. must all have braces and span multiple lines.
* All local variables should be declared in one `var` statement at the top of each function
* functions should be declared after `var` but before any other statements.
* Lots of comments please, but put them on the line before the code, not at the end of the line.
* When in doubt, refer to existing code.

## Best Practices ##
* Prioritize speed for code that runs in render loops, but prioritize readability, simplicity and usability for everything else.
* Publicly accessible methods should be simple to use and forgiving of mistakes whenever possible. Assume they're being used by inexperienced programmers.
* Observe [WebGL best practices](https://developer.mozilla.org/en-US/docs/Web/WebGL/WebGL_best_practices)
* Private or protected code may assume more advanced users, to prioritize speed and power.
* Minimize impact on the global environment. No unnecessary global variables, and shim when necessary but don't polyfill.
* All plugins must support either AMD or global declarations (see [UMD](https://github.com/umdjs/umd/blob/master/returnExportsGlobal.js)). Examples may use AMD, but it's not required.
* Check all Javascript code with jshint or jslint, but use your brain. The following options are recommended:
` devel: true, bitwise: true, browser: true, white: true, nomen: true, plusplus: true, maxerr: 50, indent: 4, todo: true`
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Full documentation is in progress at the [wiki](https://github.com/brianchirls/S
- [Color Cube](http://www.youtube.com/watch?v=rfQ8rKGTVlg&t=24m30s)
- [Daltonize](http://www.daltonize.org/p/about.html)
- Directional Blur
- Displacement Map
- Dither
- Edge Detect
- Emboss
Expand All @@ -54,6 +55,7 @@ Full documentation is in progress at the [wiki](https://github.com/brianchirls/S
- Linear Transfer
- Luma Key
- Night Vision
- Panorama
- Polar Coordinates
- Ripple
- Scanlines
Expand All @@ -64,6 +66,7 @@ Full documentation is in progress at the [wiki](https://github.com/brianchirls/S
- Throttle Frame Rate
- Tone Adjust
- TV Glitch
- Vibrance
- Vignette
- White Balance

Expand Down
144 changes: 139 additions & 5 deletions effects/seriously.accumulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
multiply: '(base * blend)',
average: '(base + blend / TWO)',
add: 'min(base + blend, ONE)',
subtract: 'max(base + blend - ONE, ZERO)',
subtract: 'max(base - blend, ZERO)',
divide: 'base / blend',
difference: 'abs(base - blend)',
negation: '(ONE - abs(ONE - base - blend))',
exclusion: '(base + blend - TWO * base * blend)',
Expand All @@ -56,6 +57,13 @@
phoenix: '(min(base, blend) - max(base, blend) + ONE)',
linearburn: 'max(base + blend - ONE, ZERO)', //same as subtract?

hue: 'BlendHue(base, blend)',
saturation: 'BlendSaturation(base, blend)',
color: 'BlendColor(base, blend)',
luminosity: 'BlendLuminosity(base, blend)',
darkercolor: 'BlendDarkerColor(base, blend)',
lightercolor: 'BlendLighterColor(base, blend)',

overlay: vectorBlendFormula('base < 0.5 ? (2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend))'),
softlight: vectorBlendFormula('blend < 0.5 ? (2.0 * base * blend + base * base * (1.0 - 2.0 * blend)) : (sqrt(base) * (2.0 * blend - 1.0) + 2.0 * base * (1.0 - blend))'),
hardlight: vectorBlendFormula('base < 0.5 ? (2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend))', 'blend', 'base'),
Expand Down Expand Up @@ -107,9 +115,8 @@
'const vec3 TWO = vec3(2.0);',

'#define BlendAddf(base, blend) min(base + blend, 1.0)',
'#define BlendSubtractf(base, blend) max(base + blend - 1.0, 0.0)',
'#define BlendLinearDodgef(base, blend) BlendAddf(base, blend)',
'#define BlendLinearBurnf(base, blend) BlendSubtractf(base, blend)',
'#define BlendLinearBurnf(base, blend) max(base + blend - 1.0, 0.0)',
'#define BlendLightenf(base, blend) max(blend, base)',
'#define BlendDarkenf(base, blend) min(blend, base)',
'#define BlendLinearLightf(base, blend) (blend < 0.5 ? BlendLinearBurnf(base, (2.0 * blend)) : BlendLinearDodgef(base, (2.0 * (blend - 0.5))))',
Expand All @@ -130,6 +137,126 @@
the result is a brighter image due to increased brightness.
*/

/*
RGB/HSL conversion functions needed for Color, Saturation, Hue, Luminosity, etc.
*/

'vec3 RGBToHSL(vec3 color) {',
' vec3 hsl;', // init to 0 to avoid warnings ? (and reverse if + remove first part)

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

' hsl.z = (fmax + fmin) / 2.0;', // Luminance

' if (delta == 0.0) {', //This is a gray, no chroma...
' hsl.x = 0.0;', // Hue
' hsl.y = 0.0;', // Saturation
' } else {', //Chromatic data...
' if (hsl.z < 0.5)',
' hsl.y = delta / (fmax + fmin);', // Saturation
' else',
' hsl.y = delta / (2.0 - fmax - fmin);', // Saturation

' float deltaR = (((fmax - color.r) / 6.0) + (delta / 2.0)) / delta;',
' float deltaG = (((fmax - color.g) / 6.0) + (delta / 2.0)) / delta;',
' float deltaB = (((fmax - color.b) / 6.0) + (delta / 2.0)) / delta;',

' if (color.r == fmax )',
' hsl.x = deltaB - deltaG;', // Hue
' else if (color.g == fmax)',
' hsl.x = (1.0 / 3.0) + deltaR - deltaB;', // Hue
' else if (color.b == fmax)',
' hsl.x = (2.0 / 3.0) + deltaG - deltaR;', // Hue

' if (hsl.x < 0.0)',
' hsl.x += 1.0;', // Hue
' else if (hsl.x > 1.0)',
' hsl.x -= 1.0;', // Hue
' }',

' return hsl;',
'}',

'float HueToRGB(float f1, float f2, float hue) {',
' if (hue < 0.0)',
' hue += 1.0;',
' else if (hue > 1.0)',
' hue -= 1.0;',
' float res;',
' if ((6.0 * hue) < 1.0)',
' res = f1 + (f2 - f1) * 6.0 * hue;',
' else if ((2.0 * hue) < 1.0)',
' res = f2;',
' else if ((3.0 * hue) < 2.0)',
' res = f1 + (f2 - f1) * ((2.0 / 3.0) - hue) * 6.0;',
' else',
' res = f1;',
' return res;',
'}',

'vec3 HSLToRGB(vec3 hsl) {',
' vec3 rgb;',

' if (hsl.y == 0.0)',
' rgb = vec3(hsl.z);', // Luminance
' else {',
' float f2;',

' if (hsl.z < 0.5)',
' f2 = hsl.z * (1.0 + hsl.y);',
' else',
' f2 = (hsl.z + hsl.y) - (hsl.y * hsl.z);',

' float f1 = 2.0 * hsl.z - f2;',

' rgb.r = HueToRGB(f1, f2, hsl.x + (1.0/3.0));',
' rgb.g = HueToRGB(f1, f2, hsl.x);',
' rgb.b= HueToRGB(f1, f2, hsl.x - (1.0/3.0));',
' }',

' return rgb;',
'}',

// Hue Blend mode creates the result color by combining the luminance and saturation of the base color with the hue of the blend color.
'vec3 BlendHue(vec3 base, vec3 blend) {',
' vec3 baseHSL = RGBToHSL(base);',
' return HSLToRGB(vec3(RGBToHSL(blend).r, baseHSL.g, baseHSL.b));',
'}',

// Saturation Blend mode creates the result color by combining the luminance and hue of the base color with the saturation of the blend color.
'vec3 BlendSaturation(vec3 base, vec3 blend) {',
' vec3 baseHSL = RGBToHSL(base);',
' return HSLToRGB(vec3(baseHSL.r, RGBToHSL(blend).g, baseHSL.b));',
'}',

// Color Mode keeps the brightness of the base color and applies both the hue and saturation of the blend color.
'vec3 BlendColor(vec3 base, vec3 blend) {',
' vec3 blendHSL = RGBToHSL(blend);',
' return HSLToRGB(vec3(blendHSL.r, blendHSL.g, RGBToHSL(base).b));',
'}',

// Luminosity Blend mode creates the result color by combining the hue and saturation of the base color with the luminance of the blend color.
'vec3 BlendLuminosity(vec3 base, vec3 blend) {',
' vec3 baseHSL = RGBToHSL(base);',
' return HSLToRGB(vec3(baseHSL.r, baseHSL.g, RGBToHSL(blend).b));',
'}',

// Compares the total of all channel values for the blend and base color and displays the higher value color.
'vec3 BlendLighterColor(vec3 base, vec3 blend) {',
' float baseTotal = base.r + base.g + base.b;',
' float blendTotal = blend.r + blend.g + blend.b;',
' return blendTotal > baseTotal ? blend : base;',
'}',

// Compares the total of all channel values for the blend and base color and displays the lower value color.
'vec3 BlendDarkerColor(vec3 base, vec3 blend) {',
' float baseTotal = base.r + base.g + base.b;',
' float blendTotal = blend.r + blend.g + blend.b;',
' return blendTotal < baseTotal ? blend : base;',
'}',

'#define BlendFunction(base, blend) ' + blendModes[mode],
(mixAlpha[mode] ? '#define MIX_ALPHA' : ''),

Expand Down Expand Up @@ -229,7 +356,8 @@
['multiply', 'Multiply'],
['average', 'Average'],
['add', 'Add'],
['substract', 'Substract'],
['subtract', 'Subtract'],
['divide', 'Divide'],
['difference', 'Difference'],
['negation', 'Negation'],
['exclusion', 'Exclusion'],
Expand All @@ -247,7 +375,13 @@
['hardmix', 'Hard Mix'],
['reflect', 'Reflect'],
['glow', 'Glow'],
['phoenix', 'Phoenix']
['phoenix', 'Phoenix'],
['hue', 'Hue'],
['saturation', 'Saturation'],
['color', 'color'],
['luminosity', 'Luminosity'],
['darkercolor', 'Darker Color'],
['lightercolor', 'Lighter Color']
]
}
}
Expand Down
1 change: 0 additions & 1 deletion effects/seriously.ascii.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@
'precision mediump float;',

'varying vec2 vTexCoord;',
'varying vec4 vPosition;',

'uniform sampler2D source;',
'uniform sampler2D letters;',
Expand Down
1 change: 0 additions & 1 deletion effects/seriously.bleach-bypass.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
'precision mediump float;',

'varying vec2 vTexCoord;',
'varying vec4 vPosition;',

'uniform sampler2D source;',

Expand Down
Loading

0 comments on commit 3b8394b

Please sign in to comment.