Jump to content

Shadows still apears when object is under the ground


Recommended Posts

22 hours ago, CHIMAIRA said:

Hi everyone

Hi Chimaira... welcome to the forum, good to have you aboard.  (Just wanted to reciprocate your nice greeting.)

I'm not in agreement with these guys... claiming that bias is the solution, here.  (I've been known to be wrong quite often, though)  :)

If we push the ground into the shadowMap with that .004 bias, things REALLY go to hell.  :)

Something doesn't feel right with the framework, here, imho.  Granted, I don't use shadows very often, but NEEDING TO deal-with this micro-bias adjusting during scene assembly... would quickly turn-me-off to using shadows.  Our shadows system should be MUCH easier to deal-with.... than this.

If I make enemies of my heroes by saying this, that's tough.  I am going to hold my ground until proven wrong.  Never should a shadow be cast toward the light, and as far as I can tell, that is what is happening, a bit.  *shrug*  Throw stuff at me, at will, guys.  :)

Link to comment
Share on other sites


Our shadow system... has "range modes" I think. For example, 0-10 light->caster range, 10-100 range, 100-500 range, etc. 

Flying lights have a real issue, here, me thinks.  User would need to know WHEN a range-change happens, and then re-adjust .bias for each new automatic range-change?  (Wingy feels-for a tumor that could be forming on his forehead.) :)

Yeah, I can understand why auto-ranging a shadowGen might give best edge clarity/contrast, but, flying lights could be hell.  hmm.

Seems that there was a "needsUpdateEveryFrame" (or similar-named) property involved-in shadows or their lights... but I can't remember where that was, or if it is pertinent.  Perhaps shadowGenerator._light.needProjectionMatrixCompute(true)... but I see no changes in the above PG, when used.

Link to comment
Share on other sites

Just to bring more precision from the actual behavior, I would say shadow is like karma: http://www.keepcalmandposters.com/poster/5597154_keep_calm_because_karma_is_a_btch

Precision is an important part of it and there is no single method that works, but a bunch of different more or less adapted to your scene. To have an adaptative solution we are planing to integrate cascaded shadows at some point to help with bigger scenes.

In your particular case, you could make the point light act as a spot light in a self shadow like mode which should solve your issues a bit like this:




Link to comment
Share on other sites

5 hours ago, Wingnut said:

If we push the ground into the shadowMap with that .004 bias, things REALLY go to hell.  :)

Hi Wingnut , Sebavan , thank you both for your replies , really appreciate !

@Wingnut  , I was really optimistic untill I read your message . Then I ran testing the bias property on my real scene (diffrent sizes , moving light... ) ! and guess what :P? the result was catastrophestic .  "things REALLY go to hell." :wacko:

Worse then that , even by manipulating the light properties  , I can't get a satisfying result  and the shadow edges are disturbed with light animation with some aliasing .  really ugly .

I'm a little disappointed, that shadows have those  critical issues ! It should be simple to implement .

Plus ,  I don't know why  I can't find a shadows demo on the net which brings me some tricks to solve my problem . 

@Sebavan  I'll try your  suggestion too .  

2 hours ago, Sebavan said:



Link to comment
Share on other sites

Hi again.  So, what's happening here?  Are we all supposed to stay calm and hope this blows over and the issue is blown-off?  Is that what all this karma talk is all about?  Perhaps I don't understand what point is trying to be made.

Meantime, we have no pointLight sun or moon that can cross a scene from horizon-to-horizon, and do tolerable shadows along the way?

This seems like an important thing for many scenes.

@Sebavan - have you got some info on this issue... something that could be explained to less-than-genius folk like myself?  Is there some work I could do... to fix or minimize this issue?  Can you (or anyone else) steer the team in some direction that would be useful?  (thx)

Link to comment
Share on other sites


About the Karma, this was a failing humour tentative so I guess Karma is really... :-)

Else, about Shadows we have an amazing doc here for troubleshooting: http://doc.babylonjs.com/tutorials/shadows#troubleshooting

Also for finer grain details, you can have a look at this document detailing mostly all the artifacts and issues we might have: https://msdn.microsoft.com/en-us/library/windows/desktop/ee416324(v=vs.85).aspx?f=255&MSPPError=-2147217396

For larger scene we are planing to introduce cascaded shadow maps after 3.1 to help addressing precision issues where mostly needed.

Link to comment
Share on other sites

Thx!  From the MSDN article...

"Like shadow acne, Peter Panning is aggravated when there is insufficient precision in the depth buffer. Calculating tight near planes and far planes also helps avoid Peter Panning."

I think "Peter Panning" is what we are seeing in some of these playgrounds.  Sometimes, shadow is not connected to caster.  There is a gap between caster and shadow.

At other times, I think we see something that could be called "inverse Peter Panning"... where the shadow is SO "deeply attached" to the caster... that it is TOO near, and actually appears to cast a backwards shadow... toward the light.  Interesting.  Thanks for the links, and thanks for ALL your contribs, Sebavan!   (something like 156 git-commits to BJS -- outstanding!)

Link to comment
Share on other sites

  • 3 weeks later...

Hi friends , 

it's me again ,

I 'm really struggling with shadows, I have a scene that loads a couple of meshes from an obj file (generated with 3dsmax) .  

I wish to apply a "realistic" shadows on theme , I tried all things I "know" about babylons shadows, Activating blur,   Poisson Sampling, mixing params bias, deeling with kernel blur, shadow map size etc, with no success . :wacko:

The following zip file contains the scene files, ready to run . (I can't use the the playground because of the obj file.)


Please can someone give me an advise ? Thanks!:) 

Please have a look to screenshot : 

















Link to comment
Share on other sites

Hi guys.  Just bumping this up.  I think it would be useful if a few of our shadow experts... grabbed Chimaira's ZIP and gave it a test-drive... see if they can get scene shadows acting sanely.

And, I'm sort-of curious about possible improvements in shadows.. in WebGL 2. 

Chimaira... sorry for all the hassles.  If no shadow experts try your file, I soon will (though I am not very bright)  :) 

Ok, mission accomplished, so far (topic bump).

Link to comment
Share on other sites

Yep!  Well said, DK, or almost well said.  Chim has ALL objects coming from inside the myobj.obj file (which is inside his/her zippedScene.zip file).  Teapot, ground, cylinders, all if it.  No problems, but I wanted to point-out that they are all externally-modeled mesh.

I took it, I ran it.  It's got some serious jaggies... but...

Hey Shadow Experts...  can badly-aimed lighting normals on a heightMap ground... screw-up shadows cast UPON that ground?

I think the answer is no, but I'm not sure.  :)

I think it is important to do what Deltakosh states.  Do your best to make a playground that uses your createScene function from testa.html, and imports myobj.obj from a free github account (or some other CORs-clear hosting site). 

Testers, remember that myobj.obj contains at least 5 mesh, including ground/heightMap.

Okay, that's plenty of project for Chimaira for now.

How about a similar playground that... well... it's a mess.  hehe.  I found a CORS-clear Utah Teapot model in some stranger's GitHub folder... and I found some dynamic-generated Perlin-noise-driven heightMap code (probably from @jerome)... and I put it all in a garbage can and stirred-it-up with an outboard motor.  Look what I got...


Chimaira... WARNING.  It is a bad idea to use MY mess... as a shadow-testing playground, because mine doesn't use YOUR teapot, YOUR ground, or YOUR cylinders (which were likely made in a 3D modeler).  To REALLY test your issue properly, we need a playground with YOUR mesh... from myobj.obj.  I just made this substitute playground... because I was bored or something.  :)

Shadows in this substitute playground look fairly good.  A little greasy, maybe.  There's a seam on the back of the teapot that doesn't react well as shading passes over it.  There's also some problems around the teapot lid and pour-stem, too. 

There could be a minor modeling/normals issues at the top and bottom of the handle, too.  Not sure what the story is... on those.

Someone needs to erect some cylinders and set their shadows active.  It is something to play-with until Chim gets his/her playground working.

Chimaira... here's a few hints about what to do with your free Github account, should you decide to use THAT as a place to publish myobj.obj.  Look at MY free Github account... here.  Notice that I created a "repo" (repository) called misc.  Let's look inside it.  Notice that there is a file called "bjs_text.babylon".  Now let's go view the playground which loads that file...  here.  Notice the unusual domain/path in line 10.  https://cdn.rawgit.com/Wingnutt/misc/master/.

Perhaps these hints will "git" you rolling a bit faster.  Hope I've been helpful.  Talk soon.

Link to comment
Share on other sites

Hi, @Wingnut, @Deltakosh

Holly Sh*. I already have a github account (guess the name :P), and I did not noticed the possible "hot linking" files ! Thanks for the hint :D

So here we go with the playground : (I mean My playground with MY meshes and MY Metrics)  



In my humble opinion, I think that shadows are hard to configure with big meshes !


Link to comment
Share on other sites

Alright!  We're rockin'.  You made it look easy, Chimaira... thanks for making the PG! 

Now let's see what the shadow Gods can do with it. 

I'm going to go read that link that Sebavan gave us... so I can be occluded included in the advanced technical discussions that are sure to come soon.  :)  (oh goodie, eh?)

I cranked-up the shadow resolution (4096) and blindly set some various values in lines 36-43.  Looks a little nicer... but I turned-off some fancy blur stuff.  Experimenting.  :)

Link to comment
Share on other sites

Hi  :) @Wingnut, @Deltakosh

And as always,  thanks for replies  !

For my scene, I m trying to get a daylight lighting system. So the self-shadow  is quite important.  there is no self shadow, ( as Deltakosh mentioned) and the shadows style seems to comme  from  a candle and not a sun. 

I did not understand why the mesh wireframe appears here : 


For Wingnut instance , even with higher shadow resolution, we still see the shadow aliasing  , which is not okey for big scene. ( I tryed (8192 too, and got error for more bigger values).


And then, if you look from  the top you will notice that the teapot shadow is disappearing at some moment : 







Believe me, I don't want to bother you , You guys are doing a great job. I never knew a forum like this one. People are really taking time to help each other and solving theire issues . so BRAVO


See ya next time, 



Link to comment
Share on other sites

Shadows are not a simple beast as they really depend on your scene


So here are some suggestions:

- Read this and make sure to understand it: http://doc.babylonjs.com/babylon101/shadows#troubleshooting

- Try to reduce the size of your scene, to get good shadows the overall size of the scene should be kept under 100 so shadows can get enough precision

- Start with a simple scene (a plane and a teapot). Make sure that it works before adding more items. 

- Report here :)



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.

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.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...