kultie

Villager
Member
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)
Screen Shot 2020-01-06 at 9.55.30 AM.png
After some tweak and i got it technically work like this for RMMV (This is position of (0,0))
Screen Shot 2020-01-06 at 9.52.41 AM.png
But if I change to position of (0.5,0.5) - center of map it's got offset like this:
Screen Shot 2020-01-06 at 9.58.51 AM.png
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:

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
421
First Language
Portuguese
Primarily Uses
RMMV
you are using the game map's width, not the game screen's.
it can be useful, of course, but that is the cause of your problem.
 

kultie

Villager
Member
Joined
Jul 2, 2018
Messages
14
Reaction score
1
First Language
English
Primarily Uses
RMMV
@Waterguy Yeah after some digging in for the PIXI 4.5.4 version of FilterManager i've learn it
What I used for 5.2 was uniform of resolution that i pass it in, and somehow that 5.2 let's me do it the way I've done it with standard glsl.
But in 4.5.4 all I need was built-in uniform called filterArea that have the screen dimension of xy parts.
So when I pass in pos I need to divided it with filterArea.xy. Man should've read document more carefully and not banging my head hoping Kadakawa will upgrade pixi library form 4.54 to 5.2 :kaoswt2:

And now I have to remake my shader plugin to properly resolve this issues :kaocry:
Oh and i found the way to add 1 more sampler to the shader too, still don't know how to add more than 1 tho since i guess the matrix use for each sprite only
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

RPG Maker MZ just crashed, please tell me I didn't just lose 4 hours of progress.
>be me with a separate game for testing
>NPC doesn't stay in new position after leaving the map
>looking for tutorials, nothing useful
>checks plugin of save even location and installs it
>testing the game

"Oh... IT'S WORKING, IT'S ACTUALLY WORKING!!"
My current peak of boss design.
energy drinks have made this week SUPER productive so far lol. I finished one of my overworld maps, along with 2 other maps and a way to traverse to said overworld map.
i am absolutely DRAGGING MYSELF RIGHT NOW, i bought a commission ($35) back in october, got the art back, it was great, only to NOW realize i never DOWNLOADED it to my computer, and the site i used auto-deletes uploads after 3 months. Now i'm panicking cuz she closed all her commissions on that site & deleted her IG and Facebook, luckily I found her g-mail but who knows if she'll respond :kaocry: pray for me ya'll

Forum statistics

Threads
109,031
Messages
1,041,388
Members
141,510
Latest member
markkk
Top