Jump to content

Soft shadows


nirbe
 Share

Recommended Posts

Hi and welcome to the forum!

 

Maybe you should create a playground that shows the problem at www.babylonjs-playground.com

 

I assume the "all black" (http://www.babylonjs-playground.com/#20GGCS) is because you let your meshes cast and receive shadow at the same time. I think that this is not possible with useBlurVarianceShadowMap active.

 

As an alternative you could use usePoissonSampling. Not as soft but still better then no filter at all. http://www.babylonjs-playground.com/#20GGCS#1 (hint: make sure you find a good bias value for the shadow generator, just try different values and see what works for you)

 

About making shadow more transparent: you could use an additional light to soften the shadow effect: http://www.babylonjs-playground.com/#20GGCS#2

 

I hope this helps. Let us know how it's working out. :)

Link to comment
Share on other sites

I've been asking about this as well.  It'd be cool to have an "intensity" setting for shadows.  Adding additional light creates extra load on the processor (noticeable drop on frame rate on mobile) and alters the whole scene so I can't use that option.

Link to comment
Share on other sites

So how shadows work?

 

Let Professor Deltakosh explains you the theory :)

 

Realtime shadows used in Babylon.js use a texture to determine distance between every pixel (that the light can see) and the light. During mesh rendering, shaders compute the current distance of every pixel to the light.

IF this distance is greater than the one saved inside the texture this means that the light CANNOT see the pixel so shaders know they can skip lighting phase for this specific pixel

 

Long story short

Shadows work like in the real word: by not computing the light. Which means that you cannot control the "darkness" because the shadow is not painted or rendered. You can see a shadow because light is not applied where the shadow is.

 

Am I screwed?

No, Babylon.js is your best friend, remember? You can still control your rendering (of course) by adding more ambient color on your receiving object for instance: http://www.babylonjs-playground.com/#20GGCS#4 (See at line 37)

 

Darkness parameter is a little bit different: it can be used when no filter is applied to reduce the strength of the shadows (Creating some kind of cheap penumbra)

Link to comment
Share on other sites

Thanks for the explanation Deltakosh.  I'm still wondering how other frameworks such as Unity are able to have a "Strength" setting for their shadows which allow you to control the strength of the shadow.  If they have that option then it must be possible to implement with Babylon.js.  Adding extra lights to the scene isn't a practical solution for me because it changes the rest of the scene and reduces the frame rate significantly on mobile devices.

Link to comment
Share on other sites

Hmm.

 

 

 

[...] the light CANNOT see the pixel so shaders know they can skip lighting phase for this specific pixel

 

@Deltakosh:

1) Could the shader be modified to not skip the lighting phase but to do lighting with a different intensity (if a darkness value < 1 is provided in the shadow generator)?

2) Alternativley: could a darkness value be implemented for "no light"? I mean a value that can set how dark things are if there is no light at all, that should then effect the shadow areas was well, right?

Link to comment
Share on other sites

I've been asking about this as well.  It'd be cool to have an "intensity" setting for shadows.  Adding additional light creates extra load on the processor (noticeable drop on frame rate on mobile) and alters the whole scene so I can't use that option.

 

Does one hemispheric light put that much additional load on the processor?

 

If it doesn't, it seems like a good solution.  

http://www.babylonjs-playground.com/#20GGCS#3

 

You might want to line up the lights like this:

http://www.babylonjs-playground.com/#20GGCS#6

 

intensity increased a little for hemi light:

http://www.babylonjs-playground.com/#20GGCS#7

Link to comment
Share on other sites

Since we are talking about darkness parameter, it would be super great to be able to strengthen the SSAO effect.

For now we can barely see the shadows added by that process (look at the PG example http://www.babylonjs-playground.com/?24 , just press "3" and you'll notice that the effect is in fact very gentle).

In real cases, eg. scenes well lit containing objects with more or less complex materials, SSAO does not make any difference because the produced shadows are not enough dark. Don't know if the post process is multiplied or added - or whatever else - to the rendered image, but to be usable in production we really need a param to make it more visible.

Link to comment
Share on other sites

Hey Vousk-prod :)

 

The SSAO rendering pipeline can be customized by modifying the .totalStrength parameter (for dark shadows)

Here a full example with all the modifiable values : http://www.babylonjs-playground.com/#1SYMDO

The parameters are explained here : http://doc.babylonjs.com/classes/2.2-alpha/SSAORenderingPipeline

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