alter-egoism/js/plugins/CBR_fade.js
2025-11-01 14:17:42 -05:00

60 lines
No EOL
1.7 KiB
JavaScript

Scene_Map.prototype.fadeSpeed = function() {
return 24 / 24;
};
Sprite_Picture.prototype.updateOther = function() {
const picture = this.picture();
this.opacity = picture.opacity();
this.blendMode = picture.blendMode();
this.rotation = (picture.angle() * Math.PI) / 180;
if(this.visible && this._pictureId == 20){
var v = $gameVariables.value(113);
var t = 30;
var filter = new PIXI.filters.fadeInFilter();
filter.uniforms.key1 = v;//現在の時間
filter.uniforms.key2 = t;//全体にかかる時間
this.filters = [filter];
if($gameSwitches.value(140) && v < t){
v++;
$gameVariables.setValue(113, v);
}else if(!$gameSwitches.value(140) && 0 < v){
v--;
$gameVariables.setValue(113, v);
}
}
};
// フェードイン
PIXI.filters.fadeInFilter = function () {
var fragmentSrc = [
'precision lowp float;',
'uniform float key1;',//0~100
'uniform float key2;',//0~100
'uniform sampler2D uSampler;',
'varying vec2 vTextureCoord;',
"vec4 mapCoord( vec2 coord, vec4 color ){",
"return vec4(0, 0, 0, color.a + key1 / key2 * 2.0 - 1.0);",
"}",
"void main(){",
"vec4 color_o = texture2D(uSampler, vTextureCoord);",
"vec4 color = mapCoord(gl_FragCoord.xy, color_o);",
"gl_FragColor = vec4(color);",
"}"
];
PIXI.Filter.call(this,
null, // vertex shader
fragmentSrc.join('\n'), // fragment shader
{t:0.0} // uniforms
);
};
PIXI.filters.fadeInFilter.prototype = Object.create(PIXI.Filter.prototype);
PIXI.filters.fadeInFilter.prototype.constructor = PIXI.filters.fadeFilter;