Jump to content

Recommended Posts

Hello Everyone !

I am currently working on an 'indoor' project and can't manage to solve an issue.

I would like to render a room with a ceiling light.

  • I am working with StandardMaterial only.
  • I use a single pointLight to avoid heavy computations with multiple lights.
  • Every mesh both cast and receive shadows.
  • To see non-directly-illuminated mesh, I also use an ambientColor on every material on the scene.
  • Thanks to Deltakosh's answers on a previous post, I managed to get correct shadows using Close Exponential Shadow Map by stretching my scene into a unit cube and setting the depthScale of the shadowGenerator to 1.
  • I use shadowGenerator.setDarkness(0) to ensure shadows are the most dark as possible.

However, even if these shadows are correct, they are way too light to be seen in my scene. I think this is both due to the depthScale and the fact that receiving-shadows-mesh material have an ambientColor.

I thought about apply a filter directly in the shadows texture to increase level of gray in the entire image but I don't know how to get this texture and how to apply filter before the render.

Do you know how to do that ? Or any ideas on how to reach my goal ?

Because the room I would like to render is fully dynamic, I think I cannot use tricks like static lightMapping.

PS : Here is a PG showing my problem. I would like the shadow to be darker.

Thank you very much !

Link to comment
Share on other sites

Unfortunately shadows try to work like in real world: They are space where the light can't be seen

Because you have a white ambient, the light influence is minimal so shadows for this light reduce the lighting but not the ambient light.

Anyway you can still force the darkness by increasing the depthScale:

https://playground.babylonjs.com/#27GWGK#2

Link to comment
Share on other sites

Thank you very much for your answer @Deltakosh !

I totally understand that. This is the most consistent way of managing shadows. Even though I was a little afraid of that answer :P.

Is there any way to access the shadow texture(s) to increase its intensity before rendering ? Because the scene is 

Otherwise, I will try to work with lightMaps and the property lightmapMode = LIGHTMAP_SHADOWSONLY of Light. 

Thanks again !

Link to comment
Share on other sites

Hi everyone !

I finally manage to find a way to get darker shadows with CESM !
I know it is very bad for memory usage because it litteraly doubles the vertices and indices number in the scene... so if somebody has another idea, it would be really appreciated !

What I changed :

  • Every mesh in my scene is now casting shadows but not receiving shadows anymore.
  • Then, I merge all the meshes (without disposing source) in a 'shadowReceiver' mesh with a shadow-only material
  • To avoid artifacts because 'real meshes' and 'shadowMesh' have the exact same vertices, I use the property zOffset on the shadow-only material.

PS : There are some little memory optimizations (like deleting the unused data from the shadowMesh VertexData)...

Playground with the too light shadows
Same Playground using this method

Here is the kind of result I managed to reach (Indoor scene with piece of furniture, 1 single ceiling light)
5a747cd57e56a_Capturedecran2018-02-02a15_57_27.thumb.png.2549822b2b4fcf1c16da452983f0a671.png

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