MV - Community Lighting MV & MZ

● ARCHIVED · READ-ONLY
Started by ImaginaryVillain 1279 posts Page 62 of 64 View original ↗
  1. Aesica said:
    You know, your lag issue might be something else. I just made a 256x256 map and it runs at 60 fps, but it also only as one event and light source. Does it still lag with other plugins turned off? Are there a lot of events and light sources, even if most are "off" due to active radius?
    There are 31 Events on the map, not including the light sources, all together you have about 91 events in total on the map.

    This is a video of some of the maps... the first one is the map that drops the FPS. They drop a little more since I'm recording in the video, but not much.
    [embedded media]

    And this is a picture of the entire map in the editor:
    Room 1 (1).png

    I have no idea what could be causing the slow down... If I turn off the lighting plugin then the FPS goes up to 60. Plus there aren't any significant plugins on the map [Yanflys EventChase is the most significant I can think of]. there is one Parallel Process Event that is erased as soon as you enter the map and that's pretty much it.
  2. How big is your screen?
  3. utunnels said:
    How big is your screen?
    The game's resolution is 1104x624... I read somewhere that this is a good resolution for the game.
  4. @firestalker Can you give me a link to the lagged version you are using? The topic is a bit long and I'm a little lost.
  5. Most Recent Stable Version

    I'm not saying the plugin is laggy, except on large maps for me, and it only seems to lag on large maps [usually 90 tiles and above will get it].

    I can send you a copy of my game, though it's rather beefy since I have not cleaned out the folders in a long time and there are several [tens of several] obsolete assets and plugins.
  6. Oh if you can make a smaller demo for that map it'll be more convenient. Because it is difficult to replicate the problem.
  7. utunnels said:
    Oh if you can make a smaller demo for that map it'll be more convenient. Because it is difficult to replicate the problem.
    I'll see what I can do... It might take a minute though. I'll DM you when I have it...
  8. I wouldn't mind taking a look, too. I've got several maps with lots of lights for testing purposes and they don't lag like that.
  9. You know what might be a good idea to improve performance for this? It's something I do in my own stuff (regardless of the engine), and that's to reduce how often it updates. So instead of updating the lights every frame, it would update every other frame or every third frame, etc. Then you can just have a plugin property that people can adjust.

    I am of course not volunteering to provide such an update though. Just an idea for anybody who is feeling feisty. :popcorn:

    Aesica said:
    Okay that's what I was afraid of. Yeah some of these people (Terrax for sure) are completely unreachable, so I guess we'll just stick with the huge credit list.

    That said, the free-for-all version could still continue to remain as is if anyone else wanted to run with it. What I'm working on would just be my own curated branch, kind of like the mini version is with you.

    Fair enough. I mean who knows maybe I'll randomly decide I want to continue this... I mean I can't imagine a world where I would give up the stars to live in the mud, but I guess it's possible. Still I'll at least put people's updates on Github if they show up. This thread hasn't really seen much action in years though, so I'm not expecting to ever need to do so again.

    Aesica said:
    Necessity makes fools of us all. I knew I'd eventually need to get a good lighting plugin because I still do things in MZ, but there just aren't a lot of good lighting plugin options. So here I am. ;)

    Haha yes, this is my entire RM experience in a nutshell. Granted I paid $20 for someone else to produce the most fantastic weather/lighting/time system I've ever seen in UE. Kind of really begs the question just how much one's time is worth you know? I know for certain this plugin would never have existed if I'd seen that first. :kaoswt:
  10. ImaginaryVillain said:
    You know what might be a good idea to improve performance for this? It's something I do in my own stuff (regardless of the engine), and that's to reduce how often it updates. So instead of updating the lights every frame, it would update every other frame or every third frame, etc. Then you can just have a plugin property that people can adjust.
    Wouldn't this affect the lights that are moving? Like the light would be a frame or two behind the light source as it moves?
  11. firestalker said:
    Wouldn't this affect the lights that are moving? Like the light would be a frame or two behind the light source as it moves?
    It 100% would, but that's the trade off. Lighting is an expensive operation in game dev, but it's unlikely something needs to be updated every frame. When I did animation in RM for instance, RM can't even handle displaying images faster than 30 frames per second due to needing 1 frame to process the command, and 1 to display it. Yet the animations looked great and nobody could see the difference.

    RM's unfortunately a very weak engine, I could go into all the reasons why I basically had to create my own HLOD system to make it able to do what I had it do. But it's a very technical discussion and probably not that interesting to most people. My advice towards fixing the problem is a band-aid of just letting you reduce resource costs to make up for whatever other things you've put into your game.
  12. ImaginaryVillain said:
    You know what might be a good idea to improve performance for this? It's something I do in my own stuff (regardless of the engine), and that's to reduce how often it updates. So instead of updating the lights every frame, it would update every other frame or every third frame, etc. Then you can just have a plugin property that people can adjust.

    I am of course not volunteering to provide such an update though. Just an idea for anybody who is feeling feisty. :popcorn:
    That shouldn't be too hard to add to what I've got so far, especially with the gigafunction broken up. I'll give it a go next time I open it. But first, I somehow broke region lights/blocks, so... :D
  13. By the way, isn't there already an ellipse method?
    CanvasRenderingContext2D: ellipse() method - Web APIs | MDN
    Edit* OK it seems the article was written in 2012, and the method was added in 2013.
    JavaScript:
      // *******************  CIRCLE/OVAL SHAPE ***********************************
      // from http://scienceprimer.com/draw-oval-html5-canvas
      /**
       * @param {Number} centerX
       * @param {Number} centerY
       * @param {Number} xradius
       * @param {Number} yradius
       * @param {String} color1
       */
      Bitmap.prototype.FillCircle = function (centerX, centerY, xradius, yradius, color1) {
        centerX = centerX + lightMaskPadding;
    
        let context = this._context;
        context.save();
        context.fillStyle = color1;
        context.beginPath();
        let rotation = 0;
        let start_angle = 0;
        let end_angle = 2 * Math.PI;
        for (let i = start_angle * Math.PI; i < end_angle * Math.PI; i += 0.01) {
          xPos = centerX - (yradius * Math.sin(i)) * Math.sin(rotation * Math.PI) + (xradius * Math.cos(i)) * Math.cos(rotation * Math.PI);
          yPos = centerY + (xradius * Math.cos(i)) * Math.sin(rotation * Math.PI) + (yradius * Math.sin(i)) * Math.cos(rotation * Math.PI);
    
          if (i == 0) {
            context.moveTo(xPos, yPos);
          } else {
            context.lineTo(xPos, yPos);
          }
        }
        context.fill();
        context.closePath();
        context.restore();
        this._setDirty();
      };


    JavaScript:
      CanvasGradient.prototype.addTransparentColorStops1 = function (brightness, color1, color2) {//console.log('...')
    
        if (brightness) {
          if (!useSmootherLights) {
            var alpha = Math.floor(brightness * 100 * 2.55).toString(16);
            if (alpha.length < 2) {
              alpha = "0" + alpha;
            }
            this.addColorStop(0, '#FFFFFF' + alpha);
          }
        }
    
        if (useSmootherLights) {
          for (let distanceFromCenter = 0; distanceFromCenter < 1; distanceFromCenter += 0.1) {
            let data = hexToRgb(color1);
            var newRed = data.r - (distanceFromCenter * 100 * 2.55);
            var newGreen = data.g - (distanceFromCenter * 100 * 2.55);
            let newBlue = data.b - (distanceFromCenter * 100 * 2.55);
            let newAlpha = 1 - distanceFromCenter;
            if (brightness > 0) {
              newAlpha = Math.max(0, brightness - distanceFromCenter);
            }
            this.addColorStop(distanceFromCenter, rgba(~~newRed, ~~newGreen, ~~newBlue, newAlpha));
          }
        } else {
          this.addColorStop(brightness, color1);
        }
    
        this.addColorStop(1, color2);
      }
    Another thing I don't quite understand is the logic behind useSmootherLights.
    The code seems to degrade the light too fast. And you need to set the radius bigger if you have this option on.

    I wrote another version below and it seems to have similar effect and correct the radius problem.
    JavaScript:
      CanvasGradient.prototype.addTransparentColorStops = function (brightness, color1, color2) {
    
        if (brightness) {
          if (!useSmootherLights) {
            var alpha = Math.floor(brightness * 100 * 2.55).toString(16);
            if (alpha.length < 2) {
              alpha = "0" + alpha;
            }
            this.addColorStop(0, '#FFFFFF' + alpha);
          }
        }
    
        if (useSmootherLights) {
          let data = hexToRgb(color1);
          let data2 = hexToRgb(color2);
          let newAlpha = brightness>0?(1-brightness):1;
          this.addColorStop(0, rgba(data.r,data.g,data.b,data.a/255*newAlpha));
          this.addColorStop(1, rgba(data2.r,data2.g,data2.b,data2.a/255*newAlpha));
        } else {
          this.addColorStop(brightness, color1);
          this.addColorStop(1, color2);
        }
    
      }
  14. Hi. I wanted to try this plugin but I have already day/night system in game. Is there a way to use only light sources (events) from this plugin and stop the screen going black?
  15. RenGames said:
    Hi. I wanted to try this plugin but I have already day/night system in game. Is there a way to use only light sources (events) from this plugin and stop the screen going black?
    Unfortunately no. The way the lighting works is that it adds brighter colors (the lights) on top of the specified tint (black, night blue, etc)
  16. I have a question.
    Do you know why the x, y, width, and height of the tile and region blocks are not working?
    Also, is there a way to solve this?
  17. Hello i'm very sorry for the stupid question, but how do we change the black screen tint please ?
    If we want it less dark i mean ?
    Any tutorial for nubs anywhere by any chance please ?
    Edit: my bad, i didnt fully read the read me -_- thats stupid sorry again.
    Thanks anyway for the plugin, sharing is a wonderfull thing, love you all.
  18. Is there a way an event can cycle through colours dependent on variables or switches for event note tags?
  19. Is there a way to make the lighting have less hard edges? What I'm looking for is more of a fadeout of the light towards the edges rather than the hard edges it seems to have no matter what I turn the brightness to.
  20. Thank you very much for this plug in, I have a doubt, is there any way to use the terrain tag to add lights to some sprites from the tilesets?