Jump to content

Change colour of shadow in shadow-only material?


MadeByJawns
 Share

Recommended Posts

Hey, is there any way to change the shadow colour when using the shadow-only material, apart from using shadowGenerator.setDarkness() ?

If not, I'm guessing maybe I'd need to try extend the shader to include emissive? is that right? or is there a different / easier way I can have a transparent mesh that displays colored shadows?

This is so I can have a model with a blueish shadow displayed on page and be able to change the background page colour without also having to then match up the colour of a plane in the scene.

Any pointers on how to begin would be great!

Link to comment
Share on other sites

Shadows are generating by masking the lights. They are not producing a color per se. They just block the light to add energy to the local mesh color.

So to produce colored shadow you will need to create your own shader that will compute the shadow level and will write the color you want accordingly

The idea would be to replace this line :

https://github.com/BabylonJS/Babylon.js/blob/master/materialsLibrary/src/shadowOnly/shadowOnly.fragment.fx#L49

by: vec4 color = myColor * clamp(shadow, 0., 1.);

 

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...