satguru Posted July 23, 2017 Share Posted July 23, 2017 I am loading a mesh from a babylon file The mesh has a skeleton. The shadow casted by it is not proper. See file "with_skel.jpg" to check the shadow casted. Now if i remove the skeleton by doing mesh.skeleton=null; The shadow is proper. See file "without_skel.jpg" I was able to reproduce the issue in playground but wasn't able to save the code. I got the error message "file too big" when trying to save. The code is a little large as it has an embedded scene file. So I have attached the code here. See file "playground_code,txt" Copy the code to playground to check. comment on/off line 44 to see the issue playground_code.txt Quote Link to comment Share on other sites More sharing options...
satguru Posted July 23, 2017 Author Share Posted July 23, 2017 If it helps, this problem started due to some code change after 06/19/2017. I have a babylon.js file from that day and it works fine. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 24, 2017 Share Posted July 24, 2017 Do you have the .max version? it could be great to do a diff. So far if I cancel bones in the shader it works so I was first thinking about an issue with the bones data (and it works for the dude: https://www.babylonjs-playground.com/#07IG98#0) Edit: Ok this is a precision issue due to the fact we are now using half float Add this in your code should work: shadowGenerator.bias = -0.3; Quote Link to comment Share on other sites More sharing options...
satguru Posted July 24, 2017 Author Share Posted July 24, 2017 @Deltakosh Yes " shadowGenerator.bias = -0.3;" works. is setting shadowGenerator.bias to a negative value "normal" ? or is this a workaround? what is it in the skeleton which results in this? Can I set the bones differently? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 24, 2017 Share Posted July 24, 2017 setting bias (positive or negative) is fairly normal I'm just a bit concerned by why your skeleton needs this. I don't know regarding Blender. Perhaps @gryff can help providing guidance on this topic Quote Link to comment Share on other sites More sharing options...
gryff Posted July 25, 2017 Share Posted July 25, 2017 @Deltakosh and @satguru : as I don't have any experience with using shadows with animated figures, the only thought I have is about the figure. Is it a single mesh or multiple separate meshes attached to the skeleton? cheers, gryff Quote Link to comment Share on other sites More sharing options...
satguru Posted July 25, 2017 Author Share Posted July 25, 2017 @gryff It's a single mesh. Attached is the blend file, if it helps. vincent.blend Quote Link to comment Share on other sites More sharing options...
gryff Posted July 26, 2017 Share Posted July 26, 2017 @satguru : Ok I have the file and will have a look at it on Thursday. Right now, I'm entertaining my daughters and my first grand-daughter until Thursday. cheers, gryff Quote Link to comment Share on other sites More sharing options...
satguru Posted July 26, 2017 Author Share Posted July 26, 2017 @gryff Sure. No hurry. Setting "shadowGenerator.bias = -0.3" solves my problem for now. I will also keep looking. Thx Quote Link to comment Share on other sites More sharing options...
gryff Posted July 27, 2017 Share Posted July 27, 2017 On 2017-07-24 at 6:14 PM, Deltakosh said: I don't know regarding Blender. Perhaps @gryff can help providing guidance on this topic Well @satguru and @Deltakosh : I took a look at your Vincent character and export from Blender. I made two basic changes to the file: 1. changed the point tlight to a directional light (Sun) and moved the lamp directly behind the figure. 2. added a ground plane set to receive shadows. Then exported to a .babylon file with various shadow generating options for the lamp that were default option settings (apart from the shadow map size which I increased to 1024 px.) Results in image below with the following shadow map setting: 1. Standard 2. Poisson 3. Blur ESM All exports produced shadows as I expected - look closely and 3 is smoother that 1. So I did not see the issues that you are having with the presence of the skeleton.And I did not change the bias setting from the default value of the exporter. Not sure if that helps - but the export from Blender appears fine. cheers, gryff Quote Link to comment Share on other sites More sharing options...
gryff Posted July 27, 2017 Share Posted July 27, 2017 @satguru and @Deltakosh - hold up on the above post. I have managed to produce weird shadows examples below - but first some details. 1. Vincent - Blender Exporter v5.4, BJS is "babylon.3.0.js" that i downloaded May 6th 2017. 2. Vincent - Blender Exporter v5.4, BJS is "babylon.3.0.js" that I downloaded today Result with BJS 3.1-alpha is the same as 2. So it looks like something happened to the BJS code between May 6th and today that is causing the issue. Is it something in @JCPalmer 's Exporter (I just used the standard settings apart from Shadow Map size) or is it an issue with BJS ? I suspect the latter as @satguru 's code above appears to be adding the shadow stuff in code. cheers, gryff EDIT:Actually, I uploaded the wrong "Vincent" .babylon file - one made with Blender Exporter v5.3. I have uploaded the correct "Vincent" file now with the bias set to -.0.3. No shadows for either one. I also now see that @satguru says above that it worked for a version of BJS from 06/19/2017. - so mid June. Code from the v5.4 of the exporter with the shadow info for the light "producer":{"name":"Blender","version":"2.76 (sub 0)","exporter_version":"5.4.0","file":"vincent2.babylon"}, ----------- "lights":[{"name":"Lamp","id":"Lamp","type":1,"position":[0,5.9039,3.1566], "direction":[-0.0029,-0.7947,-0.607],"intensity":1,"diffuse":[1,1,1],"specular":[1,1,1]}], "shadowGenerators":[{"mapSize":1024,"lightId":"Lamp","bias":-0.02995, "darkness":1,"useBlurExponentialShadowMap":true,"blurScale":2,"blurBoxOffset":0, "renderList":["Vincent"]}] Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted July 27, 2017 Share Posted July 27, 2017 I recently made a scene with a mesh which cast shadows from Blender which also has a skeleton. I exported in Javascript format, not .babylon though. I also defaulted on bias, and used ShadowOnlyMaterial, code here. Also because I had a light attached to the camera, and the camera moved, I use a separate light for shadows with intensity = 0. I had the shadow Light, shadow generator, and ShadowOnlyMaterial outside of Blender. Weird things happened during dev. Think it was my code, not ToB. Quote Link to comment Share on other sites More sharing options...
gryff Posted July 27, 2017 Share Posted July 27, 2017 And just to add to the picture 3. Vincent Blender Exporter v5.3, "babylon.3.0.js" that i downloaded May 6th 2017. 4. Vincent Blender Exporter v5.3, BJS is "babylon.3.0.js" that I downloaded today Only options 1 and 3 work as I expected with 1 and 2 giving no shadows, and 4 something like the results @satguru shows above. (see post below about "darkness") {"producer":{"name":"Blender","version":"2.76 (sub 0)","exporter_version":"5.3-beta","file":"vincent2.babylon"}, ------- "lights":[{"name":"Lamp","id":"Lamp","type":1,"position":[0,5.9039,3.1566],"direction":[-0.0029,-0.7947,-0.607],"intensity":1,"diffuse":[1,1,1],"specular":[1,1,1]}], "shadowGenerators":[{"mapSize":1024,"lightId":"Lamp","bias":0, "useBlurExponentialShadowMap":true,"blurScale":2, "blurBoxOffset":0,"renderList":["Vincent"]}] Quote Link to comment Share on other sites More sharing options...
satguru Posted July 27, 2017 Author Share Posted July 27, 2017 @gryff Please note I am only loading the mesh and skeleton from the file created by the Blender exporter. I am using the "BABYLON.SceneLoader.ImportMesh(..)" function rather than "BABYLON.SceneLoader.Load(..)" or "BABYLON.SceneLoader.Append(..)". In other words I am ignoring lights, shadow setting etc in the file. Light and shadows are being set in the code. Quote Link to comment Share on other sites More sharing options...
gryff Posted July 27, 2017 Share Posted July 27, 2017 @satguru Yes I noted that above 4 hours ago, gryff said: I suspect the latter as @satguru 's code above appears to be adding the shadow stuff in code. and it is not working properly with Blender exporter either. And I'm no coder, so it is best not to confuse the issue with any of my code !! I figured out why examples 1 and 2 above throw no shadow - the darkness variable has to be set to 0. It then gives the same results as examples 3 and 4. To me, not a very intuitive way to assign a value to the amount of darkness When I do that examples 1 and 2 give the same results as examples 3 and 4. Options 1 and 3 work as expected - using a version of BJS v3.0 that is about a couple of months old. The latest stable version produces that weird shadow as does the current alpha version. and changing the bias value does not seem to help. Changing the bias value does help - I had changed it to -0.03 not 0.3 as @Deltakosh had suggested. I have absolutely no idea what this parameter means - and how you might go about setting the correct value for a given situation cheers gryff Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 28, 2017 Share Posted July 28, 2017 Ok thanks to @gryff investigation, this is now sure: it is a bug! Let me fix it Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 28, 2017 Share Posted July 28, 2017 It should be fixed now gryff 1 Quote Link to comment Share on other sites More sharing options...
satguru Posted July 28, 2017 Author Share Posted July 28, 2017 @Deltakosh, Yes it works now. Thanks for the fix @gryff, Thanks for the troubleshooting. 19 hours ago, JCPalmer said: I recently made a scene with a mesh which cast shadows from Blender which also has a skeleton. @JCPalmer Impressive demo. Was a bit hesitant to click on the link when I read it though, being in office and all. Quote Link to comment Share on other sites More sharing options...
gryff Posted July 28, 2017 Share Posted July 28, 2017 12 hours ago, Deltakosh said: It should be fixed now Yes indeed . Good work @Deltakosh And here is an up to date demo with looping animation of mesh and shadow. Vincent Exported from Blender ( Exporter v5.4) using BJS.3.1-alpha (downloaded this morning) Blender settings from the default for the shadow export is in image below. Only changes from the default settings: Map Size:1024, Shadow Darkness 0.5 (gives a grey shadow but you can set it to 0 for black). Hope my investigations did not appear too chaotic - but two daughters and a grand-daughter and two dogs can make things a little crazy cheers, gryff GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
satguru Posted August 5, 2017 Author Share Posted August 5, 2017 @Deltakosh @gryff we have another problem now. during animation the mesh is distorted See file "latest_anim.jpg" to see how the mesh looks in playground with the latest version of bablylonjs See file "stable_anim.jpg" to see how the mesh looks in playground with the stable version of bablylonjs The code is again "playground_code.txt" The code is same as before except for the following new line at line number 46 mesh.skeleton.beginAnimation("walk",true); playground_code.txt Quote Link to comment Share on other sites More sharing options...
Dad72 Posted August 5, 2017 Share Posted August 5, 2017 This kind of mesh deformation problem is often because all the mesh is not properly bind to the skeleton. If there is a point that is not taken into account, this create this problem that I regularly had and correct by adjusting this with 3ds max. I have a character model with 40 animations or all points are well link to the skeleton and no deformation to notice. Quote Link to comment Share on other sites More sharing options...
satguru Posted August 5, 2017 Author Share Posted August 5, 2017 @Dad72 I do not think the problem is with bind. Animation works fine with bjs 3.0 but not with the 3.1 alpha Quote Link to comment Share on other sites More sharing options...
Dad72 Posted August 6, 2017 Share Posted August 6, 2017 Ah, ok, I did not check with version 3.1. Quote Link to comment Share on other sites More sharing options...
gryff Posted August 6, 2017 Share Posted August 6, 2017 23 hours ago, satguru said: Animation works fine with bjs 3.0 but not with the 3.1 alpha @satguru and @Deltakosh : hmm the version I posted above Vincent uses BJS 3.1 that I downloaded about a week ago. So maybe changes since then ?? cheers, gryff Quote Link to comment Share on other sites More sharing options...
Dad72 Posted August 6, 2017 Share Posted August 6, 2017 I just tested my character that worked very well. But this is not working properly. (whith 3.1) My character is completely distorted with the animations, which was not the case before. 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.