iTowns / itowns

A Three.js-based framework written in Javascript/WebGL for visualizing 3D geospatial data
http://www.itowns-project.org
Other
1.08k stars 293 forks source link

[BUG - ColorLayer] ColorLayer rendering issue on firefox with planar view #2236

Closed ketourneau closed 7 months ago

ketourneau commented 7 months ago

Your Environment

Context

We used a WMS source (to render a GeoTiff) with a ColorLayer and a PlanarView and with map background. We want to replace white color of WMS source by transparency so we try to use effect type:2 on ColorLayer (applyWhiteToInvisibleEffect). But it seems to render black color in firefox so we apply custom effect type.

Steps to Reproduce (for bugs)

online demo

  1. Use firefox and open online demo link
  2. Expand Color Layers and expand GeoTiff layer
  3. Set effect_type to 2 (applyWhiteToInvisibleEffect)

Expected Behavior

With effect_type:2 on ColorLayer => white color must be invisible (on all browsers).

firefox_effect_type_custom

Actual Behavior

With effect_type:2 on ColorLayer => white color is replaced by black color (only on firefox, it's working on chrome).

firefox_effect_type_2

Possible Cause/Fix/Solution

It seems it's caused by applyWhiteToInvisibleEffect.

I think we can replace line 29 by color.a = 0.0.

It's how we fix it in our demo.

Desplandis commented 7 months ago

Hi and thanks for your detailed bug report! I managed to easily reproduce this issue and agree with you on the cause of the bug.

The different type of effects on color layers are clearly not well-documented (especially the effect_parameter layer property which is passed to the shader as a per-layer uniform).

In the case where effect_type = 2, effect_parameter is passed as the intensity parameter of applyWhiteToInvisibleEffect and is used in line 29. Since we do not set a default value to effect_parameter it is passed as undefined to the shader (which could be implementation-defined behavior).

Moreover, I too question the need for line 29 since $a \in [0.99, 1.0]$ at this point. Since this is not documented, we could either:

I'll open a PR fixing those three issues (documentation, undefined and shader code)!