Scene
background color and model lighting wrong
#507
-
I can't seem to set the background color of the scene to match the actual color of the view surrounding it. And when I have both main direct light and indirect light, the model is still very dark. Help is greatly appreciated! I've got the following setup for my Jetpack Compose var isLoadingModel by remember { mutableStateOf(true) }
val nodes = remember { mutableStateListOf<Node>() }
val engine = rememberEngine()
val modelLoader = rememberModelLoader(engine)
val indirectLight = rememberIndirectLight(engine = engine)
val mainLight = rememberMainLightNode(engine = engine)
val view = rememberView(engine = engine)
val renderer = rememberRenderer(engine)
val scene = rememberScene(engine = engine)
val materialLoader = rememberMaterialLoader(engine)
val skybox = rememberSkybox(engine = engine, creator = {
Skybox
.Builder()
.color(250f / 255f, 250f / 255f, 250f / 255f, 1f)
.build(engine)
}
) Loading the models: LaunchedEffect(key1 = true) {
modelLoader.loadModelInstanceAsync("https://github.com/JohanSkoett/glb_tests/raw/main/untitled2.glb", onResult = { modelInstance ->
isLoadingModel = false
modelInstance?.let {
val node = ModelNode(
modelInstance = it,
scaleToUnits = 2.5f
).apply {
transform(
position = Position(z = -4f, x = -0.1f, y = -0.3f),
rotation = Rotation(x = 0f)
)
}
nodes.add(node)
}
})
} The actual scene: Scene(
modifier = Modifier,
activity = LocalContext.current as? MainActivity,
lifecycle = LocalLifecycleOwner.current.lifecycle,
childNodes = nodes,
engine = engine,
modelLoader = modelLoader,
materialLoader = materialLoader,
scene = scene,
view = view,
renderer = renderer,
indirectLight = indirectLight,
skybox = skybox,
mainLightNode = mainLight,
) What my scene actually looks like: It's clear that the scene's background is not 3x 255 / 255 RGB, and I can't seem to solve the model being very dark. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
@ThomasGorisse |
Beta Was this translation helpful? Give feedback.
-
@NohaSamir |
Beta Was this translation helpful? Give feedback.
-
Have you tried setting a different environment? These are used to determine how things are lit.
Here are some free image based lighting files you can try: https://polyhaven.com/hdris |
Beta Was this translation helpful? Give feedback.
-
You can make the 3d background transparent instead of white because the white color looks different in the 3D environment.
|
Beta Was this translation helpful? Give feedback.
-
For the lights, Create a front light and add it to the nodes list
|
Beta Was this translation helpful? Give feedback.
-
Hello, Do you found any solution to make background transparent with version 2.0.3 ? |
Beta Was this translation helpful? Give feedback.
-
@dsilvera I found an answer in this issue |
Beta Was this translation helpful? Give feedback.
Have you tried setting a different environment? These are used to determine how things are lit.
Here are some free image based lighting files you can try: https://polyhaven.com/hdris