As you can see, the environment light looks brighter at the bottom of the car compared to the top. I’m guessing I have to modify the fragment shader, but I’m not sure what to change.
I’m not sure to understand what you mean by the ground color of the sky material? You can change the appearance of the sky material by modifying the different parameters of the material. This page can help you in this regard:
Do you mean the ground texture? I made that using Prototype Textures · Kenney, here’s the GLB. If you mean the whole setup, I can make a playground of that a bit later.
I think you will have to test different value for the sky material properties (see the doc page I linked) to try to find the ones that suit you the best.
I did try that, so unless I missed something, I don’t think that’s possible.
But I think I figured it out (will mark as solution when I test later). I’ll add another skybox with a dark color and a transparent top to get something like this.
let envColor = BABYLON.Color3.FromHexString([YOURHEX);
//get BackgroundPlaneMaterial
let backgroundPlaneMaterial = this.scene.getMaterialByName('BackgroundPlaneMaterial');
//set BackgroundPlaneMaterial to color
backgroundPlaneMaterial.primaryColor = envColor;
//set BackgroundPlaneMaterial to 100% alpha
backgroundPlaneMaterial.alpha = 1;
Here’s my usual constructor:
StartBabylon.prototype.initSkybox = function (){
this.mainColorboxHelper = this.scene.createDefaultEnvironment({
enableGroundShadow: true,
groundSize: 100,
createSkybox: true
});
this.mainColorboxHelper.setMainColor(BABYLON.Color3.White());
let groundplane = this.mainColorboxHelper.ground;
groundplane.isPickable = false; //otherwise objects get stuck under it
groundplane.position.y = -.01;
let skybox = this.mainColorboxHelper.skybox;
skybox.scaling = new BABYLON.Vector3(20, 20, 20); //make it bigger so not clipping the ground
skybox.isPickable = false;
//set scaling of BackgroundPlane
let backgroundPlane = this.scene.getMeshByName('BackgroundPlane');
backgroundPlane.scaling = new BABYLON.Vector3(3.2, 3.2, 3.2);
}
Here’s the playground (it’s a little post-process heavy and I couldn’t get the “groundbox” visible directly). The stuff relevant to this question is in the function setupSkybox. Control the sun’s position using 1 and 2.