From 99df7cda423c0257144eeb907a34db3b4512e3ec Mon Sep 17 00:00:00 2001 From: Duncan Murdoch Date: Sun, 18 Feb 2024 08:30:12 -0500 Subject: [PATCH] Use luminance, not red, for compatibility with older shader. --- inst/htmlwidgets/lib/rglClass/shaders/rgl_fragment.glsl | 6 ++++-- man/material.Rd | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/inst/htmlwidgets/lib/rglClass/shaders/rgl_fragment.glsl b/inst/htmlwidgets/lib/rglClass/shaders/rgl_fragment.glsl index 7d4a03752..8c5ffb5c1 100644 --- a/inst/htmlwidgets/lib/rglClass/shaders/rgl_fragment.glsl +++ b/inst/htmlwidgets/lib/rglClass/shaders/rgl_fragment.glsl @@ -203,12 +203,14 @@ void main(void) { #endif //TEXTURE_rgba #ifdef TEXTURE_alpha + float luminance = dot(vec3(1.,1.,1.),textureColor.rgb)/3.; + #if defined(TEXMODE_replace) || defined(TEXMODE_decal) - textureColor = vec4(lighteffect.rgb, textureColor.r); + textureColor = vec4(lighteffect.rgb, luminance); #endif #if defined(TEXMODE_modulate) || defined(TEXMODE_blend) || defined(TEXMODE_add) - textureColor = vec4(lighteffect.rgb, lighteffect.a*textureColor.r); + textureColor = vec4(lighteffect.rgb, lighteffect.a*luminance); #endif #endif // TEXTURE_alpha diff --git a/man/material.Rd b/man/material.Rd index 22ffcf8af..5ddaa3f6a 100644 --- a/man/material.Rd +++ b/man/material.Rd @@ -117,7 +117,8 @@ of objects in an \pkg{rgl} scene. 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 luminance (i.e. the average of the R, G and B channels) +of the texture, whereas the R display bases the choice on the internal format of the texture file. } \item{texmode}{