-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update package.json with new test-suite sha, rename imageOffset -> setPattern include distance interpolation for opacity fix linting tests refactor image offset calculations use distance from line to calculate alpha, change to multiplication for combining u_opacity and alpha add u_world to use_program for outline pattern, refactor using new imageOffset function refactor draw_fill, fix conditionals
- Loading branch information
Molly Lloyd
committed
Apr 4, 2016
1 parent
3f86fbf
commit 6a985a6
Showing
5 changed files
with
154 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
precision mediump float; | ||
|
||
uniform float u_opacity; | ||
uniform vec2 u_pattern_tl_a; | ||
uniform vec2 u_pattern_br_a; | ||
uniform vec2 u_pattern_tl_b; | ||
uniform vec2 u_pattern_br_b; | ||
uniform float u_mix; | ||
|
||
uniform sampler2D u_image; | ||
|
||
varying vec2 v_pos_a; | ||
varying vec2 v_pos_b; | ||
varying vec2 v_pos; | ||
|
||
void main() { | ||
vec2 imagecoord = mod(v_pos_a, 1.0); | ||
vec2 pos = mix(u_pattern_tl_a, u_pattern_br_a, imagecoord); | ||
vec4 color1 = texture2D(u_image, pos); | ||
|
||
vec2 imagecoord_b = mod(v_pos_b, 1.0); | ||
vec2 pos2 = mix(u_pattern_tl_b, u_pattern_br_b, imagecoord_b); | ||
vec4 color2 = texture2D(u_image, pos2); | ||
|
||
// find distance to outline for alpha interpolation | ||
|
||
float dist = length(v_pos - gl_FragCoord.xy); | ||
float alpha = smoothstep(1.0, 0.0, dist); | ||
|
||
|
||
gl_FragColor = mix(color1, color2, u_mix) * alpha * u_opacity; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
precision highp float; | ||
|
||
uniform vec2 u_patternscale_a; | ||
uniform vec2 u_patternscale_b; | ||
uniform vec2 u_offset_a; | ||
uniform vec2 u_offset_b; | ||
|
||
attribute vec2 a_pos; | ||
|
||
uniform mat4 u_matrix; | ||
uniform vec2 u_world; | ||
|
||
varying vec2 v_pos_a; | ||
varying vec2 v_pos_b; | ||
varying vec2 v_pos; | ||
|
||
|
||
void main() { | ||
gl_Position = u_matrix * vec4(a_pos, 0, 1); | ||
v_pos_a = u_patternscale_a * a_pos + u_offset_a; | ||
v_pos_b = u_patternscale_b * a_pos + u_offset_b; | ||
v_pos = (gl_Position.xy/gl_Position.w + 1.0) / 2.0 * u_world; | ||
} |