From 4f66c2e8853bc5f76b756c0bd1ac3b7f9900e4ec Mon Sep 17 00:00:00 2001 From: Duncan Murdoch Date: Sun, 18 Feb 2024 05:33:38 -0500 Subject: [PATCH] Use red channel to retrieve value for `textype="alpha"`; all textures are converted to RGBA. --- NEWS.md | 3 ++- inst/htmlwidgets/lib/rglClass/shaders/rgl_fragment.glsl | 6 +++--- man/material.Rd | 6 ++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 2dbd25d7e..af826fbc9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# rgl 1.2.13 +# rgl 1.2.14 ## Major changes @@ -28,6 +28,7 @@ run in a Shiny session. * Fixed issue with `warning()` call reported by CRAN. * Smooth shapes were not rendered correctly by `rglwidget()`. This was especially noticeable for spheres with `fov = 0`, but was present in other cases as well (issue #401). +* `textype = "alpha"` was not rendered correctly by `rglwidget()` (issue #408). # rgl 1.2.1 diff --git a/inst/htmlwidgets/lib/rglClass/shaders/rgl_fragment.glsl b/inst/htmlwidgets/lib/rglClass/shaders/rgl_fragment.glsl index 0ed044e59..7d4a03752 100644 --- a/inst/htmlwidgets/lib/rglClass/shaders/rgl_fragment.glsl +++ b/inst/htmlwidgets/lib/rglClass/shaders/rgl_fragment.glsl @@ -204,14 +204,14 @@ void main(void) { #ifdef TEXTURE_alpha #if defined(TEXMODE_replace) || defined(TEXMODE_decal) - textureColor = vec4(lighteffect.rgb, textureColor.a); + textureColor = vec4(lighteffect.rgb, textureColor.r); #endif #if defined(TEXMODE_modulate) || defined(TEXMODE_blend) || defined(TEXMODE_add) - textureColor = vec4(lighteffect.rgb, lighteffect.a*textureColor.a); + textureColor = vec4(lighteffect.rgb, lighteffect.a*textureColor.r); #endif -#endif +#endif // TEXTURE_alpha // The TEXTURE_luminance values are not from that reference #ifdef TEXTURE_luminance diff --git a/man/material.Rd b/man/material.Rd index 0b4f59e6d..22ffcf8af 100644 --- a/man/material.Rd +++ b/man/material.Rd @@ -113,6 +113,12 @@ of objects in an \pkg{rgl} scene. \item{"rgb"}{color} \item{"rgba"}{color and alpha texture} } + Note that support for these modes is slightly different +in the display within R versus the WebGL display using +\code{rglwidget()}. In particular, in WebGL +\code{textype = "alpha"} will always take the alpha value from +the red channel of the texture, whereas the R display bases +the choice on the internal format of the texture file. } \item{texmode}{ specifies how the texture interacts with the existing