Skip to content

Commit

Permalink
Use luminance, not red, for compatibility with older shader.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmurdoch committed Feb 18, 2024
1 parent 4f66c2e commit 99df7cd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions inst/htmlwidgets/lib/rglClass/shaders/rgl_fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion man/material.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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}{
Expand Down

0 comments on commit 99df7cd

Please sign in to comment.