WebGL Varyings Error

443 views
Skip to first unread message

JR Smith

unread,
Mar 13, 2015, 10:51:50 PM3/13/15
to webgl-d...@googlegroups.com
I am having trouble with a linker error in WebGL that popped up in Chrome. This particular set of shaders all worked in Chrome and Firefox before.  Now it only works in Firefox. 

Error message:
Uncaught Error linking shaders:Varyings with the same name but different type, or statically used varyings in fragment shader are not declared in vertex shader: vColor

Before I post a frag/vert shader, I want to point out that as a test I ran through all of my frag shaders and gave it a static color. The program linked just fine. 

basic.frag
precision mediump float;
precision mediump int;

varying vec4 vColor;

void main(void) {
gl_FragColor = vColor;
}

point.vert
precision mediump float;
precision mediump int;

attribute vec3 aVertexPosition;
attribute vec4 aVertexColor;

uniform mat4 uModelViewMatrix;
uniform mat4 uProjectionMatrix;
uniform float uPointSize;

//for undetermined point attenuation feature
// uniform vec3 uAttenuation;

uniform vec3 uBias;
uniform vec3 uScale;
uniform int uCEMode;

varying vec4 vColor;

void main(void) {
if(uCEMode == 1) {
//use bias and scale unifroms for min max color enhancement
vColor = (aVertexColor - vec4(uBias, 0.0)) * vec4(uScale, 1.0);
}
else {
vColor = aVertexColor;
}

vec4 ecPos4 = uModelViewMatrix * vec4(aVertexPosition, 1.0);

//make points larger as they get further away from the viewer
//helps to make the cloud look less sparse when far enough to only see
//the first level or two of the octree
gl_PointSize = length(ecPos4) / uPointSize * 3.0;

//for undetermined point attenuation feature
// float attn = uAttenuation[0] + (uAttenuation[1] * dist) + (uAttenuation[2] * dist * dist);
// gl_PointSize = (attn > 0.0 && attn < uPointSize) ? uPointSize * sqrt(1.0/attn) : uPointSize;

gl_Position = uProjectionMatrix * ecPos4;
}

I've tried adding lowp/mediump/highp. I've tried declaring it at the top of all the files and individually for each variable. The error message tells me nothing since, as it is hopefully clear above, the varying vColor is the same thing. I've done all the googling I can think of, checked the spec, and even read some tutorials - which also didn't work in Chrome but worked in Firefox.

Last checklist:
- Chrome is updated
- Windows 7 updated
- Chrome's cache is cleared
- Use console watch variables and breakpoints to make sure it's pulling the right shaders
- WebGL is enabled in checking chrome://gpu/

I'm hoping someone can either see what's wrong with the above code or provide something else for me to check (or remind me of something I didn't include in my writeup).

JR Smith

unread,
Mar 13, 2015, 10:54:50 PM3/13/15
to webgl-d...@googlegroups.com
I went to webglreport.com after this to pull down all the pertinent info. I hope this helps:


Platform:Win32
Browser User Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36
Context Name:webgl
GL Version:WebGL 1.0 (OpenGL ES 2.0 Chromium)
Shading Language Version:WebGL GLSL ES 1.0 (OpenGL ES GLSL ES 1.0 Chromium)
Vendor:WebKit
Renderer:WebKit WebGL
Unmasked Vendor:Google Inc.
Unmasked Renderer:ANGLE (Intel(R) HD Graphics 4000 Direct3D11 vs_5_0 ps_5_0)
Antialiasing:Available
ANGLE:Yes, D3D11
Major Performance Caveat:No

Vertex Shader

Max Vertex Attributes:16
Max Vertex Uniform Vectors:1024
Max Vertex Texture Image Units:16
Max Varying Vectors:28
Best float precision:[-2127, 2127] (23)

Transform Feedback

Coming in WebGL 2

Rasterizer

Aliased Line Width Range:[1, 1]
Aliased Point Size Range:[1, 1024]

Fragment Shader

Max Fragment Uniform Vectors:1024
Max Texture Image Units:16
float/int precision:highp/highp
Best float precision:[-2127, 2127] (23)

Framebuffer

Max Color Buffers:8
RGBA Bits:[8, 8, 8, 8]
Depth / Stencil Bits:[24, 8]
Max Render Buffer Size:16384
Max Viewport Dimensions:[16384, 16384]

Textures

Max Texture Size:16384
Max Cube Map Texture Size:16384
Max Combined Texture Image Units:32
Max Anisotropy:16

Uniform Buffers

Coming in WebGL 2
Supported Extensions:
ANGLE_instanced_arrays
EXT_blend_minmax
EXT_frag_depth
EXT_shader_texture_lod
EXT_sRGB
EXT_texture_filter_anisotropic
WEBKIT_EXT_texture_filter_anisotropic
OES_element_index_uint
OES_standard_derivatives
OES_texture_float
OES_texture_float_linear
OES_texture_half_float
OES_texture_half_float_linear
OES_vertex_array_object
WEBGL_compressed_texture_s3tc
WEBKIT_WEBGL_compressed_texture_s3tc
WEBGL_debug_renderer_info
WEBGL_debug_shaders
WEBGL_depth_texture
WEBKIT_WEBGL_depth_texture
WEBGL_draw_buffers
WEBGL_lose_context
WEBKIT_WEBGL_lose_context
 

Alecazam

unread,
Mar 14, 2015, 12:26:14 PM3/14/15
to webgl-d...@googlegroups.com
You might try converting uCEMode to a bool.   There are specific static and dynamic branching registers for bools.  If you use an int all bets are off.   int was meant for indexing only (skinning).   

JR Smith

unread,
Mar 15, 2015, 11:12:00 AM3/15/15
to webgl-d...@googlegroups.com
Thank you for the suggestion, but that change doesn't change the error mentioned above.

Alecazam

unread,
Mar 15, 2015, 1:51:04 PM3/15/15
to webgl-d...@googlegroups.com
My guess is it's a bug in Angle shader translator.  You can try without the branch (just have two shaders), and see if that fixes.   You can always try the GL backend and see if that works, and also download the Angle source to see where it's shader translation is going awry.

Zhenyao Mo

unread,
Mar 16, 2015, 12:36:51 PM3/16/15
to webgl-d...@googlegroups.com
OK, I'll debug a little and get back to you soon. Thanks for reporting this.

--
You received this message because you are subscribed to the Google Groups "WebGL Dev List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webgl-dev-lis...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Zhenyao Mo

unread,
Mar 16, 2015, 12:50:59 PM3/16/15
to webgl-d...@googlegroups.com
So I tested on Linux with top of tree Chromium build with the two shaders, and it compiled and linked fine for me.

So it seems like a win only bug

fragment:

precision mediump float;
precision mediump int;

varying vec4 vColor;

void main(void) {
gl_FragColor = vColor;
}


vertex:

Geoff Lang

unread,
Mar 16, 2015, 2:16:56 PM3/16/15
to webgl-d...@googlegroups.com
I tried compiling the shader in chrome M42 and M43 and didn't see any link errors.  It could be an M41-only issue or requires more than just the shader to repro.

Jamie Madill

unread,
Mar 16, 2015, 2:22:37 PM3/16/15
to webgl-d...@googlegroups.com
Just a note that I tried in ANGLE D3D11 on Chrome M41 and didn't repro the bug. If you can find a repro case, please open a bug on crbug.com with the contents of your about:gpu. Also trying in Canary wouldn't hurt.

Kenneth Russell

unread,
Mar 16, 2015, 2:46:14 PM3/16/15
to webgl-d...@googlegroups.com
I wonder whether the problem might be a bug in Chrome's shader cache. There have been a couple of bugs discovered and fixed recently, usually involving compiling shaders and linking programs multiple times.

Try running Chrome from the command line with the argument --user-data-dir=[temporary directory]. If that clears up the problem then there's likely a bug in the shader cache. It would be great if you could try to figure out reproduction steps in that case.


Reply all
Reply to author
Forward
0 new messages