From pub...@ Fri Jul 12 03:41:06 2019 From: pub...@ (Anton Sedov (...@...)) Date: Fri, 12 Jul 2019 13:41:06 +0300 Subject: [Public WebGL] Indexing samplerCube(Shadow) causes shader compilation error. Message-ID: Indexing samplerCube and samplerCubeShadow causes shader compilation error. Consider the case below: #define LIGHTS_COUNT 4 #define SHADOW_CASTERS_COUNT 3 // Provides relations between shadow casters and lights uniform int shadowCastersMask[LIGHTS_COUNT]; #ifdef GLES_3 uniform highp samplerCubeShadow shadowCastersSamplers[SHADOW_CASTERS_COUNT]; #else uniform highp samplerCube shadowCastersSamplers[SHADOW_CASTERS_COUNT]; #endif ... for (int lightIndex = 0; lightIndex < LIGHTS_COUNT; ++lightIndex) { ... float shaded = 0.0; int shadowCasterIndex = shadowCastersMask[lightIndex]; if (shadowCasterIndex == -1) continue; for (int samplingIndex = 0; samplingIndex < SHADOW_CASTERS_COUNT; ++samplingIndex) { if (samplingIndex != shadowCasterIndex) continue; float currentDepth = ... vec4 samplingVector = ... #ifdef GLES_3 shaded = 1.0 - texture(shadowCastersSamplers[samplingIndex], samplingVector); #else float closestDepth = textureCube(shadowCastersSamplers[samplingIndex], vec3(samplingVector)).r; shaded = currentDepth > closestDepth ? 1.0 : 0.0; #endif break; } ... diffuseColor *= 1.0 - shaded; specularColor *= 1.0 - shaded; ... } When you will try to compile the code above on android browser with WebGL 2 rendering context enabled you get: 'samplerCubeShadow' : requires extension GL_EXT_gpu_shader5 to be enabled '[' : indexing into a sampler array using a non-constant expression is not permitted The same code works perfect on PC with WebGL 1 / WebGL 2 context, but on android browsers with WebGL 1 rendering context only. *Note that replacing 'samplerCubeShadow' by 'samplerCube' doesn't change nothing.* As you can see the code valid on WebGL 1 rendering context doesn't work on second context. Looks like a bug, isn't it? Chrome version is 75.0.3770.101. Firefox version is 68.0. Android versions: 7.0, 8.0, 9.0. -- _ATTENTION:?*This message with all the attachments contains confidential information. Review, transfer, distribution, disclosure or use of received information is prohibited for the unauthorized recipient.*_ -------------- next part -------------- An HTML attachment was scrubbed... URL: From pub...@ Fri Jul 12 13:45:57 2019 From: pub...@ (Jeff Gilbert (...@...)) Date: Fri, 12 Jul 2019 13:45:57 -0700 Subject: [Public WebGL] Indexing samplerCube(Shadow) causes shader compilation error. In-Reply-To: References: Message-ID: Unfortunately, the Android behavior is correct, and the desktop behavior is incorrect for essl300. I made a testcase: https://jsfiddle.net/7kbLg6v1/3/ On Fri, Jul 12, 2019 at 3:42 AM Anton Sedov (anton.s...@) wrote: > > Indexing samplerCube and samplerCubeShadow causes shader compilation error. > > Consider the case below: > > #define LIGHTS_COUNT 4 > #define SHADOW_CASTERS_COUNT 3 > > // Provides relations between shadow casters and lights > uniform int shadowCastersMask[LIGHTS_COUNT]; > > #ifdef GLES_3 > uniform highp samplerCubeShadow shadowCastersSamplers[SHADOW_CASTERS_COUNT]; > #else > uniform highp samplerCube shadowCastersSamplers[SHADOW_CASTERS_COUNT]; > #endif > > ... > > for (int lightIndex = 0; lightIndex < LIGHTS_COUNT; ++lightIndex) { > ... > > float shaded = 0.0; > > int shadowCasterIndex = shadowCastersMask[lightIndex]; > > if (shadowCasterIndex == -1) > continue; > > for (int samplingIndex = 0; samplingIndex < SHADOW_CASTERS_COUNT; ++samplingIndex) { > if (samplingIndex != shadowCasterIndex) continue; > > float currentDepth = ... > vec4 samplingVector = ... > > #ifdef GLES_3 > shaded = 1.0 - texture(shadowCastersSamplers[samplingIndex], samplingVector); > #else > float closestDepth = textureCube(shadowCastersSamplers[samplingIndex], vec3(samplingVector)).r; > shaded = currentDepth > closestDepth ? 1.0 : 0.0; > #endif > break; > } > > ... > > diffuseColor *= 1.0 - shaded; > specularColor *= 1.0 - shaded; > > ... > } > > When you will try to compile the code above on android browser with WebGL 2 rendering context enabled you get: > > 'samplerCubeShadow' : requires extension GL_EXT_gpu_shader5 to be enabled > '[' : indexing into a sampler array using a non-constant expression is not permitted > > The same code works perfect on PC with WebGL 1 / WebGL 2 context, but on android browsers with WebGL 1 rendering context only. > > Note that replacing 'samplerCubeShadow' by 'samplerCube' doesn't change nothing. > As you can see the code valid on WebGL 1 rendering context doesn't work on second context. > Looks like a bug, isn't it? > > Chrome version is 75.0.3770.101. Firefox version is 68.0. > Android versions: 7.0, 8.0, 9.0. > > ATTENTION: This message with all the attachments contains confidential information. Review, transfer, distribution, disclosure or use of received information is prohibited for the unauthorized recipient. ----------------------------------------------------------- You are currently subscribed to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: unsubscribe public_webgl ----------------------------------------------------------- From pub...@ Fri Jul 12 14:07:21 2019 From: pub...@ (Jeff Gilbert (...@...)) Date: Fri, 12 Jul 2019 14:07:21 -0700 Subject: [Public WebGL] Indexing samplerCube(Shadow) causes shader compilation error. In-Reply-To: References: Message-ID: I'm adding a test for this: https://github.com/KhronosGroup/WebGL/pull/2910 On Fri, Jul 12, 2019 at 1:45 PM Jeff Gilbert wrote: > > Unfortunately, the Android behavior is correct, and the desktop > behavior is incorrect for essl300. > I made a testcase: https://jsfiddle.net/7kbLg6v1/3/ > > On Fri, Jul 12, 2019 at 3:42 AM Anton Sedov (anton.s...@) > wrote: > > > > Indexing samplerCube and samplerCubeShadow causes shader compilation error. > > > > Consider the case below: > > > > #define LIGHTS_COUNT 4 > > #define SHADOW_CASTERS_COUNT 3 > > > > // Provides relations between shadow casters and lights > > uniform int shadowCastersMask[LIGHTS_COUNT]; > > > > #ifdef GLES_3 > > uniform highp samplerCubeShadow shadowCastersSamplers[SHADOW_CASTERS_COUNT]; > > #else > > uniform highp samplerCube shadowCastersSamplers[SHADOW_CASTERS_COUNT]; > > #endif > > > > ... > > > > for (int lightIndex = 0; lightIndex < LIGHTS_COUNT; ++lightIndex) { > > ... > > > > float shaded = 0.0; > > > > int shadowCasterIndex = shadowCastersMask[lightIndex]; > > > > if (shadowCasterIndex == -1) > > continue; > > > > for (int samplingIndex = 0; samplingIndex < SHADOW_CASTERS_COUNT; ++samplingIndex) { > > if (samplingIndex != shadowCasterIndex) continue; > > > > float currentDepth = ... > > vec4 samplingVector = ... > > > > #ifdef GLES_3 > > shaded = 1.0 - texture(shadowCastersSamplers[samplingIndex], samplingVector); > > #else > > float closestDepth = textureCube(shadowCastersSamplers[samplingIndex], vec3(samplingVector)).r; > > shaded = currentDepth > closestDepth ? 1.0 : 0.0; > > #endif > > break; > > } > > > > ... > > > > diffuseColor *= 1.0 - shaded; > > specularColor *= 1.0 - shaded; > > > > ... > > } > > > > When you will try to compile the code above on android browser with WebGL 2 rendering context enabled you get: > > > > 'samplerCubeShadow' : requires extension GL_EXT_gpu_shader5 to be enabled > > '[' : indexing into a sampler array using a non-constant expression is not permitted > > > > The same code works perfect on PC with WebGL 1 / WebGL 2 context, but on android browsers with WebGL 1 rendering context only. > > > > Note that replacing 'samplerCubeShadow' by 'samplerCube' doesn't change nothing. > > As you can see the code valid on WebGL 1 rendering context doesn't work on second context. > > Looks like a bug, isn't it? > > > > Chrome version is 75.0.3770.101. Firefox version is 68.0. > > Android versions: 7.0, 8.0, 9.0. > > > > ATTENTION: This message with all the attachments contains confidential information. Review, transfer, distribution, disclosure or use of received information is prohibited for the unauthorized recipient. ----------------------------------------------------------- You are currently subscribed to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: unsubscribe public_webgl ----------------------------------------------------------- From pub...@ Fri Jul 12 14:17:00 2019 From: pub...@ (Ken Russell (...@...)) Date: Fri, 12 Jul 2019 14:17:00 -0700 Subject: [Public WebGL] Indexing samplerCube(Shadow) causes shader compilation error. In-Reply-To: References: Message-ID: This limitation in OpenGL ES 3.00 is discussed in its specification available here: https://www.khronos.org/registry/OpenGL/index_es.php Section 12.30 "Dynamic Indexing" states: "Indexing of arrays of samplers by constant-index-expressions is supported in GLSL ES 1.00. A constant- index-expression is an expression formed from constant-expressions and certain loop indices, defined for a subset of loop constructs. Should this functionality be included in GLSL ES 3.00? RESOLUTION: No. Arrays of samplers may only be indexed by constant-integral-expressions." WebGL implementations should be doing a better job of rejecting this construct on all platforms. Thanks Jeff for putting together the test case. Anton, you could work around this using a switch statement and using a constant index into the array in each arm. Assuming all of the fragments for a given triangle go down the same path I think this won't cause divergent behavior in the shader and should be reasonably fast. -Ken On Fri, Jul 12, 2019 at 2:08 PM Jeff Gilbert (jgilbert...@) < public_webgl...@> wrote: > > I'm adding a test for this: > https://github.com/KhronosGroup/WebGL/pull/2910 > > On Fri, Jul 12, 2019 at 1:45 PM Jeff Gilbert wrote: > > > > Unfortunately, the Android behavior is correct, and the desktop > > behavior is incorrect for essl300. > > I made a testcase: https://jsfiddle.net/7kbLg6v1/3/ > > > > On Fri, Jul 12, 2019 at 3:42 AM Anton Sedov (anton.s...@) > > wrote: > > > > > > Indexing samplerCube and samplerCubeShadow causes shader compilation > error. > > > > > > Consider the case below: > > > > > > #define LIGHTS_COUNT 4 > > > #define SHADOW_CASTERS_COUNT 3 > > > > > > // Provides relations between shadow casters and lights > > > uniform int shadowCastersMask[LIGHTS_COUNT]; > > > > > > #ifdef GLES_3 > > > uniform highp samplerCubeShadow > shadowCastersSamplers[SHADOW_CASTERS_COUNT]; > > > #else > > > uniform highp samplerCube > shadowCastersSamplers[SHADOW_CASTERS_COUNT]; > > > #endif > > > > > > ... > > > > > > for (int lightIndex = 0; lightIndex < LIGHTS_COUNT; ++lightIndex) { > > > ... > > > > > > float shaded = 0.0; > > > > > > int shadowCasterIndex = shadowCastersMask[lightIndex]; > > > > > > if (shadowCasterIndex == -1) > > > continue; > > > > > > for (int samplingIndex = 0; samplingIndex < > SHADOW_CASTERS_COUNT; ++samplingIndex) { > > > if (samplingIndex != shadowCasterIndex) continue; > > > > > > float currentDepth = ... > > > vec4 samplingVector = ... > > > > > > #ifdef GLES_3 > > > shaded = 1.0 - > texture(shadowCastersSamplers[samplingIndex], samplingVector); > > > #else > > > float closestDepth = > textureCube(shadowCastersSamplers[samplingIndex], vec3(samplingVector)).r; > > > shaded = currentDepth > closestDepth ? 1.0 : 0.0; > > > #endif > > > break; > > > } > > > > > > ... > > > > > > diffuseColor *= 1.0 - shaded; > > > specularColor *= 1.0 - shaded; > > > > > > ... > > > } > > > > > > When you will try to compile the code above on android browser with > WebGL 2 rendering context enabled you get: > > > > > > 'samplerCubeShadow' : requires extension GL_EXT_gpu_shader5 to be > enabled > > > '[' : indexing into a sampler array using a non-constant > expression is not permitted > > > > > > The same code works perfect on PC with WebGL 1 / WebGL 2 context, but > on android browsers with WebGL 1 rendering context only. > > > > > > Note that replacing 'samplerCubeShadow' by 'samplerCube' doesn't > change nothing. > > > As you can see the code valid on WebGL 1 rendering context doesn't > work on second context. > > > Looks like a bug, isn't it? > > > > > > Chrome version is 75.0.3770.101. Firefox version is 68.0. > > > Android versions: 7.0, 8.0, 9.0. > > > > > > ATTENTION: This message with all the attachments contains confidential > information. Review, transfer, distribution, disclosure or use of received > information is prohibited for the unauthorized recipient. > > ----------------------------------------------------------- > You are currently subscribed to public_webgl...@ > To unsubscribe, send an email to majordomo...@ with > the following command in the body of your email: > unsubscribe public_webgl > ----------------------------------------------------------- > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pub...@ Mon Jul 15 10:16:19 2019 From: pub...@ (Anton Sedov (...@...)) Date: Mon, 15 Jul 2019 20:16:19 +0300 Subject: [Public WebGL] Indexing samplerCube(Shadow) causes shader compilation error. In-Reply-To: References: Message-ID: Yes, solution with switch statement works fine. Thanks for advice. ??, 13 ???. 2019 ?. ? 00:17, Ken Russell (kbr...@) < public_webgl...@>: > This limitation in OpenGL ES 3.00 is discussed in its specification > available here: > https://www.khronos.org/registry/OpenGL/index_es.php > > Section 12.30 "Dynamic Indexing" states: > > "Indexing of arrays of samplers by constant-index-expressions is supported > in GLSL ES 1.00. A constant- index-expression is an expression formed from > constant-expressions and certain loop indices, defined for a subset of loop > constructs. Should this functionality be included in GLSL ES 3.00? > > RESOLUTION: No. Arrays of samplers may only be indexed by > constant-integral-expressions." > > WebGL implementations should be doing a better job of rejecting this > construct on all platforms. Thanks Jeff for putting together the test case. > > Anton, you could work around this using a switch statement and using a > constant index into the array in each arm. Assuming all of the fragments > for a given triangle go down the same path I think this won't cause > divergent behavior in the shader and should be reasonably fast. > > -Ken > > > On Fri, Jul 12, 2019 at 2:08 PM Jeff Gilbert (jgilbert...@) < > public_webgl...@> wrote: > >> >> I'm adding a test for this: >> https://github.com/KhronosGroup/WebGL/pull/2910 >> >> On Fri, Jul 12, 2019 at 1:45 PM Jeff Gilbert >> wrote: >> > >> > Unfortunately, the Android behavior is correct, and the desktop >> > behavior is incorrect for essl300. >> > I made a testcase: https://jsfiddle.net/7kbLg6v1/3/ >> > >> > On Fri, Jul 12, 2019 at 3:42 AM Anton Sedov (anton.s...@) >> > wrote: >> > > >> > > Indexing samplerCube and samplerCubeShadow causes shader compilation >> error. >> > > >> > > Consider the case below: >> > > >> > > #define LIGHTS_COUNT 4 >> > > #define SHADOW_CASTERS_COUNT 3 >> > > >> > > // Provides relations between shadow casters and lights >> > > uniform int shadowCastersMask[LIGHTS_COUNT]; >> > > >> > > #ifdef GLES_3 >> > > uniform highp samplerCubeShadow >> shadowCastersSamplers[SHADOW_CASTERS_COUNT]; >> > > #else >> > > uniform highp samplerCube >> shadowCastersSamplers[SHADOW_CASTERS_COUNT]; >> > > #endif >> > > >> > > ... >> > > >> > > for (int lightIndex = 0; lightIndex < LIGHTS_COUNT; ++lightIndex) >> { >> > > ... >> > > >> > > float shaded = 0.0; >> > > >> > > int shadowCasterIndex = shadowCastersMask[lightIndex]; >> > > >> > > if (shadowCasterIndex == -1) >> > > continue; >> > > >> > > for (int samplingIndex = 0; samplingIndex < >> SHADOW_CASTERS_COUNT; ++samplingIndex) { >> > > if (samplingIndex != shadowCasterIndex) continue; >> > > >> > > float currentDepth = ... >> > > vec4 samplingVector = ... >> > > >> > > #ifdef GLES_3 >> > > shaded = 1.0 - >> texture(shadowCastersSamplers[samplingIndex], samplingVector); >> > > #else >> > > float closestDepth = >> textureCube(shadowCastersSamplers[samplingIndex], vec3(samplingVector)).r; >> > > shaded = currentDepth > closestDepth ? 1.0 : 0.0; >> > > #endif >> > > break; >> > > } >> > > >> > > ... >> > > >> > > diffuseColor *= 1.0 - shaded; >> > > specularColor *= 1.0 - shaded; >> > > >> > > ... >> > > } >> > > >> > > When you will try to compile the code above on android browser with >> WebGL 2 rendering context enabled you get: >> > > >> > > 'samplerCubeShadow' : requires extension GL_EXT_gpu_shader5 to be >> enabled >> > > '[' : indexing into a sampler array using a non-constant >> expression is not permitted >> > > >> > > The same code works perfect on PC with WebGL 1 / WebGL 2 context, but >> on android browsers with WebGL 1 rendering context only. >> > > >> > > Note that replacing 'samplerCubeShadow' by 'samplerCube' doesn't >> change nothing. >> > > As you can see the code valid on WebGL 1 rendering context doesn't >> work on second context. >> > > Looks like a bug, isn't it? >> > > >> > > Chrome version is 75.0.3770.101. Firefox version is 68.0. >> > > Android versions: 7.0, 8.0, 9.0. >> > > >> > > ATTENTION: This message with all the attachments contains >> confidential information. Review, transfer, distribution, disclosure or use >> of received information is prohibited for the unauthorized recipient. >> >> ----------------------------------------------------------- >> You are currently subscribed to public_webgl...@ >> To unsubscribe, send an email to majordomo...@ with >> the following command in the body of your email: >> unsubscribe public_webgl >> ----------------------------------------------------------- >> >> -- _ATTENTION:?*This message with all the attachments contains confidential information. Review, transfer, distribution, disclosure or use of received information is prohibited for the unauthorized recipient.*_ -------------- next part -------------- An HTML attachment was scrubbed... URL: