GithubHelp home page GithubHelp logo

Comments (12)

inc0der avatar inc0der commented on May 18, 2024 2

I've never implemented pixi-lights into RPGMaker MV but I am using pixi-layers and the basic light example from pixi examples to create a lighting system of my own for RM game. My guess is pixi-lights will not be much different than doing things this way.

Take a look at examples below, I can't show you the exact way I'm doing it without confusing the crap out of you so I moved my code around to show you it a bit easier, I never tested the code, it's just an extraction of my code placed into one example to quickly show you. In my real code I use a class called LightManager to add the layers to Spriteset_Map and to add lights to the lighting layer.

The first thing you need to do is make sure Stage is using pixi-layers.

function Stage () {
  this.initialize.apply(this, arguments)
}

// Use PIXI Layers
Stage.prototype = Object.create(PIXI.display.Stage.prototype)
Stage.prototype.constructor = Stage

Stage.prototype.initialize = function () {
  PIXI.display.Stage.call(this)

  // The interactive flag causes a memory leak.
  this.interactive = false
}

Then add a lighting layer and a blend sprite to the map's spriteset

// Sorry about bad var names lol

  // Create lighting layer's that make the lights shine!
  const _lightingLayer = new PIXI.display.Layer()

  _lightingLayer.on('display', (element) => {
    element.blendMode = PIXI.BLEND_MODES.ADD
  })
  _lightingLayer.useRenderTexture = true
  _lightingLayer.clearColor = _ambience

  const _lightBlendLayer = new PIXI.Sprite(_lightingLayer.getRenderTexture())
  _lightBlendLayer.blendMode = PIXI.BLEND_MODES.MULTIPLY

// Alias createUpperLayer, create lights and add the layers and lights
const createUpperLayer = Spriteset_Map.prototype.createUpperLayer
Spriteset_Map.prototype.createUpperLayer = function () {
  createUpperLayer.call(this)
 this.addChild(_lightingLayer)
 this.addChild(_lightBlendLayer)

// Create two sprites, one is the light and another to hold the light, it's the only way this will work.
  const _lightContainer = new Sprite()
  const _lightSprite = new Sprite()

 /*
 Give lightSprite a light image for it's bitmap, Replace lightFilename with whatever file you use, or simply swap with  Bitmap.drawCircle(x, y, radius, color) or PIXI.Graphics, or whatever you want really.
 */

    _lightSprite.bitmap = ImageManager.loadBitmap('img/lights/', 'lightFilename', 0, true)
 _lightSprite.parentLayer = _lightingLayer

 // Add lightSprite to the container
 _lightContainer.addChild(lightSprite)

 // Add the lightContainer to the lightingLayer
 _lightingLayer.addChild(_lightContainer)
}

from pixi-lights.

ivanpopelyshev avatar ivanpopelyshev commented on May 18, 2024 1

Yeah, i dont know why people go for lights with normals before they try simple solution. Of course its possible even without pixi-display, its just an efficient way to code multi-layered world.

The next step is to drawing a dark version of object and lighted one in different layers (day and night) and changing between gradually using light layer and a shader (simple tint or adjustment)

from pixi-lights.

ivanpopelyshev avatar ivanpopelyshev commented on May 18, 2024

@djmisterjon knows how to do it.

Bear in mind that both projections and lights are experimental plugins and you have to be aware of how their work if you want to use them for something more than simple demos, especially if you want to use them together.

Both plugins were not even possible to make on vanilla pixijs before! First examples were 3 years ago but they worked only on heavily modified pixi.js , it took many nights to get the architecture right and not screw up the renderer API.

Maybe you wont be able to use them at the same time, maybe you have to wait when pixi-display supports multi-texture sprites, or something like that.

Are you sure you want normal maps in your game and not something simpler like here ?

Also user anisoft at pixijs slack knows how to use different types of lighting in RMMV. Do you want an invite there?

from pixi-lights.

PesadeloDoEspantalho avatar PesadeloDoEspantalho commented on May 18, 2024

Yes I'm interested.
Thanks for the invitation.

from pixi-lights.

ivanpopelyshev avatar ivanpopelyshev commented on May 18, 2024

give me your email here, or write me to XXX

from pixi-lights.

PesadeloDoEspantalho avatar PesadeloDoEspantalho commented on May 18, 2024

I'm send message in your mail.
Thanks and sorry for my english.

@djmisterjon speak french, he can explain me no?
How to contact him?

from pixi-lights.

hjoseph96 avatar hjoseph96 commented on May 18, 2024

Also interested in this issue, let me know if anyone finds a solution...

from pixi-lights.

ivanpopelyshev avatar ivanpopelyshev commented on May 18, 2024

The plugin is experimental, and people who are using it with RMMV.. not actually using it with vanilla RMMV, they already have very serious experience with plugins and their games are heavy-modded.

Plugin has several problems that weren't solved, like, for example, masking, or the fact that you have to use container with two sprites for every element, or the absence of integration with pixi-spine.

If you are sure, I can send you an invite to pixijs slack, but don't be surprised when you dont understand stuff from first try.

from pixi-lights.

PesadeloDoEspantalho avatar PesadeloDoEspantalho commented on May 18, 2024

I managed to make the sprite black but not enlightened, I'm not put normal, you think that's the problem ????

from pixi-lights.

ivanpopelyshev avatar ivanpopelyshev commented on May 18, 2024

Sorry guys, I don't have time to explain everything, I'm working on v5 and moving plugins to it, including this one.

so far @djmisterjon is the only one who made it work.

from pixi-lights.

PesadeloDoEspantalho avatar PesadeloDoEspantalho commented on May 18, 2024

It's this without normal no light :D

from pixi-lights.

ivanpopelyshev avatar ivanpopelyshev commented on May 18, 2024
  1. make sure updateStage() is called from your app, from somewhere. Otherwise layers wont work at all.
  2. make sure that lightLayer has _activeChildren with your lights inside. Its a calculated array with all stuff that has parentGroup=lightgroup

from pixi-lights.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.