RMMV Tried simultaneously rendering two versions of a map for a DIY masking-based lighting plugin. Got 8 FPS [RESOLVED]

Status
Not open for further replies.

Gensun

Veteran
Veteran
Joined
Feb 4, 2019
Messages
114
Reaction score
91
First Language
English
Primarily Uses
RMMV
So I'm aiming for a horror game which I need to start getting gud with lighting. My goal is to make a lighting plugin that works by having all tiles and sprites having a "lit" and "unlit" version each rendered on to a lit/unlit layer respectively. Then, a transparent mask applied on the "unlit" layer.

The strengths I'm expecting out of using this method over shaders:
  • Possibility of making tiles that have details visible only when lit or vice-versa
  • Possibility of using contrasting art styles between lit and unlit layers
  • Absolute control over color pallet
Obv my window colors can be picked better but here's an example picture to illustrate what I'm aiming for.
Masking.png

The scripts I have so far lets me set a secondary tileset with a notetag of <Unlit:tilesetId> so I could map with tileset index 2 but index 3 would be the unlit version of that same tileset.

So far I have scripts that has additional new layers, they correctly render my (lit) tileset #1 underneath my (unlit) tileset #2, though I don't have code for drawing my character sprites yet so my characters are invisible if tileset #2 is visible.

I can fiddle around so it renders either only tileset #1 or tileset #2 and the FPS would be fine. When I render both, it chugs at a 4 or 8 FPS with no other plugins. Anyone with graphics programming experience know what could be causing this slowdown?
4FPS.png

Attached my sad plugin to this thread lol. Throw it into a blank project, write <Unlit:2> in the notebox for the starting map and watch it burn. If this method is a dead end, I'll have to try parallax mapping

Update:
Updating NWJS doesn't do anything obvious aside for locking me from pulling up the console via F12. Updating PIXI also breaks the game and the game tries calling functions that don't exist

Update 2:
Tried another approach where lit and unlit versions are on the same tileset rather than trying to render two tilesets at a same time. The lag problem so far is gone. Will post updates if the finished plugin might produce another lag problem later
 

Attachments

  • Gensun_maskLighting.js
    17.1 KB · Views: 1
Last edited:

Gensun

Veteran
Veteran
Joined
Feb 4, 2019
Messages
114
Reaction score
91
First Language
English
Primarily Uses
RMMV
I'm really close.
After restructuring my assets and the code so lit and unlit versions are on the same tileset, I found out that I can just assign a PIXI.Graphics object to the map scene's Shader_Tilemap object responsible for handling the game map's rendering.

I got a masking effect working in my prototype but when I try creating this mask in the script, it has no effect. The only methods I can get a masking effect up and running is by calling it via a script call in an event that triggers by interaction. If I put it on a parallel process with an Erase Event command at the end, it works if I add a 4-frame wait, but not a 3-frame wait.

So far I'm trying to pinpoint the render method of my lit layer so I can figure out why a mask is not being properly applied here.
 

Attachments

  • 2022_6_30_20_37_27_633_4199.png
    2022_6_30_20_37_27_633_4199.png
    20.7 KB · Views: 1
  • 1656646831731.png
    1656646831731.png
    113.7 KB · Views: 1
Last edited:

Gensun

Veteran
Veteran
Joined
Feb 4, 2019
Messages
114
Reaction score
91
First Language
English
Primarily Uses
RMMV
Took a while but I managed to get my desired lighting plugin working!
For whatever reason my masking layer needs to be applied after 1/8th second wait after loading otherwise the mask gets ignored. I can't figure out why and nothing in PIXI's documentation says anything. Oh well, I will just code around my tech limits and will accept a slightly longer load time.

Broom2.gif
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
9,943
Reaction score
6,304
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts


Clarn Hold
(No storylines)
There was a tutorial on how to draw anime eyes. Just draw Among Us. So I tried.
Screenshot_107.jpg
DamageActor3_7.png added!
index.php

Making a "characters first appearance" drawing for my game. Now I just have to finish the sprite art animation for her grand entrance.​
ScreenShot_9_24_2022_7_56_24.png
New area being started today. It leads to one of the games 2 optional bosses.

Forum statistics

Threads
125,540
Messages
1,171,816
Members
164,613
Latest member
dulichvungtaudl3m
Top