Andrevv Posted April 30, 2017 Share Posted April 30, 2017 Hello everyone! This is my first question about my first babylon.js project. It will be a strategy game with complex economics (similar to Caesar 3, Knights and Merchants). The framework is amazing, I like it very much, but I have some problems with shadows. Everything works fine, until I add lots of instances of a mesh across a large ground. The shadow becomes just a blob, almost invisible. I think the problem comes from DirectionalLight.prototype.setShadowProjectionMatrix where all mesh positions are checked to see how big the area is for casting shadows. The bigger the area, the more detail will be lost. Can someone give me some advice on how to handle this problem? I thought of the following: 1. Increase the mapSize from 1024 to a much larger value, but it doesn't make much difference with 2048 and the fps drops very much. 2. Somehow force the shadow casting area to be smaller with the help of customProjectionMatrixBuilder, and make it follow the camera, but how? 3. Make the shadow part of the model, like an old-school circle shadow with transparency. Ugly, but at least I get 60 fps Any other idea may be helpful You can take a look at it if it helps: http://feszer.go.ro/babylon.js/1/ P.S. I know, that instances can't have different animations, I will handle that with separate clones for every action, I think Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 1, 2017 Share Posted May 1, 2017 Hello this is exactly the right analysis 1. This is an option. It could work to some extends. 2. This is my favorite. You can control the size of the shadowmap and not take in account all meshes if they are not visible. The center of the projection would be the camera area 3. Could work as a fallback Quote Link to comment Share on other sites More sharing options...
Tomm Huth Posted March 22, 2018 Share Posted March 22, 2018 @Deltakosh I'm having the same problem, and also though solution #2 would be good. But I have no idea how to calculate that. Any ideas on specifically how to do that? Quote Link to comment Share on other sites More sharing options...
Tomm Huth Posted March 22, 2018 Share Posted March 22, 2018 If I do light.setShadowProjectionMatrix(camera._projectionMatrix.clone()) I get: app.js:12432 Uncaught TypeError: Cannot read property 'length' of undefined at i../node_modules/babylonjs/babylon.js.i._setDefaultAutoExtendShadowProjectionMatrix (app.js:12432) at i../node_modules/babylonjs/babylon.js.i._setDefaultShadowProjectionMatrix (app.js:12432) at i../node_modules/babylonjs/babylon.js.i.setShadowProjectionMatrix (app.js:12432) But I have absolutely no idea what I'm doing. Haha. Quote Link to comment Share on other sites More sharing options...
Guest Posted March 23, 2018 Share Posted March 23, 2018 Hey! can you try to repro it in the playground? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.