pixijs / lights

Adds dynamic lighting via deferred shading to PixiJS
https://pixijs.io/lights/docs/index.html
MIT License
198 stars 29 forks source link

Cannot read property 'registerPlugin' of undefined #42

Closed fred-hu closed 4 years ago

fred-hu commented 4 years ago

"pixi-filters": "^3.0.3", "pixi-layers": "^0.2.2", "pixi-lights": "^2.0.3", "pixi.js": "^5.1.5"

ivanpopelyshev commented 4 years ago

i didnt move pixi-lights to v5 yet. are you usre that you need normal lights, and not something easier?

ishaan-puniani commented 3 years ago

I also need to use illuminatorMaps to achieve an effect. so stuck at the same problem. @ivanpopelyshev is there any easier filter to get the lightening effect?

probityrules commented 3 years ago

We've used ColorMatrixFilter to some success in simulating something like this. In its current form, it's not a perfect replacement for pixi-lights, but it suits our needs: we still use the normal map image but use the orientation of the entity to determine whether to show highlight or shadow for a given normal.

Here the walls and rotating spinners update the light top edges and dark bottom edges as the box and spinners rotate so that the top is always highlighted and the bottom is always shadowed. ss

Example spinner normal map: slider-bevelSpriteSheet-636i656f686d6b6c6d696e66766f7l6d5u6c576a

Something like

            matrix[0] = matrix[5] = matrix[10] = red;
            matrix[1] = matrix[6] = matrix[11] = green;
            matrix[2] = matrix[7] = matrix[12] = 0;
            matrix[4] = matrix[9] = matrix[14] = (red < 0 ? -red : 0) + (green < 0 ? -green : 0);

            matrix[17] = -0.7;
            matrix[18] = 0.7;

where red and green are dot products of the direction of light and the x and y axes. The alpha channel makes normals close to perpendicular with the light source direction transparent.

I think there's probably a way to use ColorMatrixFilter to more closely mimic pixi-lights, but I don't have a deep enough understanding of the filter to pursue that... I just kept running tests on ideas until I achieved something close enough. 😅