spritefire Posted January 30, 2015 Share Posted January 30, 2015 I think what he is after is the same mesh casting shadows on itself and also the ground?ie a high poly tree with branches on it (all the one mesh) and the branches casting shadows on the trunk and also the ground.Where as the example of the engine is built up with a number of different meshes, so one mesh is casting a shadow onto a different mesh. Quote Link to comment Share on other sites More sharing options...
RaananW Posted January 30, 2015 Share Posted January 30, 2015 I know, but in a case of a very complex mesh it is possible that the mesh itself somehow causes this. This is why he created this simple scene with a relatively complex sphere mesh (not created by babylon JS) to check if it is working. Now that this scene is working, he can start adding different meshes and test them. He then can add new meshes that might cast shadows on themselves (as a sphere is not the best example for that) and see how it goes. Would be very interesting to see if it works :-) Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 30, 2015 Share Posted January 30, 2015 For objects that are sub-objects, you must do so : for(var i = 0; i < NewMeshes.getChildren().length - 1; i++) { shadowGenerator.getShadowMap().renderList.push(NewMeshes.getChildren()[i]); } Quote Link to comment Share on other sites More sharing options...
ozRocker Posted January 30, 2015 Author Share Posted January 30, 2015 Silly me! I forgot to add the sphere to the shadow map. Thank you for pointing that out RaananW Actually, when I was adding that object to the shadow map I realised that my model of the guy consisted of 6 meshes and I was only adding 1 of them to the shadow map. I have now entered all 6 and the shadow on the ground looks good! YAY! You can see it here http://www.punkoffice.com/babylon/luke_anim.html The weird thing is babylon.2.0-beta.debug.js will screw up my armature as you can see in the link above. It looks like the animation is inverted. If I use babylon.1.14.js the animation is right but I don't get any shadows. I still need to check that the shadows received by the guy will come out properly. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 30, 2015 Share Posted January 30, 2015 I think that Gryff our master of Blender can help you for this one Quote Link to comment Share on other sites More sharing options...
gryff Posted January 31, 2015 Share Posted January 31, 2015 I spent several hours this morning using ozrocker's blend file from his previous thread. This is the best I can do: Player 2 Details: 1. Blender 2.73 with latest exporter. I redid the animation/rigging using the method I described in that previous thread.2. Light : Sun Lamp. Shadows set up in the Blender exporter - Map Size: 4096, Map Type: Variance.3. Added purple ground for DK. The ground receives shadows, figure casts shadows.4. Reduced the animation to just the "press up" part - to reduce file size and exporting time.4. I am using babylon.2.0-beta.js that I downloaded from Github this morning I seems to work pretty well. However, older versions of babylon.2.0-beta.js - from 9 days ago - produced the the kind of weird animation that ozrocker is seeing. I know amorgan was having issues with an animation and some changes were made which I assume are reflected in this latest version of BJS 2. That is the best I can do. cheers, gryff GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
ozRocker Posted February 1, 2015 Author Share Posted February 1, 2015 sweet, thanks Gryff! The new babylon.2.0-beta.js fixed up the animation. What I've done is reduce my figure to 2,000 polys to make things simpler. I've set everything up as per your instructions. The texture looks normal if the figure doesn't receive shadows, but when I set it to receive shadows its all practically black. It appears as if its receiving a shadow from something up above it. http://www.punkoffice.com/babylon/luke_anim.html Quote Link to comment Share on other sites More sharing options...
gryff Posted February 1, 2015 Share Posted February 1, 2015 It appears as if its receiving a shadow from something up above it. In my experiments yesterday, I played with having the figure receive shadows too - and I got a the same result. To me it looks like the map is created and the same map is applied to the figure and darkens the whole figure. Almost like a second map is needed for the figure. But as I've said before, I'm no expert on the ins and outs of this shadow stuff. And I still think you should maybe think of using the retopology tool in ZBrush - if for no other reason than it seems to allow you to retain edge flow which decimation does not. And I also gather with that retopology tool you can protect certain areas. cheers, gryff Quote Link to comment Share on other sites More sharing options...
ozRocker Posted February 1, 2015 Author Share Posted February 1, 2015 Thanks for your help and your patience gryff. Much appreciated mate! I can actually dynamesh (the ZBrush re-topologiser that I use) down to a different polycount. I'll have a play with that when I can. The reason I've been using dynamesh then also the decimate tool was cos that's the process Lee from Infinite Realities use. He's considered the Master of multi-cam photogrammetry but he confesses he is no ZBrush expert himself (http://www.triplegangers.com/index.php/blog/cat/tutorials/post/tutorial-series-part03-01/) So it looks like you can only have one object receiving shadows in babylon.js. I suppose all the demos are using just the ground to receive shadows. Can anyone confirm this? Quote Link to comment Share on other sites More sharing options...
RaananW Posted February 1, 2015 Share Posted February 1, 2015 Putting an object in the shadow map list and at the same time setting it to receive shadows will cause this object to receive its own shadow, hence the darkened object. I am not sure what can be done to avoid it, other than setting a shadow generator to each of the objects that should receive shadow without them in the list. I'm pretty sure this is amazingly bad for performance, and not quite sure if it'll actually work (if the architecture allows it) Quote Link to comment Share on other sites More sharing options...
ozRocker Posted February 1, 2015 Author Share Posted February 1, 2015 the webGL demo that I exported from Unity5 is able to run quite smoothly on my Surface Pro with a 100k mesh thats casting and receiving shadows http://www.punkoffice.com/luke/ Objects casting shadows on themselves is a common occurrence with meshes that have protruding arms such as trees, characters, animals, planes, tanks. Maybe it'll happen in the next version of babylon.js Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 1, 2015 Share Posted February 1, 2015 There is no limit to the number of objects receiving shadows.Self shadowing is also supported but tweaks may be required Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 1, 2015 Share Posted February 1, 2015 If you can repro the issue with self shadowing on the playground, I promise to try to fix it:) Quote Link to comment Share on other sites More sharing options...
ozRocker Posted February 1, 2015 Author Share Posted February 1, 2015 I've edited the shadows demo in the playground so that the torus also receives shadows. http://www.babylonjs-playground.com/#2GVV5T You can see it reacting strangely in that example. Quote Link to comment Share on other sites More sharing options...
iiceman Posted February 1, 2015 Share Posted February 1, 2015 Could it be that the light is just not set up right? I edit your example (removed one of the lights and move the other one a bit): http://www.babylonjs-playground.com/#2GVV5T#1 Looks better, right? Have you tired different light positions with your luke-mesh? Quote Link to comment Share on other sites More sharing options...
ozRocker Posted February 2, 2015 Author Share Posted February 2, 2015 yes, I've tried different light positions for the luke mesh. However, there should never be a case where a shadow has completely covered the whole mesh since the only object casting shadows is the mesh itself. I'll come up with a clearer playground example to illustrate the point more Quote Link to comment Share on other sites More sharing options...
ozRocker Posted February 2, 2015 Author Share Posted February 2, 2015 here is a clearer example http://www.babylonjs-playground.com/#1NTVZU its just one object casting and receiving shadows Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted February 2, 2015 Share Posted February 2, 2015 But since you're moving the light at runtime, you also need to change light's direction at run time (I know this is a bit boring, but it's directionnal light and shadow map need a direction and "a point of view") http://www.babylonjs-playground.com/#1NTVZU#3 Quote Link to comment Share on other sites More sharing options...
RaananW Posted February 2, 2015 Share Posted February 2, 2015 that didn't solve the darkened object problem. I guess it is expected that the jaw, for example, would cast a shadow on the inner part. but be fully lit. Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted February 2, 2015 Share Posted February 2, 2015 (but that doesn't change the fact that shadows shouldn't darken the whole object like that, since light's point of view is always the camera and the "light's target" is the skull, the skull should be brightly lighted in front of us I think) Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted February 2, 2015 Share Posted February 2, 2015 Yes RaananW, same time Quote Link to comment Share on other sites More sharing options...
iiceman Posted February 2, 2015 Share Posted February 2, 2015 http://www.babylonjs-playground.com/#1NTVZU#5 fixed I still think it is about the light's position... for me it seems like the camera is actually casting a shadow on the object and not the object itself... you know what I mean? Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted February 2, 2015 Share Posted February 2, 2015 hmmm, I bet that cameras are not rendered as real solid mesh... they can't cast shadow Quote Link to comment Share on other sites More sharing options...
Vousk-prod. Posted February 2, 2015 Share Posted February 2, 2015 Nevertheless, with this example it's very difficult to get exactly what happen, because this skull has some colors and lighting directly baked in the vertex color, so its self baked shadows are pretty deceptive to get the complete impact of shadowGenerator Quote Link to comment Share on other sites More sharing options...
RaananW Posted February 2, 2015 Share Posted February 2, 2015 Nothing's better than a knot to test this - http://www.babylonjs-playground.com/#OPL98Both objects receive shadows (ground is only there to make sure the shadow works). 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.