pichou Posted September 9, 2017 Share Posted September 9, 2017 Hey everyone, I am trying to add a basic shadow in scene with directionnalLight but it doesn't seem to work after all kind of tests. I tried to get inspiration from other playgrounds : https://www.babylonjs-playground.com/#1KF7V1https://www.babylonjs-playground.com/#IIZ9UU And I even went in the source code of this great example : https://www.babylonjs.com/demos/advancedshadows/ I create one that is not working and where I can't see the difference with other scenes : https://playground.babylonjs.com/#TWANP3 It seems very basic but I just can't see the problem. Thanks, Pichou Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 11, 2017 Share Posted September 11, 2017 Hey This is not a bug. I moved your topic to the "Questions" subforum. You forgot the give a position to the light: https://playground.babylonjs.com/#TWANP3#2 Quote Link to comment Share on other sites More sharing options...
pichou Posted September 11, 2017 Author Share Posted September 11, 2017 Hey Deltakosh, OK very basic indeed! I have another question still linked to shadows. I have tested the worldmonger project to show a degraded ground but I can't manage to make the shadows working on this ground contrary to normal groundMaterial. I saw that the worldmonger ground material use material effects and matrix to build the ground. Do you know if there is a way to had shadows to this system? Thanks. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 12, 2017 Share Posted September 12, 2017 There is a way but you will have to update the shaders. Is this what you want ? Quote Link to comment Share on other sites More sharing options...
pichou Posted September 12, 2017 Author Share Posted September 12, 2017 You mean that I will have to manually update the shaders? What I want exatly is the ground to receiveShadows like with a normal BABYLON.StandardMaterial but using the WORLDMONGER.GroundMaterial ! I have read some of the effect doc used by worldmonger (https://doc.babylonjs.com/classes/3.0/effect), but if you know a simpler way, it would be awesome. Bye, Pichou Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 13, 2017 Share Posted September 13, 2017 Yeah you will have to manually update the shaders...OR use the shadowOnlyMaterial on top of a clone of your ground: http://doc.babylonjs.com/extensions/shadowonly Quote Link to comment Share on other sites More sharing options...
pichou Posted September 15, 2017 Author Share Posted September 15, 2017 Cool, I will give it a try! Indeed I haven't thought to clone it. Clever idea! Thanks deltakosh Quote Link to comment Share on other sites More sharing options...
pichou Posted September 15, 2017 Author Share Posted September 15, 2017 Hey Deltakosh, It is working perfect with the shadow only extension. Awesome! Thanks for the tips! Quote Link to comment Share on other sites More sharing options...
pichou Posted September 18, 2017 Author Share Posted September 18, 2017 I have an issue with the shadowOnly extension. When I use a particle system, the shadow goes in front of it (see attached image). Of course I haven't set receiveShadow = true on the partcles system, I guess this is not possible anyway Do tou know where it could come from? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 18, 2017 Share Posted September 18, 2017 Hello! This is because the shadowOnlyMaterial is transparent so rendered after particles. You can fix it by setting the renderGroupId of your particles to 1 Quote Link to comment Share on other sites More sharing options...
pichou Posted September 18, 2017 Author Share Posted September 18, 2017 OK, The exact property was particle.renderingGroupId. By setting to 1, now the particles are in front of every other mesh, which I don't want, I want the particles to be in front of shadows only. Can I rendered shadow just before particles? I tried different number of renderingGroupId for both particles and shadowOnly to do that but it didn't work because it creates rendering conflicts with the other meshes. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 18, 2017 Share Posted September 18, 2017 then in this case you can set everything BUT the ground with renderingGroupdId = 1. The ground will then be always rendered first Quote Link to comment Share on other sites More sharing options...
pichou Posted September 23, 2017 Author Share Posted September 23, 2017 Hello again, I tried to do that deltakosh but it didn't work. I think I a m stuck! :/ Let me explain, I have 4 layers : ground, shadow, mesh and particles. I need my particles to be behind everything except the shadow. Let's assume these rendering number for these 3 layers : ground:1, shadow:2, particle:3 Then the shadow is in front of the ground and the particles in the front of the shadow : good. But the particles are also in front of the ground and are still shown even when they are under the ground which I don't want. So I try these rendering number for each layer : ground:1, shadow:2, particle:1 Now the particles disappear behing the ground again. But as the shadow is rendering after, the particles are hidden from the shadow when I want them to be in front the shadow. With every configuration I have an issue. I have made a playground to make the test easyer : https://playground.babylonjs.com/#WEQHTG The renderingGroupId are at the end of the code. Let me know if any of you have come up with something! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 25, 2017 Share Posted September 25, 2017 what about this: https://playground.babylonjs.com/#WEQHTG#3 Quote Link to comment Share on other sites More sharing options...
pichou Posted September 25, 2017 Author Share Posted September 25, 2017 Nope! The particles need to be not visible when behind the ground, like this : https://playground.babylonjs.com/#WEQHTG#2 But in front of the shadow héhé. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 26, 2017 Share Posted September 26, 2017 So you want the particles to be behind the ground or above? Can you rephrase your need? Quote Link to comment Share on other sites More sharing options...
pichou Posted September 27, 2017 Author Share Posted September 27, 2017 Yes of course! I need the scene to be exactly like that : https://playground.babylonjs.com/#WEQHTG#2 Except that the particles must be in front of the shadow. Quote Link to comment Share on other sites More sharing options...
RaananW Posted September 27, 2017 Share Posted September 27, 2017 https://playground.babylonjs.com/#WEQHTG#4 ? I wonder why you use the ShadownOnly material (there must be a good reason, maybe I missed it). Quote Link to comment Share on other sites More sharing options...
pichou Posted September 27, 2017 Author Share Posted September 27, 2017 The reason is I am working with WORLDMONGER.GroundMaterial : https://github.com/BabylonJS/Website/blob/master/Scenes/WorldMonger/Shaders/Ground/groundMaterial.js It allows me to build the ground as I want with multimaterial but this ground doesn't receive Shadow. So I have to use the shadowOnly extension as suggested by deltakosh. Quote Link to comment Share on other sites More sharing options...
JonathanRev Posted October 19, 2017 Share Posted October 19, 2017 It would be great to have WORLDMONGER.GroundMaterial accepting the shadows of the meshes , i am also working on it , but shaders is quiet a bit far from my knowledge at this moment , i will try to investigate it pichou 1 Quote Link to comment Share on other sites More sharing options...
pichou Posted November 10, 2017 Author Share Posted November 10, 2017 Hey everybody, I have the exact same problem with a material which use FresnelParameters. The mesh's material goes in front of particles when the mesh is actually behind it. Maybe both shadowOnly and this problem are linked? Here is a playground : https://playground.babylonjs.com/#WEQHTG#5 Would be awesome to have a solution!!!! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 10, 2017 Share Posted November 10, 2017 I do not think this is a problem of ShadowOnlyMaterial: https://playground.babylonjs.com/#WEQHTG#6 The problem comes from the ground which is transparent. So rendered AFTER the particles. you can play with the renderingGroupId: https://playground.babylonjs.com/#WEQHTG#7 Quote Link to comment Share on other sites More sharing options...
pichou Posted November 10, 2017 Author Share Posted November 10, 2017 OK I would rather say even with the classic shadowGenerator we have the same problem! See without the fresnelParameter we have the expected behavior : https://playground.babylonjs.com/#WEQHTG#8 Particles are in front of the ground but are not visible when they get behind the groud : logic! But in your playground the particles are always visible even when they get behind the ground : https://playground.babylonjs.com/#WEQHTG#7 And you can play with the renderingGrounpId but you won't get the expected behavior like in the first playground above. Same issue I had with shadowOnly. So I am not saying the problem comes from shadowOnly but as the problem also appear with fresnelParameter, maybe there is a link that could help you resolve this! Cheers, Pichou Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 10, 2017 Share Posted November 10, 2017 The problem comes from transparency only actually. You can even remove the fresnel completely as long as you keep the alpha mode (like just set alpha = 0.5) Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 10, 2017 Share Posted November 10, 2017 I did it once with worlmonger so he could receive light, fog, ambiant color and shadows and others. what i had done was to merge the worldmongerMaterial with the standardMaterial and merge the worldmonger shader and standardMateriel shader. It was a lot of work, but I ended up succeeding. but with the babylon changes that ended up no longer working because the architecture of the shaders has changed a lot, so i stop using worldmonder and is creating my terrain editor using customMateriel. My terrain editor can receive mountain, slope/ramps, hole ... and up to Paint 8 different textures (more than worlmonger ) See : https://bitbucket.org/JSbabylon/terraineditor 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.