Skip to content

Commit

Permalink
Use red channel to retrieve value for textype="alpha"; all textures…
Browse files Browse the repository at this point in the history
… are converted to RGBA.
  • Loading branch information
dmurdoch committed Feb 18, 2024
1 parent 09462bd commit 4f66c2e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# rgl 1.2.13
# rgl 1.2.14

## Major changes

Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions inst/htmlwidgets/lib/rglClass/shaders/rgl_fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions man/material.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4f66c2e

Please sign in to comment.