Material "light" or "dark"

Hi everybody,

I wonder if it is possible to know if the material of my mesh is rather light or dark because i want to write on the mesh in black or white according to the darkness of the material.

Thanks in advance,


Hello @bvaisman , how are you doing?

I’m not sure if I fully understand your question. When you say “light or dark” are you refering to a specific property? I mean, you can check the material properties like diffuseColor and so on.

No, that’s my problem.

I want to write words on my mesh but if my mesh is too dark, i cannot write in black and if it’s too light, i cannot write in white because the words won’t be seen.

But what is defining the color of your material? Are you using a texture for the albedo or a value?

You can use the luminance equation maybe? image - Formula to determine perceived brightness of RGB color - Stack Overflow

The color is defined by a texture or a rgb value (emissive or diffuse).

Here’s an example of what I want to avoid.

Another way would be to create a white edging around the letters which are GUI TextBlocks. There’s the color attribute for the color of the text but is there another attribute to create such edges around the letters ?

Thanks in advance,


You can use text shadows: Simple GUI in fullscreen mode | Babylon.js Playground (

1 Like

Thanks, that was exactly what I was looking for