DiscussionsIssue archiveOCCT:Visualization

Archived issue #0032067

Visualization, TKOpenGl - shadowmap GLSL compilation error on WebGL 2.0

Open CASCADEOCCT:Visualizationclosed2 public notes

Search issues

Description

The following compilation error occurs in Microsoft Edge browser ([network address removed]) with hardware acceleration turned OFF:
EGLVersion: 1.4 Emscripten EGL
EGLVendor: Emscripten
EGLClientAPIs: OpenGL_ES
GLvendor: WebKit
GLdevice: WebKit WebGL
GLunmaskedVendor: Google Inc.
GLunmaskedDevice: Google SwiftShader
GLversion: OpenGL ES 3.0 (WebGL 2.0 (OpenGL ES 3.0 Chromium)) [GLSL: OpenGL ES GLSL ES 3.00 (WebGL GLSL ES 3.00 (OpenGL ES GLSL ES 3.0 Chromium))]
Max texture size: 8192
Max FBO dump size: 8192x8192
Max combined texture units: 32
Max MSAA samples: 0
Viewport: 583x464
GLextensions: EXT_color_buffer_float EXT_color_buffer_half_float EXT_float_blend EXT_texture_filter_anisotropic OES_texture_float_linear WEBGL_compressed_texture_etc WEBGL_compressed_texture_etc1 WEBGL_compressed_texture_s3tc WEBGL_debug_renderer_info WEBGL_debug_shaders WEBGL_lose_context WEBGL_multi_draw GL_EXT_color_buffer_float GL_EXT_color_buffer_half_float GL_EXT_float_blend GL_EXT_texture_filter_anisotropic GL_OES_texture_float_linear GL_WEBGL_compressed_texture_etc GL_WEBGL_compressed_texture_etc1 GL_WEBGL_compressed_texture_s3tc GL_WEBGL_debug_renderer_info GL_WEBGL_debug_shaders GL_WEBGL_lose_context GL_WEBGL_multi_draw
ResolutionRatio: 1.33333
Display scale: 1

TKOpenGl | Type: Error | ID: 0 | Severity: High | Message:
  
1: #version 300 es
528: //! Function computes directional light shadow attenuation (1.0 means no shadow).
529: float occDirectionalLightShadow (in int  theId,
530:                                  in vec3 theNormal)
531: {
532:   vec4 aPosLightSpace = PosLightSpace[theId];
533:   vec3 aLightDir = vec3 (occWorldViewMatrix * vec4 (occLight_Position (theId), 0.0));
534:   vec3 aProjCoords = (aPosLightSpace.xyz / aPosLightSpace.w) * 0.5 + vec3 (0.5);
535:   float aCurrentDepth = aProjCoords.z;
536:   if (abs(aProjCoords.x) > 1.0 || abs(aProjCoords.y) > 1.0 || aCurrentDepth > 1.0) { return 1.0; }
537:   vec2 aTexelSize = vec2 (occShadowMapSizeBias.x);
538:   float aBias = max (occShadowMapSizeBias.y * (1.0 - dot (theNormal, aLightDir)), occShadowMapSizeBias.y * 0.1);
539:   float aShadow = 0.0;
540:   for (int aPosIter = 0; aPosIter < 16; ++aPosIter)
541:   {
542:     float aClosestDepth = occTexture2D (occShadowMapSamplers[theId], aProjCoords.xy + occPoissonDisk16[aPosIter] * aTexelSize).r;
543:     aShadow += (aCurrentDepth - aBias) > aClosestDepth ? 1.0 : 0.0;
544:   }
545:   return 1.0 - aShadow / 16.0;
546: }
....
occt-webgl-sample.js:9 TKOpenGl | Type: Error | ID: 0 | Severity: High | Message:
  Failed to compile Fragment Shader [occt_phong-pbr-ls_D-0000]. Compilation log:
ERROR: 0:542: '[' : array index for samplers must be constant integral expressions


There is no such issue with hardware-accelerated WebGL implementations.



Other issues with WebGL 1.0:
409: const vec2 occPoissonDisk16[16] = vec2[](
...
TKOpenGl | Type: Error | ID: 0 | Severity: High | Message:
  Failed to compile Fragment Shader [occt_phong-ls_D-0000]. Compilation log:
ERROR: 0:409: '[]' : implicitly sized array supported in GLSL ES 3.00 and above only
ERROR: 0:409: '[]' : array constructor supported in GLSL ES 3.00 and above only
ERROR: 0:409: '[]' : first-class arrays (array initializer) supported in GLSL ES 3.00 and above only


And WebGL 1.0 (not fixed by the patch - has to implement a fallback with hard-coded light source index):
420: float occDirectionalLightShadow (in sampler2D theShadow,
421: in int theId,
422: in vec3 theNormal)
423: {
424: vec4 aPosLightSpace = PosLightSpace[theId];
...
TKOpenGl | Type: Error | ID: 0 | Severity: High | Message:
Failed to compile Fragment Shader [occt_phong-ls_D-0000]. Compilation log:
ERROR: 0:424: '[]' : Index expression must be constant

Steps to reproduce

N/A

pload MODELING VISUALIZATION
box b  0 0 0 1 2 3
box bb -4 -4 0 8 8 0 -preview
vgldebug -debug 1 -glslWarn 1 -extraMsg 1
vcaps -maxVersion 2 1
vinit View1
vdisplay -dispMode 1 b bb
vfit
vrenderparams -shadingModel phong
vlight -change 0 -castShadows 1  -head 0 -direction 0.1 0.1 -1


Result on Radeon:
TKOpenGl | Type: Portability | ID: 0 | Severity: Low | Message:
  Fragment Shader [occt_phong-ls_D-0000] compilation log:
WARNING: 0:413: warning(#253) Unsized array constructors are not supported in implicit GLSL version number 110

Public activity

2 archived notes

Participants are labeled by their role within this record.

01Author
Please raise the patch
- OCCT branch: [archived branch]

http://jenkins-test-12.nnov.opencascade.com:8080/view/CR32067-master-KGV
02Commenter 1
Combination -
OCCT branch : [archived branch]
master SHA - [revision removed]
[revision removed]
Products branch : [archived branch] SHA - [revision removed]
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Debian80-64:
OCCT
Total CPU difference: 17720.020000000055 / 17721.200000000135 [-0.01%]
Products
Total CPU difference: 12428.380000000123 / 12412.630000000105 [+0.13%]
Windows-64-VC14:
OCCT
Total CPU difference: 19367.234375 / 19300.265625 [+0.35%]
Products
Total CPU difference: 13821.875 / 13740.03125 [+0.60%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention

Related records