forked from cocos2d/cocos2d-x
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cocos2d#6270 from andyque/feature4783
closed cocos2d#4783, add outline shader files
- Loading branch information
Showing
4 changed files
with
139 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
Created by guanghui on 4/8/14. | ||
http://www.idevgames.com/forums/thread-3010.html | ||
*/ | ||
|
||
varying vec2 v_texCoord; | ||
varying vec4 v_fragmentColor; | ||
|
||
uniform sampler2D CC_Texture0; | ||
|
||
uniform vec3 u_outlineColor; | ||
uniform float u_threshold; | ||
uniform float u_radius; | ||
|
||
void main() | ||
{ | ||
float radius = u_radius; | ||
vec4 accum = vec4(0.0); | ||
vec4 normal = vec4(0.0); | ||
|
||
normal = texture2D(CC_Texture0, vec2(v_texCoord.x, v_texCoord.y)); | ||
|
||
accum += texture2D(CC_Texture0, vec2(v_texCoord.x - radius, v_texCoord.y - radius)); | ||
accum += texture2D(CC_Texture0, vec2(v_texCoord.x + radius, v_texCoord.y - radius)); | ||
accum += texture2D(CC_Texture0, vec2(v_texCoord.x + radius, v_texCoord.y + radius)); | ||
accum += texture2D(CC_Texture0, vec2(v_texCoord.x - radius, v_texCoord.y + radius)); | ||
|
||
accum *= u_threshold; | ||
|
||
accum.r = u_outlineColor.x; | ||
accum.g = u_outlineColor.y; | ||
accum.b = u_outlineColor.z; | ||
|
||
normal = (accum * (1.0 - normal.a)) + (normal * normal.a); | ||
|
||
gl_FragColor = v_fragmentColor * normal; | ||
} | ||
|
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,20 @@ | ||
/* | ||
Created by guanghui on 4/8/14. | ||
*/ | ||
|
||
|
||
attribute vec4 a_position; | ||
attribute vec4 a_color; | ||
attribute vec2 a_texCoord; | ||
|
||
varying vec2 v_texCoord; | ||
|
||
varying vec4 v_fragmentColor; | ||
|
||
void main() | ||
{ | ||
gl_Position = CC_MVPMatrix * a_position; | ||
v_fragmentColor = a_color; | ||
v_texCoord = a_texCoord; | ||
} |