Khas Advanced Lighting v4.2 Ultra (now with real-time shadows!)

Discussion in 'JS Plugin Releases (RMMV)' started by Khas, Apr 22, 2017.

    Tags:
  1. annatar

    annatar Warper Member

    Messages:
    1
    Likes Received:
    0
    Location:
    Santo Domingo
    First Language:
    Spanish
    Primarily Uses:
    RMMV
    Is there a way to bypass the plugin when showing Battle Animations?
     
  2. Nicke

    Nicke Fortune seeker Veteran

    Messages:
    537
    Likes Received:
    524
    Location:
    Sweden
    First Language:
    Swedish
    Primarily Uses:
    RMMV
    Hey, seems like there is a bug with the size property if you use version 4.0.
     
  3. Kilitar

    Kilitar Veteran Veteran

    Messages:
    141
    Likes Received:
    41
    First Language:
    czech
    Primarily Uses:
    RMMV
    Hello @Khas

    It is very nice to see realtime shadows, brilliant work from you.

    Anyway, because I am using bigger actors (who can go behind objects) I unfortunatelly have strange behaviour I can hardly deal with :(.

    This is how it looks when actor is behind wall. So he standing on region tag 26.

    lightWall.png

    I need it to work this way:
    halflight.JPG


    Any option to deal with it? I would love to use realtime shadows, maps look superb with it. But this is real immersion breaker....

    EDIT: As it is an issue only in South part of light I tried use paralel event to switch full light circle PNG with half circle PNG every time I am in "partially behind wall" position, but it is not smooth transition between both images and do not look good.
    I think I am stuck with my options. The right way would be plugin update which would consider if tileset object is a layer above actor and is cover it. Or terrain tag wit "allwayz block light" option. But I think it is big deal as @Khas is not active anymore and I am probably only one needed such feature :(.

    Anyway - I would be gratefull for any advice or help with this issue.
     
    Last edited: Sep 3, 2017
  4. Parallax Panda

    Parallax Panda Got into VxAce ~2014 and never stopped... Veteran

    Messages:
    718
    Likes Received:
    1,046
    Location:
    Fukuoka, Japan
    First Language:
    Swedish
    Primarily Uses:
    RMMV
    Hey Khas,
    I've a question regarding the performance of your lightning plugin since I don't know exactly how it works. For the record I'm using the 3.1 (lightweight) version. I've noticed that on my computer (which is a typical office laptop from ~2014 with no REAL graphic card, see below), just turning your advanced lightning ON with "ambient_light 15" gives me drastic lag spikes that drops my FPS from a somewhat stable 60 to 15-20 (for less than half a second each time, but still). This is without any actual light sources at all.

    I'm well aware that my laptop is crap and I can't play most games in my steam library (tried to play Worms W.M.D the other day, didn't work). So the performance might not be an issue for most potential customers, and in that case that's fine I guess. But I'm mainly asking because I'm also using your Advanced fog plugin and it does not impact performance AT ALL (which I'm very grateful for btw)!
    Also I imagine that a part of the market for RM games might be people who don't own good computers (like me...:kaocry:) and for the sake of those people I'm trying to make my game as lightweight as possible.
    As a side-note, is there any settings or restrictions in particular you'd recommend for better performance with your Advanced Lightning plugin? Custom Blending ON/OFF? Any specific light source (such as torches?) that are more demanding than the others etc?

    For the record my computer have:
    Intel(R) Core(TM) i5-4210U CPU @ 1.7GHz 2.40 GHz
    Intel(R) HD Graphics Family :kaoswt2:
    8 GB RAM (can't remember what type, but it's probably pretty old)
    ...and an SD Hard drive.

    Thanks for taking your time!
     
  5. dragon1up

    dragon1up Veteran Veteran

    Messages:
    71
    Likes Received:
    10
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Been testing out 4.0 Ultra and having these problems with a black map with random lights then it loads. Also some maps play up and have to get back into them to load up right example map is only 29x27 so any advice would be great :)

    3.1 : No problems at all...


    Kind regards

    dragon1up
     

    Attached Files:

    Last edited: Sep 3, 2017
  6. Khas

    Khas Detective lv73 Veteran

    Messages:
    282
    Likes Received:
    374
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    @Ally implementing game logic is the user's responsibility. I can only provide help with the available commands :)
    And it's possible to use only multiples of 10 (so you can combine regions with the same "height")

    @Hyouryuu-Na did you update your MV recently? It looks like your pixi.js is out of date.

    @Kirika unfortunately there's no way to do that :(

    @annatar nope :/

    @Nicke could you elaborate on that? I can't do much without information.

    @Kilitar this is expected behavior, since the algorithm is similar to the VX Ace version. I wanted to do something different for MV, but its engine won't use Z-Buffering and I can't do much without it. I know this might sound frustrating, but there's complex geometry behind shadow generation and my plugin has to simplify it to make it work.

    However, a workaround would be to use a light with an offset (-25 on the Y axis).

    @Parallax Panda good question! Both my plugins (lighting and fog) have the GPU to handle all the heavy stuff. This means the CPU is free to process a lot of events and game logic, but it also means that you need a somewhat good graphics card. The bottleneck could be either the shader (a small program run in your graphics card to apply lighting in the whole screen), or the blending, but a more in depth analysis would be needed.

    I say my plugin is lightweight based on tests with a dedicated video card (your computer has an on-board video card) and also based on tests comparing my lighting plugin with the other options for MV (and it's incredibly faster).

    Are these spikes happening with both plugins ON? Would you mind turning Fog OFF and then checking the performance? And how does the demo perform? Perhaps you could even try running the 4.0 version.

    @dragon1up interesting. Could you record a video of it happening? Or maybe send me a demo.
     
    Ally likes this.
  7. Ally

    Ally Linked Rooms Games Founder - Fleshforward Member

    Messages:
    332
    Likes Received:
    153
    Location:
    Italy
    First Language:
    Italy
    Primarily Uses:
    RM2k
    Yes yes yes :D
     
  8. dragon1up

    dragon1up Veteran Veteran

    Messages:
    71
    Likes Received:
    10
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    bandicam 2017-09-05 10-48-00-218.jpg bandicam 2017-09-05 10-47-45-350.jpg


    Literally a test video of what happens for 4.0 but when testing the demo, this never occurs. Also did copy and paste enemy lighting from version 4.0 which was this line : SetEnemyLight 1 blue 20 -80 to version 3.1 but it didn't really work but the actor line worked fine for 3.1 except the second actor. Which I have taken screenshots for.

    Kind regards

    dragon1up
     
    Last edited: Sep 5, 2017
  9. Cloned

    Cloned Veteran Veteran

    Messages:
    40
    Likes Received:
    16
    First Language:
    English
    Does this work with the Time Fantasy tileset? Would like to use it.
     
  10. Kilitar

    Kilitar Veteran Veteran

    Messages:
    141
    Likes Received:
    41
    First Language:
    czech
    Primarily Uses:
    RMMV
    @Khas , I am using 32pixel Y offset but it does not work, when actor is behind obstacles it still shine over...
    a_candle: {
    fileName: "candle",
    intensity: 80, variation: 20,
    offset_x: 0, offset_y: -32
    },

    EDIT: Strange - in case of EVENT - it works perfectly with offset.
    in case of Actor - it does not work with offset

    EDIT2: Strange even more. It works now in both cases. Dunno why it did not work before.
     
    Last edited: Sep 5, 2017
  11. Kirika

    Kirika Villager Member

    Messages:
    23
    Likes Received:
    1
    First Language:
    na
    Primarily Uses:
    N/A
    @Kilitar i actually use same settings as you and i managed to solve it by altering a little how top tile off wall drop shadowcasters(i use only Khas_SCFB instead of full set of shadowcasters). You need to alter script for thet.

    @Khas i actually managed to achieve black square overlay above all lights, i just use black tile size square image as tile light and permanently changed blending mode of all tile lights(well... i practically sacrificed tile lights for thet option but this works perfect even with time system) would be great to have blending option in light parameters.

    PS i got bug with size property to... to be precise size property do nothing at all (no scaling at all).
    override
    this.scale.x = size;
    this.scale.y = size;
    in Sprite_Light.prototype.setSize = function(size) with fixed number effect nothing to.
     
    Last edited: Sep 5, 2017
  12. Hyouryuu-Na

    Hyouryuu-Na Poker-faced girl who will lurk from now on Veteran

    Messages:
    387
    Likes Received:
    728
    Location:
    . . .
    First Language:
    Bangla/Bengali
    Primarily Uses:
    RMMV
    @Khas I haven't updated it to the latest version yet... which I should do now. Thanks for pointing it out!
     
  13. DavidFoxfire

    DavidFoxfire Veteran Veteran

    Messages:
    224
    Likes Received:
    44
    Location:
    St. Louis, MO
    A needed scenario I need to event: I have a map where a main room has a side room that is in darkness. I want the actor to open a door, and once he goes through, the Ambient Light goes down to 10 or less, and he turns on an lantern that shines for about 3 squares all around. Of course, it reverses when he leaves this area.

    Any help in this will be greatly appreciated.
     
  14. Parallax Panda

    Parallax Panda Got into VxAce ~2014 and never stopped... Veteran

    Messages:
    718
    Likes Received:
    1,046
    Location:
    Fukuoka, Japan
    First Language:
    Swedish
    Primarily Uses:
    RMMV
    @Khas

    I've done some extensive testing and I get 10 seconds of decent FPS, then a lag-spike that freezes the game for half a second after which the game then catches up with the game logic resulting in the player being "teleported" 1-2 tiles ahead of where you were. Then it's back to 10 seconds of decent FPS again and everything repeats itself. It's almost like clockwork although sometimes a lag-spike happens before 10 seconds have passed.

    I tried all different versions of your lightning plugin available (2.1, 3.0, 3.1 and 4.0 ULTRA) and the performance is just about the same (the 2.1 release had lag spikes every ~6-7th second instead of every ~10th second. Also the 4.0 version took a little longer to load on initial startup).

    During these tests I turned off all other plugins that I'm using (including your AdvancedFog). It didn't affect the performance in any significant way though.

    Is there a demo? I'm sorry but I couldn't find it in your master file. In it is only "AdvancedFog", "AdvancedLightning", "Core", "Graphics" & "Hint-System"? If there is a DEMO I'd like to try that too, just in case.

    But besides all that. Since your lightning plugin is clearly the only thing that is pushing the system requirements in my game (and probably most other peoples games too, at least in terms of graphics card) since RM games usually don't require much. Would you consider giving a helping hand in pinpointing the minimum system requirements for this specific plugin? I believe that this is something that would be mostly useful for those thinking about publishing on STEAM (which might not be too many, but still).

    I'm not making any demands or anything, just kindly asking since I'm aware that this sort of thing is on the developer to find out and each game still needs testing. But as the one who made the plugin and know it's inner workings, your opinion would be greatly appreciated.

    So, if you have time would you consider; OS, Processor, Memory, graphics card as well as maybe Direct X version requirements (for this plugin). If possible, for both 3.1 and 4.0 ULTRA since I imagine there is a big difference.:kaoswt:

    Thank you very much for taking your time and reading it all!:kaoluv:
     
  15. Kirika

    Kirika Villager Member

    Messages:
    23
    Likes Received:
    1
    First Language:
    na
    Primarily Uses:
    N/A
    is it only me or after new update (MV 1.5.1) Khas Advanced Lighting v4.0 wont work ('Cannot read property "length" of undefined' on start new game) ?
     
  16. Sleepy Kitten Games

    Sleepy Kitten Games Veteran Veteran

    Messages:
    431
    Likes Received:
    189
    First Language:
    English
    Primarily Uses:
    RMMV
    I'm also getting the same error as @Kirika with the 1.5.1 update:
    [​IMG]
    The title screen loads up as normal, but once I select "new game" it throws this error.
    Turning off KhasAdvancedLighting, KhasHintSystem, KhasGraphics, and KhasAdvancedFog (since it depends on KhasGraphics) stops the error from occurring.
     
  17. DavidFoxfire

    DavidFoxfire Veteran Veteran

    Messages:
    224
    Likes Received:
    44
    Location:
    St. Louis, MO
    And with Khas retired from making/developing this script, this really creates a problem. Maybe somebody would volunteer to fix this problem.
     
  18. Nicke

    Nicke Fortune seeker Veteran

    Messages:
    537
    Likes Received:
    524
    Location:
    Sweden
    First Language:
    Swedish
    Primarily Uses:
    RMMV
    @GameFire : Go to your KhasUltraLighting or KhasAdvancedLighting and inside there is a function called Graphics._createRenderer. Replace it with this:
    Code:
    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    // * Graphics
    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      Graphics.kal_createRenderer = Graphics._createRenderer;
      Graphics._createRenderer = function() {
        this.kal_createRenderer();
        if (typeof PIXI.BLEND_MODES != 'undefined') {
          var gl = this._renderer.gl;
          PIXI.BLEND_MODES.KHAS_LIGHT = 31;
          PIXI.BLEND_MODES.KHAS_LIGHTING = 32;
          this._renderer.state.blendModes[PIXI.BLEND_MODES.KHAS_LIGHT] = [gl.SRC_ALPHA, gl.ONE];
          this._renderer.state.blendModes[PIXI.BLEND_MODES.KHAS_LIGHTING] = [gl.ZERO, gl.SRC_COLOR];
        } else {
          throw new PixiOutOfDateError();
        };
      };
     
  19. DavidFoxfire

    DavidFoxfire Veteran Veteran

    Messages:
    224
    Likes Received:
    44
    Location:
    St. Louis, MO
    That seems to work, but I have my own problem:

    As of right now, the plugins will treat anyregion beyond 10 as a wall in accords to blocking light. It treats regions 11-19 as if it were region 10, for example. This is okay if you're only using regions 1-9 for important stuff. Unfortunately I have more plug-ins that use regions, and I'll be needing more than nine of them. I'd like this plugin (Khas Ultra Lighting) only to look at regions that are in the 10s (10, 20, 30, 40, and so on) to create shadows, and leave the others be.
     
  20. Kilitar

    Kilitar Veteran Veteran

    Messages:
    141
    Likes Received:
    41
    First Language:
    czech
    Primarily Uses:
    RMMV
    Sorry for my bad english,
    Well, the main problem of your solution is in case, when you can reach ramp you were bellow before (using stairs or ladder) - which is pretty common. Light is blocked in both cases, not only if you near wall but if you near edge of ramp as well. You also might want more types of region in each floor (not only one - 10/20/30/40)

    To put it simple, look at this picture
    cut.JPG

    In other case If 10 regions for each floor is not is not enough - why you dont change Khas math inside plugin?
    As I read it, the responsible part is "var h = Math.floor(this.regionId(x, y) / 10) * 2;" in KhasUltraLightning.js file
    I would try to replace it by var "h = Math.floor(this.regionId(x, y) / 20) * 2;" (did not tested it, but should work)
    This way you should get 20 regions instead of 10 for each floor (0-19 floor one, 20-39 floor two etc..)
     
    Khas likes this.

Share This Page