[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] Indexing samplerCube(Shadow) causes shader compilation error.



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@webgears.app)
<public_webgl@khronos.org> 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@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email:
unsubscribe public_webgl
-----------------------------------------------------------