Shader fixes for windows

This commit is contained in:
Ricardo Quesada 2014-05-09 19:13:12 -07:00
parent e8d2cf7871
commit 488a8deae9
20 changed files with 73 additions and 69 deletions

View File

@ -29,13 +29,13 @@ attribute vec4 a_position;
attribute vec2 a_texCoord; attribute vec2 a_texCoord;
attribute vec4 a_color; attribute vec4 a_color;
#ifdef GL_ES\n \n#ifdef GL_ES\n
varying lowp vec4 v_fragmentColor; varying lowp vec4 v_fragmentColor;
varying mediump vec2 v_texCoord; varying mediump vec2 v_texCoord;
#else\n \n#else\n
varying vec4 v_fragmentColor; varying vec4 v_fragmentColor;
varying vec2 v_texCoord; varying vec2 v_texCoord;
#endif\n \n#endif\n
void main() void main()
{ {

View File

@ -1,8 +1,8 @@
const char* ccLabelDistanceFieldNormal_frag = STRINGIFY( const char* ccLabelDistanceFieldNormal_frag = STRINGIFY(
#ifdef GL_ES\n \n#ifdef GL_ES\n
precision lowp float; precision lowp float;
#endif\n \n#endif\n
varying vec4 v_fragmentColor; varying vec4 v_fragmentColor;
varying vec2 v_texCoord; varying vec2 v_texCoord;
@ -12,13 +12,13 @@ uniform vec4 v_textColor;
void main() void main()
{ {
vec4 color = texture2D(CC_Texture0, v_texCoord); vec4 color = texture2D(CC_Texture0, v_texCoord);
//the texture use dual channel 16-bit output for distance_map //the texture use dual channel 16-bit output for distance_map \n
//float dist = color.b+color.g/256.0; //float dist = color.b+color.g/256.0; \n
// the texture use single channel 8-bit output for distance_map // the texture use single channel 8-bit output for distance_map \n
float dist = color.a; float dist = color.a;
//todo:Implementation 'fwidth' for glsl 1.0 //todo:Implementation 'fwidth' for glsl 1.0 \n
//float width = fwidth(dist); //float width = fwidth(dist); \n
//assign width for constant will lead to a little bit fuzzy,it's temporary measure. //assign width for constant will lead to a little bit fuzzy,it's temporary measure.\n
float width = 0.04; float width = 0.04;
float alpha = smoothstep(0.5-width, 0.5+width, dist) * v_textColor.a; float alpha = smoothstep(0.5-width, 0.5+width, dist) * v_textColor.a;
gl_FragColor = v_fragmentColor * vec4(v_textColor.rgb,alpha); gl_FragColor = v_fragmentColor * vec4(v_textColor.rgb,alpha);

View File

@ -1,8 +1,8 @@
const char* ccLabelDistanceFieldGlow_frag = STRINGIFY( const char* ccLabelDistanceFieldGlow_frag = STRINGIFY(
#ifdef GL_ES\n \n#ifdef GL_ES\n
precision lowp float; precision lowp float;
#endif\n \n#endif\n
varying vec4 v_fragmentColor; varying vec4 v_fragmentColor;
varying vec2 v_texCoord; varying vec2 v_texCoord;
@ -13,12 +13,12 @@ uniform vec4 v_textColor;
void main() void main()
{ {
float dist = texture2D(CC_Texture0, v_texCoord).a; float dist = texture2D(CC_Texture0, v_texCoord).a;
//todo:Implementation 'fwidth' for glsl 1.0 //todo:Implementation 'fwidth' for glsl 1.0 \n
//float width = fwidth(dist); //float width = fwidth(dist); \n
//assign width for constant will lead to a little bit fuzzy,it's temporary measure. //assign width for constant will lead to a little bit fuzzy,it's temporary measure.\n
float width = 0.04; float width = 0.04;
float alpha = smoothstep(0.5-width, 0.5+width, dist); float alpha = smoothstep(0.5-width, 0.5+width, dist);
//glow //glow \n
float mu = smoothstep(0.5, 1.0, sqrt(dist)); float mu = smoothstep(0.5, 1.0, sqrt(dist));
vec4 color = v_effectColor*(1.0-alpha) + v_textColor*alpha; vec4 color = v_effectColor*(1.0-alpha) + v_textColor*alpha;
gl_FragColor = v_fragmentColor * vec4(color.rgb, max(alpha,mu)*color.a); gl_FragColor = v_fragmentColor * vec4(color.rgb, max(alpha,mu)*color.a);

View File

@ -24,9 +24,9 @@
*/ */
const char* ccLabelNormal_frag = STRINGIFY( const char* ccLabelNormal_frag = STRINGIFY(
#ifdef GL_ES\n \n#ifdef GL_ES\n
precision lowp float; precision lowp float;
#endif\n \n#endif\n
varying vec4 v_fragmentColor; varying vec4 v_fragmentColor;
varying vec2 v_texCoord; varying vec2 v_texCoord;
@ -35,8 +35,8 @@ uniform vec4 v_textColor;
void main() void main()
{ {
gl_FragColor = v_fragmentColor * vec4( v_textColor.rgb,// RGB from uniform gl_FragColor = v_fragmentColor * vec4( v_textColor.rgb,// RGB from uniform\n
v_textColor.a * texture2D(CC_Texture0, v_texCoord).a// A from texture & uniform v_textColor.a * texture2D(CC_Texture0, v_texCoord).a// A from texture & uniform\n
); );
} }
); );

View File

@ -1,7 +1,10 @@
/*
* LICENSE ???
*/
const char* ccLabelOutline_frag = STRINGIFY( const char* ccLabelOutline_frag = STRINGIFY(
#ifdef GL_ES\n \n#ifdef GL_ES\n
precision lowp float; precision lowp float;
#endif\n \n#endif\n
varying vec4 v_fragmentColor; varying vec4 v_fragmentColor;
varying vec2 v_texCoord; varying vec2 v_texCoord;

View File

@ -25,9 +25,9 @@
const char* ccPositionColor_frag = STRINGIFY( const char* ccPositionColor_frag = STRINGIFY(
#ifdef GL_ES\n \n#ifdef GL_ES\n
precision lowp float; precision lowp float;
#endif\n \n#endif\n
varying vec4 v_fragmentColor; varying vec4 v_fragmentColor;

View File

@ -28,11 +28,11 @@ const char* ccPositionColor_vert = STRINGIFY(
attribute vec4 a_position; attribute vec4 a_position;
attribute vec4 a_color; attribute vec4 a_color;
#ifdef GL_ES\n \n#ifdef GL_ES\n
varying lowp vec4 v_fragmentColor; varying lowp vec4 v_fragmentColor;
#else\n \n#else\n
varying vec4 v_fragmentColor; varying vec4 v_fragmentColor;
#endif\n \n#endif\n
void main() void main()
{ {

View File

@ -21,20 +21,20 @@
const char* ccPositionColorLengthTexture_frag = STRINGIFY( const char* ccPositionColorLengthTexture_frag = STRINGIFY(
#ifdef GL_ES\n \n#ifdef GL_ES\n
// #extension GL_OES_standard_derivatives : enable // #extension GL_OES_standard_derivatives : enable\n
\n
varying mediump vec4 v_color; varying mediump vec4 v_color;
varying mediump vec2 v_texcoord; varying mediump vec2 v_texcoord;
#else\n \n#else\n
varying vec4 v_color; varying vec4 v_color;
varying vec2 v_texcoord; varying vec2 v_texcoord;
#endif\n \n#endif\n
void main() void main()
{ {
// #if defined GL_OES_standard_derivatives // #if defined GL_OES_standard_derivatives\n
// gl_FragColor = v_color*smoothstep(0.0, length(fwidth(v_texcoord)), 1.0 - length(v_texcoord)); // gl_FragColor = v_color*smoothstep(0.0, length(fwidth(v_texcoord)), 1.0 - length(v_texcoord));\n
// #else\n // #else\n
gl_FragColor = v_color*step(0.0, 1.0 - length(v_texcoord)); gl_FragColor = v_color*step(0.0, 1.0 - length(v_texcoord));
// #endif\n // #endif\n

View File

@ -21,7 +21,7 @@
const char* ccPositionColorLengthTexture_vert = STRINGIFY( const char* ccPositionColorLengthTexture_vert = STRINGIFY(
#ifdef GL_ES\n \n#ifdef GL_ES\n
attribute mediump vec4 a_position; attribute mediump vec4 a_position;
attribute mediump vec2 a_texcoord; attribute mediump vec2 a_texcoord;
attribute mediump vec4 a_color; attribute mediump vec4 a_color;
@ -29,7 +29,7 @@ attribute mediump vec4 a_color;
varying mediump vec4 v_color; varying mediump vec4 v_color;
varying mediump vec2 v_texcoord; varying mediump vec2 v_texcoord;
#else\n \n#else\n
attribute vec4 a_position; attribute vec4 a_position;
attribute vec2 a_texcoord; attribute vec2 a_texcoord;
@ -37,7 +37,8 @@ attribute vec4 a_color;
varying vec4 v_color; varying vec4 v_color;
varying vec2 v_texcoord; varying vec2 v_texcoord;
#endif\n
\n#endif\n
void main() void main()
{ {

View File

@ -25,9 +25,9 @@
const char* ccPositionTexture_frag = STRINGIFY( const char* ccPositionTexture_frag = STRINGIFY(
#ifdef GL_ES\n \n#ifdef GL_ES\n
precision lowp float; precision lowp float;
#endif\n \n#endif\n
varying vec2 v_texCoord; varying vec2 v_texCoord;
uniform sampler2D CC_Texture0; uniform sampler2D CC_Texture0;

View File

@ -28,11 +28,11 @@ const char* ccPositionTexture_vert = STRINGIFY(
attribute vec4 a_position; attribute vec4 a_position;
attribute vec2 a_texCoord; attribute vec2 a_texCoord;
#ifdef GL_ES\n \n#ifdef GL_ES\n
varying mediump vec2 v_texCoord; varying mediump vec2 v_texCoord;
#else\n \n#else\n
varying vec2 v_texCoord; varying vec2 v_texCoord;
#endif\n \n#endif\n
void main() void main()
{ {

View File

@ -25,9 +25,9 @@
const char* ccPositionTextureA8Color_frag = STRINGIFY( const char* ccPositionTextureA8Color_frag = STRINGIFY(
#ifdef GL_ES\n \n#ifdef GL_ES\n
precision lowp float; precision lowp float;
#endif\n \n#endif\n
varying vec4 v_fragmentColor; varying vec4 v_fragmentColor;
varying vec2 v_texCoord; varying vec2 v_texCoord;
@ -35,8 +35,8 @@ uniform sampler2D CC_Texture0;
void main() void main()
{ {
gl_FragColor = vec4( v_fragmentColor.rgb,// RGB from uniform gl_FragColor = vec4( v_fragmentColor.rgb,// RGB from uniform\n
v_fragmentColor.a * texture2D(CC_Texture0, v_texCoord).a // A from texture & uniform v_fragmentColor.a * texture2D(CC_Texture0, v_texCoord).a // A from texture & uniform\n
); );
} }
); );

View File

@ -29,13 +29,13 @@ attribute vec4 a_position;
attribute vec2 a_texCoord; attribute vec2 a_texCoord;
attribute vec4 a_color; attribute vec4 a_color;
#ifdef GL_ES\n \n#ifdef GL_ES\n
varying lowp vec4 v_fragmentColor; varying lowp vec4 v_fragmentColor;
varying mediump vec2 v_texCoord; varying mediump vec2 v_texCoord;
#else\n \n#else\n
varying vec4 v_fragmentColor; varying vec4 v_fragmentColor;
varying vec2 v_texCoord; varying vec2 v_texCoord;
#endif\n \n#endif\n
void main() void main()
{ {

View File

@ -24,9 +24,9 @@
const char* ccPositionTextureColorAlphaTest_frag = STRINGIFY( const char* ccPositionTextureColorAlphaTest_frag = STRINGIFY(
#ifdef GL_ES \n#ifdef GL_ES\n
precision lowp float; precision lowp float;
#endif \n#endif\n
varying vec4 v_fragmentColor; varying vec4 v_fragmentColor;
varying vec2 v_texCoord; varying vec2 v_texCoord;
@ -37,8 +37,8 @@ void main()
{ {
vec4 texColor = texture2D(CC_Texture0, v_texCoord); vec4 texColor = texture2D(CC_Texture0, v_texCoord);
// mimic: glAlphaFunc(GL_GREATER) \n// mimic: glAlphaFunc(GL_GREATER)
// pass if ( incoming_pixel >= CC_alpha_value ) => fail if incoming_pixel < CC_alpha_value \n// pass if ( incoming_pixel >= CC_alpha_value ) => fail if incoming_pixel < CC_alpha_value\n
if ( texColor.a <= CC_alpha_value ) if ( texColor.a <= CC_alpha_value )
discard; discard;

View File

@ -24,9 +24,9 @@
*/ */
const char* ccPositionTextureColor_noMVP_frag = STRINGIFY( const char* ccPositionTextureColor_noMVP_frag = STRINGIFY(
#ifdef GL_ES \n#ifdef GL_ES\n
precision lowp float; precision lowp float;
#endif \n#endif\n
varying vec4 v_fragmentColor; varying vec4 v_fragmentColor;
varying vec2 v_texCoord; varying vec2 v_texCoord;

View File

@ -28,13 +28,13 @@ attribute vec4 a_position;
attribute vec2 a_texCoord; attribute vec2 a_texCoord;
attribute vec4 a_color; attribute vec4 a_color;
#ifdef GL_ES \n#ifdef GL_ES\n
varying lowp vec4 v_fragmentColor; varying lowp vec4 v_fragmentColor;
varying mediump vec2 v_texCoord; varying mediump vec2 v_texCoord;
#else \n#else\n
varying vec4 v_fragmentColor; varying vec4 v_fragmentColor;
varying vec2 v_texCoord; varying vec2 v_texCoord;
#endif \n#endif\n
void main() void main()
{ {

View File

@ -25,9 +25,9 @@
const char* ccPositionTexture_uColor_frag = STRINGIFY( const char* ccPositionTexture_uColor_frag = STRINGIFY(
#ifdef GL_ES\n \n#ifdef GL_ES\n
precision lowp float; precision lowp float;
#endif\n \n#endif\n
uniform vec4 u_color; uniform vec4 u_color;

View File

@ -28,11 +28,11 @@ const char* ccPositionTexture_uColor_vert = STRINGIFY(
attribute vec4 a_position; attribute vec4 a_position;
attribute vec2 a_texCoord; attribute vec2 a_texCoord;
#ifdef GL_ES\n \n#ifdef GL_ES\n
varying mediump vec2 v_texCoord; varying mediump vec2 v_texCoord;
#else\n \n#else\n
varying vec2 v_texCoord; varying vec2 v_texCoord;
#endif\n \n#endif\n
void main() void main()
{ {

View File

@ -25,9 +25,9 @@
const char* ccPosition_uColor_frag = STRINGIFY( const char* ccPosition_uColor_frag = STRINGIFY(
#ifdef GL_ES\n \n#ifdef GL_ES\n
precision lowp float; precision lowp float;
#endif\n \n#endif\n
varying vec4 v_fragmentColor; varying vec4 v_fragmentColor;

View File

@ -29,11 +29,11 @@ attribute vec4 a_position;
uniform vec4 u_color; uniform vec4 u_color;
uniform float u_pointSize; uniform float u_pointSize;
#ifdef GL_ES\n \n#ifdef GL_ES\n
varying lowp vec4 v_fragmentColor; varying lowp vec4 v_fragmentColor;
#else\n \n#else\n
varying vec4 v_fragmentColor; varying vec4 v_fragmentColor;
#endif\n \n#endif\n
void main() void main()
{ {