Jump to content

Shadows Suddenly Vanish


Borislav
 Share

Recommended Posts

I didn't even touch anything in the lines about the shadows, but they vanish?

Is that an update?

Legend

  • Char = The Character
  • Sphere = A Floating Sphere
  • Ground The ground

The shadow code:

shadowGenerator.getShadowMap().renderList.push(char);
shadowGenerator.useVarianceShadowMap = true;
    shadowGenerator.useBlurExponentialShadowMap = true;
                 
	shadowGenerator.setDarkness(0.5);
        
       var shadowGenerator = new BABYLON.ShadowGenerator(1024, light)
        
	shadowGenerator.getShadowMap().renderList.push(sphere);
shadowGenerator.useVarianceShadowMap = true;
    shadowGenerator.useBlurExponentialShadowMap = true;
                   shadowGenerator.bias - 1;
	shadowGenerator.setDarkness(0.5);
	ground.receiveShadows = true;
                
        
        return scene;
        };

http://cityworld.16mb.com/levels/1/play/

Link to comment
Share on other sites

4 hours ago, Borislav said:

shadowGenerator.bias - 1;

Hi B!  That line looks strange.  Are you sure you have entered that line correctly?  What happens when you remove it?  Anything good?

There HAS BEEN recent changes/improvements to shadows, so there COULD be a bug, but it is difficult to troubleshoot without having a playground scene that shows the issue.

Can you reproduce the problem... by using the BabylonJS Playground app http://playground.babylonjs.com?  That would be nice. 

You can simply paste-in most of the code... from your project.  You can use a basic cylinder instead of importing a player model into the playground.  Do your best, thx.

Link to comment
Share on other sites

22 hours ago, Wingnut said:

Hi B!  That line looks strange.  Are you sure you have entered that line correctly?  What happens when you remove it?  Anything good?

There HAS BEEN recent changes/improvements to shadows, so there COULD be a bug, but it is difficult to troubleshoot without having a playground scene that shows the issue.

Can you reproduce the problem... by using the BabylonJS Playground app http://playground.babylonjs.com?  That would be nice. 

You can simply paste-in most of the code... from your project.  You can use a basic cylinder instead of importing a player model into the playground.  Do your best, thx.

I removed it, didn't work.

This is the playground:

https://www.babylonjs-playground.com/#YG6CNL

 

replaced mesh with a skull

Link to comment
Share on other sites

23 hours ago, Wingnut said:

Hi B!  That line looks strange.  Are you sure you have entered that line correctly?  What happens when you remove it?  Anything good?

There HAS BEEN recent changes/improvements to shadows, so there COULD be a bug, but it is difficult to troubleshoot without having a playground scene that shows the issue.

Can you reproduce the problem... by using the BabylonJS Playground app http://playground.babylonjs.com?  That would be nice. 

You can simply paste-in most of the code... from your project.  You can use a basic cylinder instead of importing a player model into the playground.  Do your best, thx.

The = is missing :/

Link to comment
Share on other sites

28 minutes ago, Wingnut said:

:)

https://www.babylonjs-playground.com/#YG6CNL#1

I'm working on the PG a bit.  I did a little cleanup/adjusting... not much change.

I haven't figured-out why the shadows are failing, but I'll keep testing, and others may join-in.

Thx for making this playground, well done.  It makes testing easier for everyone.

It also happened with the one I didn't even change at all but the shadows vanished.

http://www.cityworld.16mb.com/levels/2/play

http://www.babylonjs-playground.com/#R1F1A0

Link to comment
Share on other sites

1 hour ago, Wingnut said:

:)

https://www.babylonjs-playground.com/#YG6CNL#1

I'm working on the PG a bit.  I did a little cleanup/adjusting... not much change.

I haven't figured-out why the shadows are failing, but I'll keep testing, and others may join-in.

Thx for making this playground, well done.  It makes testing easier for everyone.

I found the solution, you need to make the variance AFTER the exponential not before.

Link to comment
Share on other sites

But, aren't you getting warnings about "variance has been replaced with exponential" in the console?

Hmm.  I thought I had a working version for my #2 playground, but I discovered I was using 2.5... so never mind.

Still working on playground.  I will test your theory in a moment.  :)

Update:  [link #3]  'blur exponential' seems broken. (lines 146-150 area)

Non-blur seems ok, but not the 'blur' version.  Still learning.  Possible bug.  Perhaps pointLights can't do blur?  Nah, that's not the problem.  There's still a Wingnut mistake here, somewhere, I just know it. 

Link to comment
Share on other sites

Update:  [link #5] - MUCH simpler playground.  Activate line 29, shadow gone.  hmm.

So... um... blurExp shadowGen using pointLight...  fails to cast shadows on textured grounds. 

Stated correctly?   Phew. I spit and drooled a little bit... trying to speak that sentence.  :D

Link to comment
Share on other sites

I got the same problem after upgrading to 3.0. I can't go back since I already commited using the Babylon.GUI for my project. The shadow generator just suddenly does not working properly anymore. Instead of consistent shadows, it only works on part of the map and the shadow is missing bits and pieces. Unfortunately I can't provide an example since my project is procedural generated from a blender map. All I know is that if I open the Texture tabs on the Debug Layer and click on the generator it will produce an error on the console. :( 

@Wingnut I got the exact prolem but with Directional Light instead, it's kinda like this: https://www.babylonjs-playground.com/index.html#YG6CNL#6 (I took your playground and changed it a bit)

Link to comment
Share on other sites

Hi Lynx! 

In that playground, your light is positioned at 0, 0, 0, aiming straight down.  This is ok when NOT using a shadowGenerator, but when using shadows, the shadowMap is derived based-upon light.position.  Your light was not above the sphere.

https://www.babylonjs-playground.com/index.html#YG6CNL#7

See line 11.

With directionalLight shadows, I always do 2 things.  First, position the light somewhere above the wanted target... and then light.setDirectionToTarget(someMesh.position).  But that's me. 

Main thing, you must get dirLights up in the air and wisely aimed... because the light position is being used (like a camera) to determine the shadowMap (I hear). 

Take note that direction vector3's are not the same as position vector3's.  Direction vectors are much more difficult to determine... especially for geometry-impaired noobs like me.  That is why I so-love late-in-the-code light.setDirectionToTarget(someMesh.position).  It is my friend.  :)  Works great for spotlights, too.  When put inside renderLoops, it keeps makes a spotlight "track" a moving mesh (line 70).

Hops this helps.

Link to comment
Share on other sites

Hi Wingnut!

Thanks for you answer, I kinda understand it now. In 2.5, the position of the directional light doesn't matter but it does in 3.0.

Though that still doesn't solve the shadow problems in my projects. Here is a picture: 

-Left is 3.0, right is 2.5. The shadow in 2.5 although blocky (due to the large map) but still functional. But with the same code, the shadow gets glitchy in 3.0 (only some parts of the model has shadow). Moreso, the shadow map seems like it only appear in a certain area (appear in a straight line)

shadow-glitch.jpg.94f39c77611460b92d001ba6ac68ede4.jpg

-Here is more of the bugged shadow in 3.0: the left one is in a normal area, the right one is where the line of the shadow map lies. If I go a little to the right the shadow will disappear.

shadow-glitch-2.jpg.453d385d144e1f6dacbf3cd484a9ed3c.jpg

Link to comment
Share on other sites

Ahh, ratty shadows.  "acne".  Thx for the pics.

um... which type of shadow are you using?  BlurEponential?  Or, default settings?  Have you tried all the different types, from the docs?

There are some "tweaks" listed in the Shadows Documentation.  Have you tried a few of those?  .bias is a good one.

Keep experimenting... and try all the adjustments.  I have had similar problems, but beat them... with adjustments.  But I must re-iterate that keeping the dirLight ALWAYS aimed directly at the player... will result in the BEST shadow clarity.  Think about distance from light to player, and notice the minZ and maxZ comments in the docs.

I think it would be wise for you to put a dirLight.setDirectionToTarget(player.position) inside your renderLoop, if you can.

Do your best.  It is difficult for me to help...when there is no playground example.  So, for now, I will tell you what I would try.... if I were you.  Likely, we will have more shadow experts here, tomorrow.  They are all waterskiing right now.  :)

Link to comment
Share on other sites

Hey Wingnut!

Thanks for your suggestion. I did tweak some of the number, I don't get this weird line anymore and the shadow are more consistent. Though my acne problems just won't go away.  Changing the minZ maxZ and depth scale does make it less acne but the the shadow feels less accurate. Anyhow, I need to work on other parts of this project while waiting if there is more answer to this particular problem, I'm an easily irritated person if something doesn't go my way and I would be obsessed with fixing it. :wacko:

acne.png.b6378a9cbfd1b5652edfce8bdeaa2d2e.png

Link to comment
Share on other sites

Good tests, @Lynxerious!  You are on the trail to success.

I have also told the two top-dog framework coders that have made recent mods to shadows... about this thread.  They are both upper-level programmers at Microsoft, so they are very busy, yet they are extremely kind and will take some time to look-at this issue.  Pretty cool of them, eh?  You haven't shown any dismay with us (thx), but just for kicks... here's a little more background and insight...

BabylonJS is not affiliated with Microsoft in any way, but I wanted you to think about HOW BUSY their jobs/lives are.  It is truly a miracle that these two guys had ANY time to improve our shadow generators.  Yet they did... and without irritation.  Pure love of the tech.

They will thank you profusely... if you found a framework/shadows bug, or found an issue that isn't covered by the shadow docs.  And, they will forgive you if you haven't read the docs thoroughly.  Sebavan and Deltakosh both give 120%... and that's something you should cherish and hold in high-esteem, in my opinion.  They're great guys, with great brains and hearts.

All the helpers on this forum... are volunteers, not paid.  We answer hundreds of questions... many of them are repeats, and many are answerable if folks would read the docs carefully.  We forum helpers rarely get to work on personal projects.  It is a good thing that we are caring, patient, and emotionally level-headed, right?

You don't HAVE TO wait, of course. You can continue studying and experimenting.  It's only JS and webGL, not neuro-surgery.  Nothing would be irritating about that, unless you make yourself angry when you learn things, right? ;)  And learning always goes "your way", because you are the one doing it for yourself, yes? 

You didn't answer which type of shadows you are using.  Why is it taking you so long to answer that question, playground-less one?  That's pretty irritating.  :D  (nah, not at all, but I thought I could maybe make you laugh a little, about it)  heh

Did you try "poisson" shadows?  Did you try both exponential and blurExponential?  Did you try rubbing a magic teapot mesh... to get the webGL genie to appear, and grant 3 bug fixes in your code caused by you and only you?  :)

okay, okay, I'll stop trying comedy for now, but if I sense you getting irritated over this brand new, constantly-evolving, bleeding-edge tech... I'm going to try to make you smile again.  I'm just that way. 

WebGL is a friggin' miracle and it is one of the most empowering and enjoyable hobbies in my life.  I enjoy a challenging bug-chase, and I enjoy the company and knowledge of others... when we team-up for a bug-chase.   I hope you can enjoy webGL in a similar way, someday.

I will always try my best to make people enjoy BabylonJS, but I won't skip a meal for anyone.  :D

Link to comment
Share on other sites

Hi @Wingnut!

Thanks for your insight. I apologize for using the word irritated unknowingly (I'm not a native English speaker). I should clarify that what I meant on "irritated" was to myself since I didn't spend my time properly on the project and it's about to due.

I know I sounded like some whining kids who waiting for the plate to be filled with food. I did try a lot of different way in the Shadows doc but it's the best I can do for now, I will look into the code if I can. 

I'm not irritated about BabylonJs or any of the developers, I know people work so hard for it. Sorry for being vague and leading to misunderstanding.

Link to comment
Share on other sites

Deltakosh... two subjects are in this thread.

Borislav issue is first... https://www.babylonjs-playground.com/#YG6CNL#5

Shadow disappears when line 29 texture activated.

================================

Lynxerious arrived later, with "acne" issue, and yes, it would be nice to have playground for Lynx issue, and perhaps branch to new thread.

Ok, that is all.  :)

Link to comment
Share on other sites

Hi @Deltakosh

I don't know how I would reprod my acne problem exactly but I has created a workaround for my project. I make some tests though:

1. I tried to reprod it on playground but I ran into this problem instead and wonder if this is a bug? The mesh of the guy doesn't show shadow:

http://www.babylonjs-playground.com/#1EVNNB#92

 

2. About the problem with shadow disappear if past a certain place. I made this scene with Blender and use the exporter to create the .babylon scene. You could test it with the sandbox.

- In the standard.babylon, the Sun Lamp (directional light) has a standard shadow generator and all the trees have shadows (the same with Poisson).

- In the esm.babylon, the Sun Lamp has a ESM shadow generator and only half the trees show shadows (the same with Blur ESM)

- In the esm-sunlightPos.babylon, it's the same with esm.babylon except I change the position of the Sun Lamp . (pic related). And the shadows of the trees change position and one has acne. This could relate to my acne problem before.

 sunligh.thumb.jpg.8d9a02fd82b89730f0dc8573c1b3c44b.jpg

-In the poisson-sunlightPos.babylon, the Sun is in the new position like the esm-sunlightPos. All the trees have shadows but one of them has acne.

PIC RESULTS:

trees.thumb.jpg.4d1f52fdba47f3241e614f916f027f8a.jpg
I included the blend file too if you want to check it out. I don't think this is the exporter problems since the acne problem and the missing shadow problem appears on my project which have code-generated light and shadow too.

Thank you for reading. :D 

esm.babylon

standard.babylon

esm-sunlightPos.babylon

poisson-sunlightPos.babylon

test1.blend

Link to comment
Share on other sites

Hello!

So you cannot add objects to the shadowmap on EVERY frame :)  This will destroy perf (see lines #111 and #112)

The guy is composed of multiple meshes. See it fixed here: http://www.babylonjs-playground.com/#1EVNNB#93

 

You don't have acne issue actually: you have a problem of precision. For the  ESM version, can you try to reproduce your setup in the PG: this is likely a problem to just move the light at the right place ;)

 

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