pixijs / layers

Separate the z-hierarchy of your scene tree from its canonical structure.
https://pixijs.io/layers/docs/
MIT License
222 stars 57 forks source link

Static container as a background. #31

Closed Fire7 closed 6 years ago

Fire7 commented 6 years ago

Hello, first of all thanks for awesome work with layers and lighting.

I'm trying to migrate my project on a new version of pixi-layers and pixi-lighting and got some issue.

My application consists of several parts:

  1. rootStage (PIXI.display.Stage) - just a rootContainer.
  2. bgStage (PIXI.Container) - container with a background and some sprites on it without any effects.
  3. mainStage (PIXI.display.Stage) - this one is using Pixi-lights.

So, i've got some issue with mainStage opacity, I can't understand why is this happening and tried to use layers, groups, change bgStage type to layer or stage, nothing fix it.

Can you help me?

Here is example: https://codepen.io/Fire7/pen/zaPKNQ So, background and bunny should not be visible

ivanpopelyshev commented 6 years ago

Hello! Thank you!

Yep, that issue is known, that is how lights actually work, they are transparent, applied on black background! If you look at math formulas, its all there.

You have to put black (tint=0) version of diffuse layer, like here: https://pixijs.io/examples/#/layers/normals-drag.js

Put it before normals.

var diffuseBlackSprite = new PIXI.Sprite(diffuseLayer.getRenderTexture());
diffuseBlackSprite.tint = 0;
// without the black sprite, lighted elements will be transparent to background. Try remove that line
stage.addChild(diffuseBlackSprite);
ivanpopelyshev commented 6 years ago

However, to see that you'll have to remove lighted background (bg_diffuse, bg_normal), otherwise it will totally cover whole tilingsprite background.

Fire7 commented 6 years ago

Thanks for fast response, black sprite have fixed issue.