I recently started learning BabylonJS and i wanted to create a Lego Building Software for myself. Everything works fine but i can’t get the lighting down.
It kind of resets the light for the second brick on top of the lower one. But i would like to have a global lighting, i dont know how to call it, like this:
I search for hours now to find something relating to this but i couldn’t find anything about it.
I currently have one hemispheric light and one directional light set up. The Bricks have a standard material. It just frustrates me because everything else works but i cant seem to get the lighting down
Hi and welcome to the Forum,
Lights can be complex to work. Among the different type of lights, the materials, the shadowing, the environment… there are loads of parameters that can affect how a scene is lit.
Best for us to help you would be to have a PG example. If you haven’t learned about the playground yet, take a minute to check out this part of the doc.
Else, understand that light only adds to light. You are using two lights in your scene and one is an hemi. Lowering the light can be achieved by positioning the hemi much higher above the ground AND reducing its ‘intensity’ (to 0.5 or 0.3 for a start). Same with the directional light. The closer to the object, the stronger the light. Finally to get a more ‘global’ as you say light effect, a common technique is to use a 3 points lights (3 lights in a triangle above the scene each with an intensity of around 1/3 of the global lighting intensity you want). You should also check at all the different types of light you can create and exercise yourself in the playground, playing with there parameters and position in the scene.
Hope this helps for a start and you are welcome to return here anytime.
Meanwhile, have a great day
Edit: A simple hemi light will probably achieve the result you shared in your screenshot
Thx for the advice i’ve updated my post with the playground. I tried the hemispheric light you suggested. In your playground it looks like how i want it but with the models it looks like this again:
It looks like maybe you’ve merged the vertices of neighboring faces, causing each normal to be the average of the merged vertices. Can you try re-creating the mesh without merging vertices? In general each face should have unique vertices for the scene lighting to work properly, rather than using the same vertex for multiple faces.
I cannot answer for @Pryme8 but in general the code that is shared here is sure open for you to use.
And then, to answer your question, I believe it is always better to fix the source rather than applying tricks or further processing to it (personal opinion only).
Have a great day and glad to see you found a solution for it