When I run the project I get the following error:
material.js?0c4d:220 Uncaught (in promise) TypeError: this._scene.getEngine(…).createMaterialContext is not a function
at ShadowOnlyMaterial.Material (material.js?0c4d:220:1)
at ShadowOnlyMaterial.PushMaterial [as constructor] (pushMaterial.js?c0c1:12:1)
at new ShadowOnlyMaterial (shadowOnlyMaterial.js?9c5f:39:1)
When I check the engine I can not see any function “createMaterialContex”. The shadows of meshes on planes with StandardMaterial are working fine.
It might be a simple mistake I made. But what mistake?
Thanks a lot for help!
I thought it is a problem of versions. I installed 5.2.0 for core, materials and loaders. It still does not work.
Funny thing: in Playground with version 5.2.0 the code works fine and I noticed the BABYLON module has the function ShadowOnlyMaterial. On my own environment, same BABYLON version does not have that function. Is this a bug???
Interesting. I’m gonna bookmark this. From my understanding there was no ‘shadowOnlyMaterial’ as of now declared as a class of materials in the API. The BJS shadowOnlyMaterial is simply an extrapolation of the backgroundMaterial with nothing else than a shadowColor . I’d love to hear about the new class of shadowOnlyMaterial (if it exists)?…
Apologies, I didn’t realize the webpack and npm package part.
However, did you try import all materials and then use the shadowOnlyMaterial and it doesn’t work?
Since it appears there is no class in the API for the shadowOnlyMaterial I thought it must have been inheritated from the backgroundMaterial, though it might also have other dependencies.
Using the backgroundMaterial only for shadows will likely not work, although I’d like to try something and will let you know.
And then, Did you try with a legacy webpack (like 4.2.1)?
It appears the link shown in the doc to the material in github is broken. Files may have been moved or renamed.
Edit: may be @Evgeni_Popov can help you with this issue. Let’s see what he can tell you about it.
I did try with all materials from @babylonjs/materials imported, but did not change the result.
Originally I used Babylon 4.2. Then I changed to 5.2 hoping to solve the problem. Not sure if this might be also an issue, but my project is in Vue.js (webpack is under Vue).
I have some work-around for this shadow problem, but involves complex image projections, such as the shadow will fall onto a non-transparent plane. However, I would prefer the straightforward option. So I really appreciate your interest for this subject and I am looking forward to hear if there is some simpler solution.
(btw: I moved from Three.js to Babylon for many of its nice features. But this one - the shadow on a transparent plane - works like a charm in Three.js )
Yes @sebavan, you certainly explained it better than I did, but that was my thought. On the other hand, I’m not using webpacks
@Mircea_H I did try to twist a background or standard material to display shadows only, but had no luck with that. Definetely, the shadowOnlyMaterial would be the way to go - so I do hope someone in this forum will (soon) have the right answer for your issue.
Meanwhile, GL with your project and have a great WE,
At this stage, I can only advise to wait for the big brains and very dedicated people at BJS to have a closer look into this. This is simply beyond my expertise. I only quickly noticed that some fixes have been made for v5 to relink with materials. May be something is missing there for this special type of material, for the npm package or may be you are messing up something with the import. If it was me, I would rather continue working on other parts of the project and wait for an answer from the council @sebavan@RaananW . Shouldn’t be all too long…