Jump to content

Struggling with shadows from high-poly mesh


ozRocker
 Share

Recommended Posts

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.

 

Link to comment
Share on other sites

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 :-)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :)

 

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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?  

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

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

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