Khas Advanced Graphics (deferred lighting and procedurally generated fog)

Discussion in 'JS Plugin Releases (RMMV)' started by Khas, Jan 21, 2017.

  1. Khas

    Khas Detective lv73 Veteran

    Messages:
    282
    Likes Received:
    374
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV

    Khas Advanced Graphics
    Lighting and Fog


    2.0 Update
    This plugin has been discontinued! Lighting and fog are now separate plugins, and both of them require my new KhasGraphics plugin. You may read more below!

    [​IMG]
    [​IMG]

    Introduction
    This is my graphics enhancement plugin for RPG Maker MV, which includes deferred lighting and procedurally generated fog. Both systems are processed by your graphics card with GLSL shaders, so you will get great performance and awesome eye candy.

    Attention!
    This plugin requires WebGL. There’s no way around this.
    Old save files will not work correctly with this plugin.

    Features
    Easy to use!
    Deferred lighting
    Lights are created from images – you can create them in any shape you want!
    Two light blend modes: stock and custom
    All effects are rendered using GLSL shaders
    Adaptive exposure – simulates de human eye reacting to drastic lighting changes
    Comes with 23 lights and 3 fogs. You can easily add more!
    Procedurally generated fog – it’s dynamic and it looks awesome
    Variable fog density around the player

    Screenshots
    Click to enlarge.

    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]

    Download
    The latest version is always available here (click me!).
    If you like my work, please consider supporting me for more awesome plugins!

    [​IMG]


    FAQ
    Q: Is this a port of your Ultra Lighting script for RPG Maker VX Ace?

    A: A few weeks after I released Ultra Lighting, the RPG Maker MV was released. Since then, people have been asking me to port my lighting engine to MV. I was very excited after I heard the new RPG Maker supports WebGL, so I started trying to make a new version a year ago. Unfortunately, a lot of personal issues and lack of time came in the way. But now it’s finally done! I spent more than 70 hours making this plugin, according to my steam account. I had a long list of ideas I wanted to implement, so I did my best for each of them.

    Q: Your previous lighting engine had dynamic shadows. Why this plugin doesn’t have them?
    A: Technical reasons. With Ultra Lighting I had complete control over the light rendering, with nothing in between the lights and KGL (my library for rendering inspired by OpenGL). However, things in RPG Maker MV are more complex than in its predecessor. There’s the MV engine, then Pixi.js and then WebGL. Thus, I had both the limitations of the MV engine and of the Pixi.js to work with. The biggest barrier was that Pixi is great to render bunnies and other sprites, but it’s terrible to generate geometry, especially dynamic geometry. If I wanted to render shadows in the same way I did in my previous engine, I would need to edit the Pixi engine, which is not a good thing and could be very unstable (I tried). The other option would be to implement a technique similar to shadow mapping, which was my dream once I heard about MV’s OpenGL capabilities. Unfortunately, again, Pixi.js doesn’t use depth buffering (this buffer holds an extra dimension data, z in RPG Maker’s case), so this discards the possibility entirely. It would require a massive edit on Pixi and MV’s engine. As my top priority is to create something reliable, I had to discard shadows. I’m sorry.

    Q: You are back! What happened?
    A: I apologize for my long absence. If you want to know more, please read this blog post.

    Q: I got this error "TypeError - Cannot set property 'CUSTOM_KHAS' of undefined". How do I fix it?
    A: Update your RPG Maker MV. The version of your Pixi.js is outdated.

    Q: Is this plugin fast? Is it faster than other MV Lighting plugins?
    A: Yes! Lighting is super fast and won't have any performance impact in your game. Fog, however, requires a more modern GPU (because it's procedural). I'll add low, medium and high Graphics options in the future, so that won't be a problem anymore. You can read more about it and check a benchmark against other lighting system here (click me!).

    Q: Does this plugin use layers to add this effect?
    A: Nope. I implemented a technique similar to deferred shading, which renders all the lights to an off-screen framebuffer, and then I use GLSL Shaders to compose the final scene with correct lighting and fog. So there's no additional layers.

    Update Log

    03.03.2017 R3 Khas Advanced Graphics updated to 1.1
    * MV updated to 1.3.5
    * Requires Khas Core 1.2
    * Added compatibility with zoom controls (zoom in only!)
    * Added compatibility with different tile sizes
    * Added Pixi.js version checking (requires v3 or later)
    * Fixed event not turning off light on page switch
    * Added commands to create lights with region tags and terrain tags
    * Fixed lighting/fog being applied to pictures
    * Performance tweaks
    * Fixed shader problems with opacity and exposure

    01.24.2017 R2 Khas Advanced Graphics updated to 1.0.1
    * Fixed bug: inverted lighting/fog on menu screen

    01.22.2017 R1 Khas Core.js updated to 1.1
    * Fixed bug: erase event / empty event

    01.20.2017 R0 Version 1.0 released!
     
    Last edited: Apr 22, 2017
    #1
    Yin, Izzybelle, Val and 23 others like this.
  2. Jonforum

    Jonforum Veteran Veteran

    Messages:
    1,594
    Likes Received:
    1,381
    Location:
    Canada / Québec
    First Language:
    French
    Primarily Uses:
    RMMV
    Last edited by a moderator: Jan 21, 2017
    #2
  3. Khas

    Khas Detective lv73 Veteran

    Messages:
    282
    Likes Received:
    374
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV


    Hi there! This plugin is based on Pixi's filters, which are nothing more than GLSL shaders per se (GLSL is short for OpenGL Shading Language). They are small programs executed by the GPU to process all the data and draw awesome pixels on the screen. I chose to do things this way because I really like developing with OpenGL (WebGL is basically OpenGL ES 2.0), so I find programming shaders fun and I wondered what I could achieve with them.


    If you're referring to the Pixi's inability to deal with meshes and geometry, than it's a completely different thing. Pixi doesn't allow you to easily create custom geometry efficiently (there's a Graphics object, but it kind of sucks hahaha), especially dynamic geometry. Memory management is a serious topic in graphics programming, so even if I added custom code to Pixi, I would be risking to have an unstable system.


    I didn't understand your question very well, but did my best to answer it. Please let me know if you want to know any further details.
     
    #3
    Roguedeus, Archeia and Jonforum like this.
  4. Kyuukon

    Kyuukon 主人公 Veteran

    Messages:
    2,217
    Likes Received:
    1,076
    First Language:
    Spanish
    Primarily Uses:
    RMMV
    Wohooo! :D
     
    #4
    Marsigne and Khas like this.
  5. so1us

    so1us Villager Member

    Messages:
    14
    Likes Received:
    3
    First Language:
    English
    Khas, just wanted to chime in and say thanks for this! One of the reasons I got into RPG Maker in the first place was after seeing the dynamic shadows in Ultra Lighting. It was an easy way to add  production value to a standard game. While super unfortunate that technical limitations don't allow a similar implementation, thank you for putting this plugin together for MV! And sad to hear you're getting out of the plugin dev scene, but looking forward to what you do next.
     
    #5
  6. firestalker

    firestalker Veteran Veteran

    Messages:
    326
    Likes Received:
    37
    First Language:
    English
    Primarily Uses:
    RMMV
    [​IMG]


    I get the above error whenever i try to use this...  Even on a fresh, brand new project.  I just copied the plugins [Core and Advanced] from the demo and the light folder from Img.  What's wrong?
     
    #6
  7. Khas

    Khas Detective lv73 Veteran

    Messages:
    282
    Likes Received:
    374
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    so1us 



    Thank you! I'm honored to be part of the reasons you joined RPG Maker. After I got into graphics programming, I've been trying to use what I know to improve a RM's game and make it visually more appealing. But there are some limitations, as you saw above. Anyhow, thank you for taking your time to comment. 


    firestalker



    That's super weird! A few questions to help me understand what is happening:


    1. Is your RPG Maker up to date?


    2. How many events do you have within the map this problem occurs? Have you tried putting only one event with [light torch], for example?


    In order to test if everything was working correctly, I did start a new project for the demo and it went very smoothly, without any errors.
     
    #7
  8. Nicke

    Nicke Fortune seeker Veteran

    Messages:
    537
    Likes Received:
    523
    Location:
    Sweden
    First Language:
    Swedish
    Primarily Uses:
    RMMV
    Great plugin! Awesome to see you back as well. Cheers!


    Anyways.. I found two possible bugs which I would like to point out.

    1. If you use the command "Erase Event" on an event it will throw "TypeError. Cannot read property 'list' of undefined".
    2. When you go to the menu scene the light effect somehow shifts locations and looks a bit weird. This might be because of how MV creates the background bitmap. Not really sure how to explain it but I feel it is a bug.

    A part from that great work here.
     
    #8
    Khas likes this.
  9. Khas

    Khas Detective lv73 Veteran

    Messages:
    282
    Likes Received:
    374
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    Nicke



    Thanks a lot! So, about the two bugs:


    1. Yep, this is happening. It might be the same thing that firestalker pointed above. Anyway, I already found why.


    2. Oh, this was a silly mistake of me! If you look closely, the y coordinates are flipped.


    I will fix these bugs and release a new version. I will just wait a few more days to see if you guys find any other bugs.


    Thank you for your help!
     
    #9
  10. firestalker

    firestalker Veteran Veteran

    Messages:
    326
    Likes Received:
    37
    First Language:
    English
    Primarily Uses:
    RMMV
    @KhasI retried the new project thing and it worked just fine...  Weird since it wasn't last night.  I tried it again in my project and it didn't work.  I turned off all my plugins except these ones and it still didn't work.  I have no torches or notes on the starting map, and the error appears as soon as I hit 'new game'.  I hope the change helps, since I think this plugin will work better than the other lighting plugin I'm using now.
     
    #10
    Khas likes this.
  11. Nicke

    Nicke Fortune seeker Veteran

    Messages:
    537
    Likes Received:
    523
    Location:
    Sweden
    First Language:
    Swedish
    Primarily Uses:
    RMMV
    @Khas Ah great! I found out what was causing the "Erase Event" bug and fixed it myself actually. :)  


    I hope it is okay to post a screenshot. I'm currently working on a Crystal Cave and got this effect with this plugin. I really like it! :) [​IMG]
     
    #11
    Zarsla and Houpee like this.
  12. firestalker

    firestalker Veteran Veteran

    Messages:
    326
    Likes Received:
    37
    First Language:
    English
    Primarily Uses:
    RMMV
    @NickeHow do you fix it?  Can you give a hint.  i have very little, no, JS scripting knowledge...  Help?


    Nevermind...  figured out the problem, but not the solution.


    @KhasI've figured out what's happening.  I have an event on the starting map that has a Self Switch A on the first page.  I don't know why this is a problem, but it seems if you have an event that starts off with a Self Switch turned on that you later turn off, the plugin doesn't like that.


    I removed the event from the map, temporarily, and everything worked fine.  This wouldn't a problem, but I have more than a few Events in my game that have this same setup and if the plugin isn't going to play nice with them than it'll be difficult to use.


    This is the offending event:

    [​IMG]

    Pretty simple, right. I've tested it...  it is the Self Switch, because it's on the first page.  I use this like a regular switch without using a switch space up on something small.


    I have no idea how to fix the problem easily.  Thanks.
     
    Last edited by a moderator: Jan 22, 2017
    #12
  13. Khas

    Khas Detective lv73 Veteran

    Messages:
    282
    Likes Received:
    374
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    @firestalker Thank you for sending me more details. I know where the bug is now, I will just wait a bit more to release a fix in order to see if people discover other bugs. I'm doing this because I need to update 4 files each time I change anything. Could you please use a temporary solution during this time?


    @Nicke I'm glad you like it! It looks amazing :D


    Thanks for sharing this beautiful screenshot.



    Off topic: Now I know how to use those fancy mentions LOL
     
    #13
  14. firestalker

    firestalker Veteran Veteran

    Messages:
    326
    Likes Received:
    37
    First Language:
    English
    Primarily Uses:
    RMMV
    @KhasNow I'm having a different problem but the same error.  For some reason, the event errors when it tries to teleport anywhere.  I've checked the new map and nothing is there that might conflict like the last time.  Plus it almost seems like it doesn't like that I have a Fadeout on BGM...  I don't that's it, but it errors out when the Fadeout finishes.  There's only like two or three commands left before the teleport after that.


    Update:  After a test with an event that only has the Transfer event I have found that it IS the map I'm teleporting too...  I teleported to several different maps and some worked, others didn't.  The only difference between the ones that did and the ones that didn't is that there are events that appear when a Switch is turned ON.  Much like the Self Switches before.  I think it might be the same fix or something, but I don't know so I'm letting you know now.


    @KhasI could do a temporary workaround for it, but it's actually more work for.  Literally, I'll have to go through all of Hundreds of events and check them.  If they have a Self Switch or Switch on the First Page, then I'll have to add a blank page in front of it.  I have some big maps and some pretty elaborate traps and puzzles that work the way I did it, but they it means going through all of them and doing this.  I'll be spending hours on a temporary fix that will be mute when the patch comes...  Not that I'm saying hurry up or anything.  I still have a lot to do and I can still work without the plugin being Turned ON at the moment.  But I would rather not work that hard on a temporary fix if I can help.


    This is doubled with the "Erase Event" bug, since I have a bunch of those as well, I don't even know where they all are and searching for them is...  well....  i'll just wait for the bug fixes and hope for the best.


    Thanks for the great work though and I look forward to fixes.
     
    Last edited by a moderator: Jan 22, 2017
    #14
  15. Zero2505

    Zero2505 Veteran Veteran

    Messages:
    33
    Likes Received:
    43
    Location:
    Canada
    First Language:
    English
    Hadn't had the chance to try this yet, but judging from the screenshots this looks like exactly what I've been looking for.


    Thanks so much Khas!
     
    #15
    Khas likes this.
  16. nio kasgami

    nio kasgami VampCat Veteran

    Messages:
    8,600
    Likes Received:
    2,359
    Location:
    Canada / Quebec
    First Language:
    French
    Nice to see you back khas! Surprisely quasi in the past worked with geometrical shadow and didn't got any actual problem with it unless having to deal with the inverted polygobe axis...isnt probably you might need to see the problem on a different aspect? Thanks for working hard as always khas!
     
    #16
    Khas likes this.
  17. Nicke

    Nicke Fortune seeker Veteran

    Messages:
    537
    Likes Received:
    523
    Location:
    Sweden
    First Language:
    Swedish
    Primarily Uses:
    RMMV
    @firestalker: If you want I can send you my fix. I fixed both the "Erase Event" problem and the one you described :)
     
    #17
    firestalker likes this.
  18. firestalker

    firestalker Veteran Veteran

    Messages:
    326
    Likes Received:
    37
    First Language:
    English
    Primarily Uses:
    RMMV
    That would be great, thanks...
     
    Last edited by a moderator: Jan 22, 2017
    #18
  19. What?

    What? Villager Member

    Messages:
    12
    Likes Received:
    1
    First Language:
    Chinese
    That‘s amazing but,i cannot enter your website so i cannot download your script..


    but i really really want it..
     
    #19
  20. Khas

    Khas Detective lv73 Veteran

    Messages:
    282
    Likes Received:
    374
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    I solved the bug related to events! Please re-download the plugin (KhasCore.js) and update it.


    @nio kasgami Thanks for the suggestion! I contact Quxios and I'll try what he suggested.


    @What? What happens when you try to access my blog? Have you tried this link?
     
    Last edited by a moderator: Jan 23, 2017
    #20
    killerfer likes this.

Share This Page