dmurdoch / rgl

rgl is a 3D visualization system based on OpenGL. It provides a medium to high level interface for use in R, currently modelled on classic R graphics, with extensions to allow for interaction.
https://dmurdoch.github.io/rgl/
GNU General Public License v2.0
85 stars 20 forks source link

rgl should use two-sided shading #308

Closed dmurdoch closed 1 year ago

dmurdoch commented 1 year ago

In R, shading depends on the direction of the normal vector. For example, this code:

cube <- addNormals(cube3d(col = "red"))
open3d()
shade3d(cube)

cube$normals <- -cube$normals
cube$normals[4,] <- 1
open3d()
shade3d(cube)

gives these displays:

Screen Shot 2023-01-29 at 6 36 43 AM

The WebGL displays using rglwidget() are the same in both cases, as they should be. (They are different because of Gouraud shading in R vs Phong shading in WebGL.)

dmurdoch commented 1 year ago

This doesn't look possible in fixed pipeline OpenGL. Maybe #309 will solve it.