A light that is infinitely far away, such as the sun.
IlluminateWithDirectionalLightSample
@Sampled
@Composable
fun IlluminateWithDirectionalLightSample() {
// Since our light color is white, we set a darker background so that its visible.
val surfaceColor = remember { Color.Black }
val surfaceShape = remember { RoundedCornerShape(24.dp) }
Box(
Modifier.size(160.dp)
.background(surfaceColor)
.illuminate(
lights =
listOf(
DirectionalLight(
color = Color.White,
// Points towards the light: above and to the left of the surface.
directionX = -1f,
directionY = -1f,
intensity = 1f,
directionZ = 1f,
)
),
surfaceMaterial = SurfaceMaterial.diffuse(Color.White),
surfaceGeometrySpec =
SurfaceGeometrySpec.convex(
shape = surfaceShape,
thickness = 1.dp,
bevelWidth = 12.dp,
),
)
)
}