[Public WebGL] Indexing samplerCube(Shadow) causes shader compilation error.
Jeff Gilbert ([email protected])
[email protected]
Fri Jul 12 13:45:57 PDT 2019
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 ([email protected])
<[email protected]> 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 [email protected]
To unsubscribe, send an email to [email protected] with
the following command in the body of your email:
unsubscribe public_webgl
-----------------------------------------------------------
More information about the public_webgl
mailing list