How to have the Environment Ground receive light?

Hello, I’m using “createDefaultEnvironment” so to be able to have nice reflections on the ground, but the ground does not react to any light.
I’ve looked in the properties of “createDefaultEnvironment”, and I can change ground color, texture, opacity, but can’t tell him to receive light, like any mesh.
I could use a regular plane, but in this way I could not use “enableGroundMirror”, and “groundMirrorFallOffDistance” properties…
How to do that?
Here’s my demo
https://www.babylonjs-playground.com/#VWI383#3

Many thanks!

You may tune Primary Color of BackgroundPlaneMaterial

Thank-you labris,
but this is not what I need.
I would need to see the spotlight on the ground, just like on the cube, somethink like this picture:
tmp

I suspect that it’s a matter of the ground shader, that is something like “unlit”…
Is it possible to change the ground material with a standard one, that can react to the lights, and at the same time keep the nice reflections that fade on the distance (thanks to the “groundMirrorFallOffDistance” property") ?

P.S. where did you get that inspector tool?

Many thanks

For the Inspector just press Inspector button at the top of Playground:


You can also call it from the code:
scene.debugLayer.show()
As for your need to have reflections and lighting simultaneously - you may try to use (instead of ground mirror) reflection probes - Reflections and Refractions | Babylon.js Documentation

Unfortunately I can’t use reflection probes for 2 reasons:

  • them are not good at all for floor reflections
  • I have a texture on my cube that change, so the reflection have to change too.

Really is not possible to have floor reflections and shading at the same time?? :roll_eyes:

The best solution is to write a custom shader for this purpose or use Node material.
(but I am still not very good with that :slight_smile: )

Why not using a pbr material ? It would provide both but no custom falloff

1 Like

Quite surprising… with Three js there’s groundReflector out of the box to do that…
Is there any other way to have reflections on the floor ?

I’m looking at “MirrorTexture”, but as sebavan told there’s no falloff.
But, since there’s a depth pass, could not be used to blur/fade the reflection on the distance (even if I don’t know how) ?

Maybe this example is what you are looking for? - https://playground.babylonjs.com/#LVTTQX#1

1 Like

More or less :slight_smile:
Usually the reflections decay on the distance from the object (mostly due to the rougness of the floor surface), this give them a more realistic look.
Look this example picture


It seem that in Babylon this “reflection decay effect” can be achieved only with a “BackgroundPlane”, with a “BackgroundMaterial”, but this shader does not react to lighting.
Anyway, I’m trying to put a regular plane with a standard material under the backgroundPlane, and tweaking the color and the alpha mode of the backgroundMaterial.
It’s not perfect but it’s better

Ok, moving the regular plane a bit under the groundPlane and changing the groundPlane color to black it seem that I can achieve something more what I want,


But the reflection is very jaggy, how can I increase the resolution of the mirror texture of the groundPlane (in the Inspector is named “BackgroundPlaneMirrorTexture”) ?
P.S. I don’t want to blur the reflection with kernel value, just to have an higher resolution reflection texture
Here’s my demo
https://www.babylonjs-playground.com/#VWI383#4
Many thanks!

1 Like

You can pass groundMirrorSizeRatio to the default env creator. This will use the size of the rendering context (your canvas) and will calculate the max POT size for your texture.

I removed your blur and have increased the size of the canvas (using hardware scaling) just to explain what is possible:

MyTestForGroundReflection | Babylon.js Playground (babylonjs-playground.com)

Using the default hardware scaling, it’ll be this:

MyTestForGroundReflection | Babylon.js Playground (babylonjs-playground.com)

You can always create your own ground and texture and set its size to be the size you wish, if the default configuration is not suffice.

2 Likes

Thanks a lot RaananW, that’s what I was looking for.
After a couple of days of test I’m really proud of my cube :grinning_face_with_smiling_eyes: :grinning_face_with_smiling_eyes: :grinning_face_with_smiling_eyes:

4 Likes