Jump to content

gradientMaterial not working with DirectionnalLight


pichou
 Share

Recommended Posts

Hey Guys I have an issue with gradientMaterial.

Here is a basic playground where everything is fine : https://www.babylonjs-playground.com/#2IFRKC#8

If I use a DirectionalLight instead of HemisphericLight, the material become much darker and the gradient is already almost not visible : https://www.babylonjs-playground.com/#2IFRKC#9

And if I change the sphere for a plane or a cylinder, the gradientMaterial become only dark : https://www.babylonjs-playground.com/#2IFRKC#10

Does this mean we can't use gradientMaterial with directionalLight?

Thanks Pichou

Link to comment
Share on other sites

When you remove the hemispheric light ground color (the light coming from the sky "reflected" by the ground), your object is also darker, what is normal : https://www.babylonjs-playground.com/#2IFRKC#11

Now, let's give some z-value to your directionalLight : https://www.babylonjs-playground.com/#2IFRKC#12 and the object is lighter

So everything depends on where you put the lights knowing they all behave differently.

You could also use a point light always set at the camera position : https://www.babylonjs-playground.com/#2IFRKC#13

Link to comment
Share on other sites

OK thanks @jerome for this explanation. This is just a matter of shadow and light direction/position then.

For your information in my scene I just add an hemispheric light that is opposite to my directionalLight so that the right color appears on the gradientMaterial I use.

Cheers, Pichou

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...