Amarth2Estel Posted January 31, 2018 Share Posted January 31, 2018 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 ! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 31, 2018 Share Posted January 31, 2018 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 Amarth2Estel 1 Quote Link to comment Share on other sites More sharing options...
Amarth2Estel Posted February 1, 2018 Author Share Posted February 1, 2018 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 . 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 ! Quote Link to comment Share on other sites More sharing options...
Guest Posted February 1, 2018 Share Posted February 1, 2018 Unfortunately the shadow maps do not contain color information but distance to light so you cannot change their content Quote Link to comment Share on other sites More sharing options...
Amarth2Estel Posted February 2, 2018 Author Share Posted February 2, 2018 Ow.. I got it. Thanks again @Deltakosh ! Quote Link to comment Share on other sites More sharing options...
Amarth2Estel Posted February 2, 2018 Author Share Posted February 2, 2018 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) GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Guest Posted February 2, 2018 Share Posted February 2, 2018 This is a really cool idea! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.