Khas Advanced Graphics (deferred lighting and procedurally generated fog)

Oh, I really like this! Too bad about the dynamic shadows though, I would've killed to get that feature into MV. But besides that it looks great.
I'm currently using Terrax Lightning but I'll download this and compare it in my project and might end up switching over! You do have some sweet fog stuff going on there as cream on the cake after all 😉
@Skurge I'll see if I can make it compatible with old pixi versions.

@Parallax Panda Thank you! I'll give the dynamic shadows another try soon 🙂
Sounds tremendous, I think fog and such would make my game look INCREDIBLE.
How heavy is this for game system? Would there be possibility to add "turn off" function in the options? My game is quite heavy, this may be too much for some people.

Also, is this compatible with Terrax?

https://forums.rpgmakerweb.com/index.php?threads/terrax-lighting-system.49339/
@Tuomo L this should be the fastest lighting plugin available for MV. It handles the heavy party to the GPU entirely, but it requires WebGL. The fog may be a bit of performance intensive (but it's done entirely in the GPU), so I'll add settings (off, low, medium, high) on the next release. The CPU load added by this plugin is minimal.

I don't know if it's compatible with Terrax, but I see no point in having two lighting scripts in a single project.
I don't know if it's compatible with Terrax, but I see no point in having two lighting scripts in a single project.

I actually prefer Terrax lightning effects and I already have them set up for my game, (which is FAR into production) I was mostly just looking for the procedually generated fog.
What do you think the benefits and downsides of this plugin are in comparrison to Terrax's lighting plugin?
Both are under alot of construction but I gather your plugin does not utilize terrain/region tag lighting?
@Tuomo L Sorry, my bad! It would be a lot of work to switch indeed. I don't know if they work together, so you'll have to test 🙂

@Skurge Good question! Some of the benefits are a matter of personal preference (like style and feel, or easiness of use), some are big differences and can be measured. I listed some of them below:

Advantages:
* The fastest lighting plugin: the Advanced Graphics lets the GPU do the intensive work (with WebGL), leaving minimal load on the CPU. This is usually how modern, non-RPG Maker games do, which is more reliable and fast. I did a quick benchmark, the map has exactly the same size and events, but if you don't trust my test you can easily do one by yourself and see the difference.

I used these two lights:
benchmark lights.png

I tested this on my laptop (i7 5500u + GTX950M), and the results are the following (I didn't count how many lights, but there's the same number in both maps!).

benchmark - khas.jpg

3 milliseconds per frame, which means up to ~330fps(but it's capped @60fps). Smooth and reliable gameplay.

benchmark - terrax.JPG

341 milliseconds per frame, which means ~3fps. Unplayable.

Of course most people wouldn't end up with these many lights, but my plugin barely impacts your game's performance. And please note that the procedural fog is a bit performance intensive (but it doesn't affect lighting performance!), so old GPUs may not be able to run fog this fast. I'll add menu options for low, medium and high graphics settings to compensate this in the next release.

* Easier to use: lights are defined in the plugin and you just need to add a quick comment on any event to add a light. Then, if you have 100 lights of the same type across several maps and you want to change it's graphic or something, you just need to change the light definition instead of changing every single light again. You'll get more productive this way and it's easier to tweak your lights!

* Lights can be of any color/shape/size: your creativity is the limit with this one. My plugin uses images to create lights, so you can create lights for anything (you can simulate windows, car lights, or anything that is more complex than a circular light). Also this allows you to easily change the size of any light. Let's say you need to increase the size of all the torches in your game: you just need to increase the size of the torch image!

* Intuitive light control: a light is active (ON) when the page of its comment is active. You don't need to use complicated commands and the light's names are very intuitive (instead of using hex colors, you actually use a light name as halogen, torch, green_torch, and so on).

* Custom blending: I implemented another blending equation to blend lights together, so you have two styles to choose from.

This is my fourth lighting/graphics plugin (1. Neo Light Effects for VX, 2. Awesome Light Effects for VX Ace, 3. Ultra Lighting for VX Ace), so I have a lot of experience and I put a lot of effort in this one. I'll continue to improve it over time and I'll add new features. I'm already working on terrain tags/region lighting, so it'll be available soon.

Disadvantages:
Terrax is already in many projects, so it's a lot of work to switch plugins.

My plugin requires WebGL. I don't know if Terrax requires it as well.
This plugin looks sick!!! this is most stupidest question on here..but what is WebGL and how do I get it xD
@SoSick. Thank you! The RPG Maker MV uses the Pixi.js library, which offers two ways of rendering stuff on the screen: the WebGL renderer and the Canvas renderer. When you start a game, Pixi will try to use the WebGL renderer if it's available (it's usually available, you will find more information here: https://rpgmakermv.co/threads/possible-mv-lag-solution.466/). And WebGL is a graphics rendering API, which allows programmers to implement modern rendering techniques using shaders. My plugin uses shaders to process the lights, so that's why it requires WebGL.

I'm sorry if this sounds confusing, it's a bit hard to explain in a simple way. If your computer is not old, there's a very small chance WebGL won't be available, but you don't need to worry about it.
@Khas Thanks for the information, i downloaded your demo, works fine! thank god my laptop is not pants, and transferred some events the pixi.js and after removing some plugins such as hudell lighting ( it did not like any of his plugins really ) xD and some small other's its now working in my project! i use hudell time system so i hope i can use your lighting system with that. Only one problem i have really, i use custom background images for my menu's.. now all the backgrounds are black.. haha. But this is so worth all these little problems, will take rpg maker mv games to another level. Super stuff.
p.s pressed f8 in play test am i suppose to see this image in console?
p.s.s would love to see a 'low fog' option ;D haha.
@SoSick. Nice! I never heard about problems with the menus (and there shouldn't be any), but if you can't manage to fix them, please let me know and I'll check if it's the script's fault. And my console looks exactly like yours 🙂
I noticed that there is a plugin command to give a player a flashlight, but after clicking all the events and reading the help. I cannot locate a plugin command to give an event a flashlight.

Ex:
The event is a cut scene, I want to make a character inside that cut scene turn on a flashlight after taking a couple steps forward. This character is not a player character, so I cannot do - PlayerLantern flashlight. I tried EventLatern flashlight, hoping that perhaps there was already a command, but that did not work.

Is there something I missed in the Demo, or in the help file?

Thanks!

Edit:

Also, I noticed a conflict between this plugin, and the GALV_MessageBust plugin. They both seem to use the same layer for fog, and message bust. Is there a way to fix that?

Edit Edit:

It seems that it might not be the fog layer that is being shared, it could be the darkness layer that is being shared.
@Izzybelle there's an easier way to do this instead of using commands. You just need to make this event have two pages, one without comments, the other with [light flashlight]. Then, use a switch to change between the two pages, and there you have it!

I'll take a look into this issue. I also added some new questions to the FAQ, including this one:

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.
I thought it might be a good idea to provide you with an image.

This Image is as followed, the first screenshot is with GALV_MessageBusts setting the message bust above the dialogue box. While the second box is with the setting to put it below the message box.

Edit: Which is somehow putting the darkness and the image in the same place, or using the same deferred thing?

Edit Edit: The map is a work in progress, no one judge me. xD

Edit Edit Edit: It's not letting me place a thumbnail into the edit. I have no idea why. Here is another issue where when I try to do the solution you suggested. (Use switches) The event tries turning off the flashlight, and gives me this error. Instead keeping the flashlight on.

unknown.png
@Izzybelle, you could do what Khas said, like this:

Use:
- The event that will be the character that will use the flashlight
- Autorun Event to control the scene

1 - Character Event will have more than one page, the first one that will do nothing,
if he has to walk or anything control that with the autorun event.

2 - Second page will have to be triggered by a switch, which you will turn on using the
autorun event (And on this new page, you will write [light flashlight] as a comment, like a
lamp post from the demo).

3 - The autorun event continue to control the scene until you don't want the flashlight, so you
can either turn off the switch and go back to the first event page or do another page and trigger
it with another switch. You don't have to tell the flashlight to turn off, just change back the event pages.

(Hope I was clear =DDD)
@Izzybelle thanks for the pics! I believe galv's plugin puts the bust in the map's layer, so it gets processed with the map's contents. I will take a deep look this weekend 🙂

And please check @luiscesjr response above, the instructions should be clearer now 🙂

@luiscesjr obrigado cara!
@Izzybelle, you could do what Khas said, like this:

Use:
- The event that will be the character that will use the flashlight
- Autorun Event to control the scene

1 - Character Event will have more than one page, the first one that will do nothing,
if he has to walk or anything control that with the autorun event.

2 - Second page will have to be triggered by a switch, which you will turn on using the
autorun event (And on this new page, you will write [light flashlight] as a comment, like a
lamp post from the demo).

3 - The autorun event continue to control the scene until you don't want the flashlight, so you
can either turn off the switch and go back to the first event page or do another page and trigger
it with another switch. You don't have to tell the flashlight to turn off, just change back the event pages.

(Hope I was clear =DDD)

Thanks for the reply.

That was already how I had done the event and switches. The above was not the conflict I was having.

To quote myself:
The event tries turning off the flashlight, and gives me this error. <- This may have been poorly described.

The flashlight turns on fine and correctly. That is not the issue. The problem that I am having is that no matter what I do: Making a second switch, making extra character pages, switching back to original character pages. The flashlight will not turn off. The flashlight continues to stay on, even when the page is switched to another, and the prior switch is turned off.

I even tried commands such as [light off] etc.. It doesn't seem to want to turn off the light.

Edit: Example. In the event. The event character is handing the player character a flashlight. During this process, they're turning the flashlight off and handing it to the player character. When I attempt to turn the flashlight off, It pops up the above error message, then continues play. The player ends up with a flashlight, and the event continues to hold a flashlight.
@Izzybelle I found the bug you're talking about. Will be fixed in the next release (and I will include an event with this example in the demo). Thanks for explaining it better, I'm sorry I didn't understand it at first.

Edit: fixed! I forgot to put a command to delete the light when switching pages, my bad!
Hey Khas,
i'm having a problem with pictures being displayed below the ambient light.
For example, in my game I'm currently trying to implement a torch that can be switched on and of while a switch is active.
Additionally, when turning that switch on a pictures is being shown. But as the ambient light is above the picture, it is hardly visible.

I tried looking into your plugin but I'm no scripter, so I need a little advice on where to look for the part that determines on which z-layer your plugin draws the ambient light.

Original thread: https://forums.rpgmakerweb.com/threads/khas-advanced-graphics-deferred-lighting-and-procedurally-generated-fog.73911/