From 488a8deae95b5881c7cf8a194064656f2e395df1 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 9 May 2014 19:13:12 -0700 Subject: [PATCH] Shader fixes for windows --- cocos/renderer/ccShader_Label.vert | 6 +++--- cocos/renderer/ccShader_Label_df.frag | 16 ++++++++-------- cocos/renderer/ccShader_Label_df_glow.frag | 12 ++++++------ cocos/renderer/ccShader_Label_normal.frag | 8 ++++---- cocos/renderer/ccShader_Label_outline.frag | 7 +++++-- cocos/renderer/ccShader_PositionColor.frag | 4 ++-- cocos/renderer/ccShader_PositionColor.vert | 6 +++--- .../ccShader_PositionColorLengthTexture.frag | 14 +++++++------- .../ccShader_PositionColorLengthTexture.vert | 7 ++++--- cocos/renderer/ccShader_PositionTexture.frag | 4 ++-- cocos/renderer/ccShader_PositionTexture.vert | 6 +++--- .../ccShader_PositionTextureA8Color.frag | 8 ++++---- .../ccShader_PositionTextureA8Color.vert | 6 +++--- .../ccShader_PositionTextureColorAlphaTest.frag | 8 ++++---- .../ccShader_PositionTextureColor_noMVP.frag | 4 ++-- .../ccShader_PositionTextureColor_noMVP.vert | 6 +++--- .../ccShader_PositionTexture_uColor.frag | 4 ++-- .../ccShader_PositionTexture_uColor.vert | 6 +++--- cocos/renderer/ccShader_Position_uColor.frag | 4 ++-- cocos/renderer/ccShader_Position_uColor.vert | 6 +++--- 20 files changed, 73 insertions(+), 69 deletions(-) diff --git a/cocos/renderer/ccShader_Label.vert b/cocos/renderer/ccShader_Label.vert index 3e39b68c20..a5d41eb356 100644 --- a/cocos/renderer/ccShader_Label.vert +++ b/cocos/renderer/ccShader_Label.vert @@ -29,13 +29,13 @@ attribute vec4 a_position; attribute vec2 a_texCoord; attribute vec4 a_color; -#ifdef GL_ES\n +\n#ifdef GL_ES\n varying lowp vec4 v_fragmentColor; varying mediump vec2 v_texCoord; -#else\n +\n#else\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; -#endif\n +\n#endif\n void main() { diff --git a/cocos/renderer/ccShader_Label_df.frag b/cocos/renderer/ccShader_Label_df.frag index 29b3b95669..5d4c4cce2a 100644 --- a/cocos/renderer/ccShader_Label_df.frag +++ b/cocos/renderer/ccShader_Label_df.frag @@ -1,8 +1,8 @@ const char* ccLabelDistanceFieldNormal_frag = STRINGIFY( -#ifdef GL_ES\n +\n#ifdef GL_ES\n precision lowp float; -#endif\n +\n#endif\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; @@ -12,13 +12,13 @@ uniform vec4 v_textColor; void main() { vec4 color = texture2D(CC_Texture0, v_texCoord); - //the texture use dual channel 16-bit output for distance_map - //float dist = color.b+color.g/256.0; - // the texture use single channel 8-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; \n + // the texture use single channel 8-bit output for distance_map \n float dist = color.a; - //todo:Implementation 'fwidth' for glsl 1.0 - //float width = fwidth(dist); - //assign width for constant will lead to a little bit fuzzy,it's temporary measure. + //todo:Implementation 'fwidth' for glsl 1.0 \n + //float width = fwidth(dist); \n + //assign width for constant will lead to a little bit fuzzy,it's temporary measure.\n float width = 0.04; float alpha = smoothstep(0.5-width, 0.5+width, dist) * v_textColor.a; gl_FragColor = v_fragmentColor * vec4(v_textColor.rgb,alpha); diff --git a/cocos/renderer/ccShader_Label_df_glow.frag b/cocos/renderer/ccShader_Label_df_glow.frag index 0c7dbef1f0..6b5c37c346 100644 --- a/cocos/renderer/ccShader_Label_df_glow.frag +++ b/cocos/renderer/ccShader_Label_df_glow.frag @@ -1,8 +1,8 @@ const char* ccLabelDistanceFieldGlow_frag = STRINGIFY( -#ifdef GL_ES\n +\n#ifdef GL_ES\n precision lowp float; -#endif\n +\n#endif\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; @@ -13,12 +13,12 @@ uniform vec4 v_textColor; void main() { float dist = texture2D(CC_Texture0, v_texCoord).a; - //todo:Implementation 'fwidth' for glsl 1.0 - //float width = fwidth(dist); - //assign width for constant will lead to a little bit fuzzy,it's temporary measure. + //todo:Implementation 'fwidth' for glsl 1.0 \n + //float width = fwidth(dist); \n + //assign width for constant will lead to a little bit fuzzy,it's temporary measure.\n float width = 0.04; float alpha = smoothstep(0.5-width, 0.5+width, dist); - //glow + //glow \n float mu = smoothstep(0.5, 1.0, sqrt(dist)); vec4 color = v_effectColor*(1.0-alpha) + v_textColor*alpha; gl_FragColor = v_fragmentColor * vec4(color.rgb, max(alpha,mu)*color.a); diff --git a/cocos/renderer/ccShader_Label_normal.frag b/cocos/renderer/ccShader_Label_normal.frag index 42d68c4b8e..df527aa4a6 100644 --- a/cocos/renderer/ccShader_Label_normal.frag +++ b/cocos/renderer/ccShader_Label_normal.frag @@ -24,9 +24,9 @@ */ const char* ccLabelNormal_frag = STRINGIFY( -#ifdef GL_ES\n +\n#ifdef GL_ES\n precision lowp float; -#endif\n +\n#endif\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; @@ -35,8 +35,8 @@ uniform vec4 v_textColor; void main() { - gl_FragColor = v_fragmentColor * vec4( v_textColor.rgb,// RGB from uniform - v_textColor.a * texture2D(CC_Texture0, v_texCoord).a// A from texture & 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\n ); } ); diff --git a/cocos/renderer/ccShader_Label_outline.frag b/cocos/renderer/ccShader_Label_outline.frag index cc94cdc499..1dbd0010f0 100644 --- a/cocos/renderer/ccShader_Label_outline.frag +++ b/cocos/renderer/ccShader_Label_outline.frag @@ -1,7 +1,10 @@ +/* + * LICENSE ??? + */ const char* ccLabelOutline_frag = STRINGIFY( -#ifdef GL_ES\n +\n#ifdef GL_ES\n precision lowp float; -#endif\n +\n#endif\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; diff --git a/cocos/renderer/ccShader_PositionColor.frag b/cocos/renderer/ccShader_PositionColor.frag index 0ad897f79d..21d6af569b 100644 --- a/cocos/renderer/ccShader_PositionColor.frag +++ b/cocos/renderer/ccShader_PositionColor.frag @@ -25,9 +25,9 @@ const char* ccPositionColor_frag = STRINGIFY( -#ifdef GL_ES\n +\n#ifdef GL_ES\n precision lowp float; -#endif\n +\n#endif\n varying vec4 v_fragmentColor; diff --git a/cocos/renderer/ccShader_PositionColor.vert b/cocos/renderer/ccShader_PositionColor.vert index 4e23b6aa9c..c3350505fb 100644 --- a/cocos/renderer/ccShader_PositionColor.vert +++ b/cocos/renderer/ccShader_PositionColor.vert @@ -28,11 +28,11 @@ const char* ccPositionColor_vert = STRINGIFY( attribute vec4 a_position; attribute vec4 a_color; -#ifdef GL_ES\n +\n#ifdef GL_ES\n varying lowp vec4 v_fragmentColor; -#else\n +\n#else\n varying vec4 v_fragmentColor; -#endif\n +\n#endif\n void main() { diff --git a/cocos/renderer/ccShader_PositionColorLengthTexture.frag b/cocos/renderer/ccShader_PositionColorLengthTexture.frag index e4bba63b31..4b3d69a3e2 100644 --- a/cocos/renderer/ccShader_PositionColorLengthTexture.frag +++ b/cocos/renderer/ccShader_PositionColorLengthTexture.frag @@ -21,20 +21,20 @@ const char* ccPositionColorLengthTexture_frag = STRINGIFY( -#ifdef GL_ES\n -// #extension GL_OES_standard_derivatives : enable -\n +\n#ifdef GL_ES\n +// #extension GL_OES_standard_derivatives : enable\n + varying mediump vec4 v_color; varying mediump vec2 v_texcoord; -#else\n +\n#else\n varying vec4 v_color; varying vec2 v_texcoord; -#endif\n +\n#endif\n void main() { -// #if defined GL_OES_standard_derivatives -// gl_FragColor = v_color*smoothstep(0.0, length(fwidth(v_texcoord)), 1.0 - length(v_texcoord)); +// #if defined GL_OES_standard_derivatives\n +// gl_FragColor = v_color*smoothstep(0.0, length(fwidth(v_texcoord)), 1.0 - length(v_texcoord));\n // #else\n gl_FragColor = v_color*step(0.0, 1.0 - length(v_texcoord)); // #endif\n diff --git a/cocos/renderer/ccShader_PositionColorLengthTexture.vert b/cocos/renderer/ccShader_PositionColorLengthTexture.vert index 68276f83fe..cebc2c7b13 100644 --- a/cocos/renderer/ccShader_PositionColorLengthTexture.vert +++ b/cocos/renderer/ccShader_PositionColorLengthTexture.vert @@ -21,7 +21,7 @@ const char* ccPositionColorLengthTexture_vert = STRINGIFY( -#ifdef GL_ES\n +\n#ifdef GL_ES\n attribute mediump vec4 a_position; attribute mediump vec2 a_texcoord; attribute mediump vec4 a_color; @@ -29,7 +29,7 @@ attribute mediump vec4 a_color; varying mediump vec4 v_color; varying mediump vec2 v_texcoord; -#else\n +\n#else\n attribute vec4 a_position; attribute vec2 a_texcoord; @@ -37,7 +37,8 @@ attribute vec4 a_color; varying vec4 v_color; varying vec2 v_texcoord; -#endif\n + +\n#endif\n void main() { diff --git a/cocos/renderer/ccShader_PositionTexture.frag b/cocos/renderer/ccShader_PositionTexture.frag index 80d901d43e..b6bef35075 100644 --- a/cocos/renderer/ccShader_PositionTexture.frag +++ b/cocos/renderer/ccShader_PositionTexture.frag @@ -25,9 +25,9 @@ const char* ccPositionTexture_frag = STRINGIFY( -#ifdef GL_ES\n +\n#ifdef GL_ES\n precision lowp float; -#endif\n +\n#endif\n varying vec2 v_texCoord; uniform sampler2D CC_Texture0; diff --git a/cocos/renderer/ccShader_PositionTexture.vert b/cocos/renderer/ccShader_PositionTexture.vert index df8b8c5606..8fc2c442b6 100644 --- a/cocos/renderer/ccShader_PositionTexture.vert +++ b/cocos/renderer/ccShader_PositionTexture.vert @@ -28,11 +28,11 @@ const char* ccPositionTexture_vert = STRINGIFY( attribute vec4 a_position; attribute vec2 a_texCoord; -#ifdef GL_ES\n +\n#ifdef GL_ES\n varying mediump vec2 v_texCoord; -#else\n +\n#else\n varying vec2 v_texCoord; -#endif\n +\n#endif\n void main() { diff --git a/cocos/renderer/ccShader_PositionTextureA8Color.frag b/cocos/renderer/ccShader_PositionTextureA8Color.frag index 44e3e9d9aa..e393b97f77 100644 --- a/cocos/renderer/ccShader_PositionTextureA8Color.frag +++ b/cocos/renderer/ccShader_PositionTextureA8Color.frag @@ -25,9 +25,9 @@ const char* ccPositionTextureA8Color_frag = STRINGIFY( -#ifdef GL_ES\n +\n#ifdef GL_ES\n precision lowp float; -#endif\n +\n#endif\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; @@ -35,8 +35,8 @@ uniform sampler2D CC_Texture0; void main() { - gl_FragColor = vec4( v_fragmentColor.rgb,// RGB from uniform - v_fragmentColor.a * texture2D(CC_Texture0, v_texCoord).a // A from texture & uniform + gl_FragColor = vec4( v_fragmentColor.rgb,// RGB from uniform\n + v_fragmentColor.a * texture2D(CC_Texture0, v_texCoord).a // A from texture & uniform\n ); } ); diff --git a/cocos/renderer/ccShader_PositionTextureA8Color.vert b/cocos/renderer/ccShader_PositionTextureA8Color.vert index bd250628c7..a4c8e7be69 100644 --- a/cocos/renderer/ccShader_PositionTextureA8Color.vert +++ b/cocos/renderer/ccShader_PositionTextureA8Color.vert @@ -29,13 +29,13 @@ attribute vec4 a_position; attribute vec2 a_texCoord; attribute vec4 a_color; -#ifdef GL_ES\n +\n#ifdef GL_ES\n varying lowp vec4 v_fragmentColor; varying mediump vec2 v_texCoord; -#else\n +\n#else\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; -#endif\n +\n#endif\n void main() { diff --git a/cocos/renderer/ccShader_PositionTextureColorAlphaTest.frag b/cocos/renderer/ccShader_PositionTextureColorAlphaTest.frag index 437c181f12..e0495191a9 100644 --- a/cocos/renderer/ccShader_PositionTextureColorAlphaTest.frag +++ b/cocos/renderer/ccShader_PositionTextureColorAlphaTest.frag @@ -24,9 +24,9 @@ const char* ccPositionTextureColorAlphaTest_frag = STRINGIFY( -#ifdef GL_ES +\n#ifdef GL_ES\n precision lowp float; -#endif +\n#endif\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; @@ -37,8 +37,8 @@ void main() { vec4 texColor = texture2D(CC_Texture0, v_texCoord); -// mimic: glAlphaFunc(GL_GREATER) -// pass if ( incoming_pixel >= CC_alpha_value ) => fail if incoming_pixel < CC_alpha_value +\n// mimic: glAlphaFunc(GL_GREATER) +\n// pass if ( incoming_pixel >= CC_alpha_value ) => fail if incoming_pixel < CC_alpha_value\n if ( texColor.a <= CC_alpha_value ) discard; diff --git a/cocos/renderer/ccShader_PositionTextureColor_noMVP.frag b/cocos/renderer/ccShader_PositionTextureColor_noMVP.frag index cd37da4233..e2c1efdc1c 100644 --- a/cocos/renderer/ccShader_PositionTextureColor_noMVP.frag +++ b/cocos/renderer/ccShader_PositionTextureColor_noMVP.frag @@ -24,9 +24,9 @@ */ const char* ccPositionTextureColor_noMVP_frag = STRINGIFY( -#ifdef GL_ES +\n#ifdef GL_ES\n precision lowp float; -#endif +\n#endif\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; diff --git a/cocos/renderer/ccShader_PositionTextureColor_noMVP.vert b/cocos/renderer/ccShader_PositionTextureColor_noMVP.vert index 9b5a226c1c..df4763ce77 100644 --- a/cocos/renderer/ccShader_PositionTextureColor_noMVP.vert +++ b/cocos/renderer/ccShader_PositionTextureColor_noMVP.vert @@ -28,13 +28,13 @@ attribute vec4 a_position; attribute vec2 a_texCoord; attribute vec4 a_color; -#ifdef GL_ES +\n#ifdef GL_ES\n varying lowp vec4 v_fragmentColor; varying mediump vec2 v_texCoord; -#else +\n#else\n varying vec4 v_fragmentColor; varying vec2 v_texCoord; -#endif +\n#endif\n void main() { diff --git a/cocos/renderer/ccShader_PositionTexture_uColor.frag b/cocos/renderer/ccShader_PositionTexture_uColor.frag index 12ea811d46..f5b8d8ff31 100644 --- a/cocos/renderer/ccShader_PositionTexture_uColor.frag +++ b/cocos/renderer/ccShader_PositionTexture_uColor.frag @@ -25,9 +25,9 @@ const char* ccPositionTexture_uColor_frag = STRINGIFY( -#ifdef GL_ES\n +\n#ifdef GL_ES\n precision lowp float; -#endif\n +\n#endif\n uniform vec4 u_color; diff --git a/cocos/renderer/ccShader_PositionTexture_uColor.vert b/cocos/renderer/ccShader_PositionTexture_uColor.vert index 33f56d1c50..53f6aad578 100644 --- a/cocos/renderer/ccShader_PositionTexture_uColor.vert +++ b/cocos/renderer/ccShader_PositionTexture_uColor.vert @@ -28,11 +28,11 @@ const char* ccPositionTexture_uColor_vert = STRINGIFY( attribute vec4 a_position; attribute vec2 a_texCoord; -#ifdef GL_ES\n +\n#ifdef GL_ES\n varying mediump vec2 v_texCoord; -#else\n +\n#else\n varying vec2 v_texCoord; -#endif\n +\n#endif\n void main() { diff --git a/cocos/renderer/ccShader_Position_uColor.frag b/cocos/renderer/ccShader_Position_uColor.frag index ce71bbe1e7..1f99562171 100644 --- a/cocos/renderer/ccShader_Position_uColor.frag +++ b/cocos/renderer/ccShader_Position_uColor.frag @@ -25,9 +25,9 @@ const char* ccPosition_uColor_frag = STRINGIFY( -#ifdef GL_ES\n +\n#ifdef GL_ES\n precision lowp float; -#endif\n +\n#endif\n varying vec4 v_fragmentColor; diff --git a/cocos/renderer/ccShader_Position_uColor.vert b/cocos/renderer/ccShader_Position_uColor.vert index 7470142216..329f172606 100644 --- a/cocos/renderer/ccShader_Position_uColor.vert +++ b/cocos/renderer/ccShader_Position_uColor.vert @@ -29,11 +29,11 @@ attribute vec4 a_position; uniform vec4 u_color; uniform float u_pointSize; -#ifdef GL_ES\n +\n#ifdef GL_ES\n varying lowp vec4 v_fragmentColor; -#else\n +\n#else\n varying vec4 v_fragmentColor; -#endif\n +\n#endif\n void main() {