sceneview-android icon indicating copy to clipboard operation
sceneview-android copied to clipboard

ImageNode or PlaneNode cannot change the color/material

Open natasam opened this issue 1 year ago • 5 comments

I was trying to change the color of the ImageNnode and PlaneNode, by loading material, creating materialInstance, and setting color, but nothing worked. Also, when the image has opacity, it will not be rendered at all. How to properly set or change the color of the PlaneNode? Everything I get is light grey, white or black. this is my Scene:

Scene(
               modifier = Modifier.fillMaxSize(),
               engine = engine,
               onViewCreated = {
                   scene.skybox = Skybox.Builder().color(255f, 255f, 255f, 1.0f).build(engine)
                   scene.indirectLight = environment.indirectLight
               },
               modelLoader = modelLoader,
               cameraNode = cameraNode,
               childNodes = listOf(
                   centerNode, plane
               ),
             
               onFrame = {
               }
           )

And the plane is:

val plane =  PlaneNode(
           engine = engine,
           size = Size(2f, 2f),
           center = Position(x = 0f, y = 1f, z = 0.1f),
           normal = Direction(x = 0f, y = 0f, z = 0f),
          // materialInstances = listOf(materialInstance),
            materialInstance = materialInstance,
       )

Material is loaded corectly. But no color is shown. Screenshot 2024-03-06 at 21 13 26

natasam avatar Mar 06 '24 20:03 natasam

i'm using this method and it's working fine on my side

CubeNode(
            engine = engine,
        ).apply {
//...
            if (materialLoader != null) {
                materialInstance = materialLoader.createColorInstance(
                        color = Color(0.561f, 0.561f, 0.561f, 1.0f)
                    )
// ...
            }
        }

feel free to try it ^^

KvRae avatar Mar 06 '24 20:03 KvRae

Regarding the material loader, it's not a mandatory component in my function. Therefore, if it's passed, I will use it, and if not, I will ignore it.

For the PlaneNode, you can modify the cube node's properties to make it resemble a plane node. For instance, you can create a CubeNode with the following dimensions:

size = Float3(x=10f, y=10f, z=0.1f)

This is a temporary workaround until the actual issue is resolved :)

KvRae avatar Mar 07 '24 09:03 KvRae

That's great to hear! I hope everything gets fixed in the meantime...

KvRae avatar Mar 07 '24 13:03 KvRae