- Joined
- Jul 2, 2018
- Messages
- 14
- Reaction score
- 1
- First Language
- English
- Primarily Uses
- RMMV
Hi makers, currently i'm trying to make a filter plugin for my game and i'm trying to make a filter to limit vision of player when on map so something like this (This is made with newest version of PIXI 5.2)

After some tweak and i got it technically work like this for RMMV (This is position of (0,0))

But if I change to position of (0.5,0.5) - center of map it's got offset like this:

Are there any matrix or some thing about dimension I don't know when using shader code inside RMMV? The first image i got it working with mouse position and it's perfectly fine.
For some rough explanation about shader code and js here what i come up with:
Can anyone help me with this? I'm fairly new with RMMV and I don't know how or why the PIXI's filter working difference between PIXI 5.2 and RMMV(1.6.1) PIXI 4.5.4
And also how do I add more sampler to the shader?
EDIT: Just downgrade my standalone PIXI from 5.2 to 4.5.4 and have same issue, so yeah this not RMMV fault, but if someone have any idea about this halp plox

After some tweak and i got it technically work like this for RMMV (This is position of (0,0))

But if I change to position of (0.5,0.5) - center of map it's got offset like this:

Are there any matrix or some thing about dimension I don't know when using shader code inside RMMV? The first image i got it working with mouse position and it's perfectly fine.
For some rough explanation about shader code and js here what i come up with:
Code:
limitVisionShader = `
precision mediump float;
varying vec2 vTextureCoord;
uniform sampler2D uSampler;
uniform vec2 iResolution;
uniform float iTime;
uniform vec2 pos;
vec4 limitVision(vec2 st, vec2 pos, float radius){
float pct = 1. - smoothstep(0., radius ,distance(st,vec2(pos)));
return vec4(pct);
}
vec4 norctunalVision(vec2 st, vec2 pos){
vec4 col = limitVision(st, pos, .2);
vec4 tex = texture2D(uSampler,st);
vec4 result = mix(col,tex,col.a);
vec4 tex2 = vec4(0.,0.,0.,1.);
tex2.rgb /= 5.;
result = mix(result,tex2,1. - col.a);
return result;
}
void main(){
vec2 uv = vTextureCoord;
// uv *= resolution.x/resolution.y;
vec4 col = norctunalVision(uv, vec2(.5,.5)); //Replace vec2(.5,.5) to pos for reflect chaging of character posiiton
gl_FragColor = col;
}
`
Code:
//Scene_Map
Scene_Map.prototype.createNortunalVision = function(){
this._visionFilter = Kultie_FilterManager.createFilter(false,limitVisionShader,{pos:[.5,.5]});
this._spriteset.filters = [this._visionFilter];
}
Kultie.BNBattleSystem.Scene_Map_update = Scene_Map.prototype.update;
Scene_Map.prototype.update = function(){
if(this._visionFilter){
this._visionFilter.uniforms.pos = [$gamePlayer._x/$gameMap.width(), $gamePlayer._y/$gameMap.height()];
this._visionFilter.uniforms.iTime += Kultie.Utils.getDeltaTime();
}
Kultie.BNBattleSystem.Scene_Map_update.call(this);
}
Can anyone help me with this? I'm fairly new with RMMV and I don't know how or why the PIXI's filter working difference between PIXI 5.2 and RMMV(1.6.1) PIXI 4.5.4
And also how do I add more sampler to the shader?
EDIT: Just downgrade my standalone PIXI from 5.2 to 4.5.4 and have same issue, so yeah this not RMMV fault, but if someone have any idea about this halp plox
Last edited: