Nockawa Posted June 17, 2018 Share Posted June 17, 2018 Hello everyone, It's been a while, I'm glad that I can be (a little) back. I summon @jerome, I believe this one is for you. I want to cast shadow with the content of a SPS, but apparently I can't configure it the right way because I have no cast shadow. Here's the code: var sps = new BABYLON.SolidParticleSystem("Bots", this.scene); var circle = BABYLON.MeshBuilder.CreateDisc("botCircle", { radius: 1, tessellation: 18, sideOrientation: BABYLON.Mesh.DOUBLESIDE}, this.scene); let particleCount = this.botPerCircle*this.botCircleCount; sps.addShape(circle, particleCount); this.botsSPSMesh = sps.buildMesh(); this.botsSPSMesh.position.y = 20; this.botsSPSMesh.material = partMat; this.shadowmapGen.addShadowCaster(this.botsSPSMesh); sps.initParticles = () => { for (let i = 0; i < sps.nbParticles; i++) { sps.recycleParticle(sps.particles[i]); } }; sps.recycleParticle = p => { let b = allBots[p.idx]; p.position.x = b.position.x; p.position.y = b.position.y; p.position.z = b.position.z; return p; } sps.initParticles(); sps.setParticles(); this.shadowmapGen.addShadowCaster(this.botsSPSMesh); sps.billboard = true; sps.computeParticleRotation = false; sps.computeParticleColor = false; sps.computeParticleTexture = false; Unfortunately the result is not the expected one. Thanks guys! EDIT: The SPS doesn't seem to also support Glow effect set by : var gl = new BABYLON.GlowLayer("glow", this.scene); Quote Link to comment Share on other sites More sharing options...
jerome Posted June 17, 2018 Share Posted June 17, 2018 The SPS is just a standard updatable mesh. The issue is probably due to the SPS bouding box that's not updated in your case : http://doc.babylonjs.com/how_to/solid_particle_system#sps-visibility SPS.computeBoundingBox = true should bo the job anyway happy to see back Quote Link to comment Share on other sites More sharing options...
Nockawa Posted June 17, 2018 Author Share Posted June 17, 2018 The bounding box was indeed not properly computed (the SPS was clipped as soon as its center was out of frustum). Now the SPS is clipped correctly, but the shadows still doesn't work! Quote Link to comment Share on other sites More sharing options...
jerome Posted June 17, 2018 Share Posted June 17, 2018 mmmh... weird, it usually works. Can you reproduce this in a PG ? I can see you're using the billboard mode. Billboarding means that an automatic rotation is applied to each solid particle. If these particles are planar (ex: quads), maybe the light source is in the same geometric plane than the 2D particles, so they don't cast any shadow at all ? Just check with box particles (3D) instead of disc ones (2D). Or add a pointlight set at the current camera position to cast shadows from the 2D particle surfaces 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.