-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEBBattleBack.js
75 lines (63 loc) · 2.14 KB
/
EBBattleBack.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//=============================================================================
// RPG Maker MZ - Earthbound battle backgrounds
//=============================================================================
/*:
* @target MZ
* @plugindesc [MZ] [Battle]
* @author Eden
* @url https://github.com/ashifolfi/RMMZ-Plugins
*
* @help
* Replaces the battle backgrounds with earthbound style effects.
*/
const shdBack1 = `
varying vec2 vTextureCoord;
uniform sampler2D uSampler;
uniform float amp;
uniform float freq;
uniform float time;
void main(void)
{
vec2 new_uv = vTextureCoord;
if (vTextureCoord.y > 0.44)
{
new_uv.x += sin(freq * vTextureCoord.y + time) / amp;
}
// Texel color fetching from texture sampler
gl_FragColor = texture2D(uSampler, new_uv);
}
`;
const shdVertOsc = `
varying vec2 vTextureCoord;
uniform sampler2D uSampler;
uniform float amp;
uniform float freq;
uniform float time;
void main(void)
{
vec2 new_uv = vTextureCoord;
new_uv.y += sin(freq * vTextureCoord.y + time) / amp;
// Texel color fetching from texture sampler
gl_FragColor = texture2D(uSampler, new_uv);
}
`;
(function() {
// required or else graphics look weird on sine wave
PIXI.settings.WRAP_MODE = PIXI.WRAP_MODES.REPEAT;
Spriteset_Battle.prototype.createBattlebackOg = Spriteset_Battle.prototype.createBattleback;
Spriteset_Battle.prototype.createBattleback = function()
{
this.createBattlebackOg();
this._back1Filter = new PIXI.Filter(undefined, shdBack1, {time: 0.0, amp: 5.0, freq: 10.0});
this._back2Filter = new PIXI.Filter(undefined, shdVertOsc, {time: 0.0, amp: 30.0, freq: 8.0});
this._back1Sprite.filters = [this._back1Filter];
this._back2Sprite.filters = [this._back2Filter];
};
Spriteset_Battle.prototype.updateBattlebackOg = Spriteset_Battle.prototype.updateBattleback;
Spriteset_Battle.prototype.updateBattleback = function()
{
this.updateBattlebackOg();
this._back1Filter.uniforms.time += 0.01;
this._back2Filter.uniforms.time += 0.01;
};
})();