Jump to content

Can't cast shadow with SPS


Nockawa
 Share

Recommended Posts

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.

image.png.b1993e8dd7338a18db2350d6a3907a9a.png

Thanks guys!

EDIT: 
The SPS doesn't seem to also support Glow effect set by : var gl = new BABYLON.GlowLayer("glow", this.scene);
 

Link to comment
Share on other sites

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

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