wltr3565

Veteran
Veteran
Joined
Sep 20, 2012
Messages
35
Reaction score
5
First Language
Indonesian
Primarily Uses
I use a lot of custom scripts for my team's project. While there are many good improvements in this latest version, 1.6.0, other things have become worse.

The Scene_Battle of my team's project has both the Actors and Enemies all animated with a lot of sprite sheets and all. When more than 1 of them have their blendColor to [255, 255, 255, 108], the FPS drops. With more than 3 of them being highlighted, the FPS can drop to 1.

As I investigate further about the cause, it appears to happen mainly within rpg_core.js line 4197, where the color blending is handled. When it is disabled, the FPS returned to normal. While the FPS drop happens, I tried to reduce the game's window size to reduce the GPU load. But the FPS drop is still as bad as while in fullscreen, which makes me think that this is a CPU problem.

The thing is, the highlighting, which is why I use .setBlendColor, is important for the game's interface. This is not an easy function to remove to sustain FPS. Is there any way to make the color blending more efficient to the CPU within rpg_core.js line 4197, especially for animated Sprite objects that constantly activates the .refresh() function as it changes frames? Minimizing any instances of .refresh() to happen is not an option considering the battler sprites animate all the time.
 

Solis

Veteran
Veteran
Joined
Oct 24, 2015
Messages
376
Reaction score
84
First Language
English
If you're using any plugins, you should check those. There's been several reports saying that MANY of the plugins were affected and are not viable with 1.6.0.
 

wltr3565

Veteran
Veteran
Joined
Sep 20, 2012
Messages
35
Reaction score
5
First Language
Indonesian
Primarily Uses
I have done necessary version adaptations, most of them are just obsolete functions. But I think this problem persists even before 1.6.0 because the functions regarding Sprite barely receive any change.

Back to topic, I actually tried to minimize the burden by disabling several routines within _executeTint, and yes, it does reduce the CPU load. I simply applied this to one of my own plugins:
Code:
Sprite.prototype._executeTint = function(x, y, w, h) {
    var context = this._context;
    var tone = this._colorTone;
    var color = this._blendColor;

    context.globalCompositeOperation = 'copy';
    context.drawImage(this._bitmap.canvas, x, y, w, h, 0, 0, w, h);
/*
    if (Graphics.canUseSaturationBlend()) {
        var gray = Math.max(0, tone[3]);
        context.globalCompositeOperation = 'saturation';
        context.fillStyle = 'rgba(255,255,255,' + gray / 255 + ')';
        context.fillRect(0, 0, w, h);
    }

    var r1 = Math.max(0, tone[0]);
    var g1 = Math.max(0, tone[1]);
    var b1 = Math.max(0, tone[2]);
    context.globalCompositeOperation = 'lighter';
    context.fillStyle = Utils.rgbToCssColor(r1, g1, b1);
    context.fillRect(0, 0, w, h);

    if (Graphics.canUseDifferenceBlend()) {
        context.globalCompositeOperation = 'difference';
        context.fillStyle = 'white';
        context.fillRect(0, 0, w, h);

        var r2 = Math.max(0, -tone[0]);
        var g2 = Math.max(0, -tone[1]);
        var b2 = Math.max(0, -tone[2]);
        context.globalCompositeOperation = 'lighter';
        context.fillStyle = Utils.rgbToCssColor(r2, g2, b2);
        context.fillRect(0, 0, w, h);

        context.globalCompositeOperation = 'difference';
        context.fillStyle = 'white';
        context.fillRect(0, 0, w, h);
    }
*/
    var r3 = Math.max(0, color[0]);
    var g3 = Math.max(0, color[1]);
    var b3 = Math.max(0, color[2]);
    var a3 = Math.max(0, color[3]);
    context.globalCompositeOperation = 'source-atop';
    context.fillStyle = Utils.rgbToCssColor(r3, g3, b3);
    context.globalAlpha = a3 / 255;
    context.fillRect(0, 0, w, h);

    context.globalCompositeOperation = 'destination-in';
    context.globalAlpha = 1;
    context.drawImage(this._bitmap.canvas, x, y, w, h, 0, 0, w, h);
};
But surely there should be a more elegant way that does not require any cuts to the functions available. Is there any way to make this actual function more efficient, or for now, should I just resort to putting conditions to make them not active when not needed?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
34,273
Reaction score
8,726
First Language
German
Primarily Uses
RMMV
Mathematical color shifts have always been extremely resource intensive. They were only used often historically because there was a time when the RAM limitations were a lot higher than today...

Can you think of an other way of highlighting?
 

Latest Threads

Latest Posts

Latest Profile Posts

Just lost about half a day's worth of work because rpg maker crashed during playtesting and corrupted my file :kaolivid:
Boku.gif
advanced_puzzling.PNG
Having a lot of fun making different poses for my character sets! Open to suggestions/critique!

CSKttqh.png

AABS laser beams features:
1,Shoot penetrating laser beams for player's normal attack
2,Beam's width/damage/comsumes/loot can be controlled by events/variables with great flexibility
3,Beam can rebound to walls or certain regionID
4,Can play SE when shooting beams
5,Beam's images can be solid images or animated ones.
Surprising nobody, it turns out "next Friday" for the next Jump into Javascript has become "possibly Sunday if you're lucky" XD

Forum statistics

Threads
117,017
Messages
1,103,870
Members
152,917
Latest member
Adversary
Top