MZ Trying to use PIXI to load a A GLSL Fragment Shader.

I'm at a complete loss on how to make such a thing function, basically im trying to run this shader
https://github.com/Rudranil-Sarkar/Ordered-Dithering-Shader-GLSL using this plugin
I can throw some cash your way if you are down to help
Oh hey I was doing this very thing yesterday

Let me take a look at what you're trying to do.

What have you tried so far?
Oh hey I was doing this very thing yesterday

Let me take a look at what you're trying to do.

What have you tried so far?
I've not tried anything yet, beyond getting pixi to work in my project. I've just a general idea of what I should do based on advice i was given, i've not got any coding knowledge. I was told i should attempt is to combine a fragment shader with pixi default shaders. My end goal is a real time dither for a for a first person dungeon crawler.

screen cap of said advice, maybe someone can make sense of it

1666093417591.png
1666093388150.png

screen cap of my game, right now i dither all the assets by hand but i would prefer to do the real time option.
RMMZ's scenes, sprites, and spritesets all inherit PIXI's filters property, so you should be able to "simply" add a new PIXI.Filter to the filters array of the appropriate display object(s). That'll probably need a custom little plugin, though...I don't know if the one you linked to lets users define custom filters in its parameters.

Technical example: the built-in ColorFilter (rmmz_core.js) has custom GLSL and is applied to RMMZ's Sprite wrapper as well as Spriteset_Base and Scene_Base.
This is a custom shader/filter for gradients on sprites, maybe the setup will be helpful in figuring out what to do for yours.

JavaScript:
class GradientColorFilter extends PIXI.Filter {
  constructor(color1, color2) {
    super(null,
      varying vec2 vTextureCoord;
      uniform sampler2D uSampler;
      uniform vec4 color1;
      uniform vec4 color2;

      void main(void) {
        vec4 color = mix(color1, color2, vTextureCoord.x + vTextureCoord.y);
        vec4 sample = texture2D(uSampler, vTextureCoord);
        gl_FragColor = vec4(color * sample.a);
      });

  this.uniforms.color1 = color1;
  this.uniforms.color2 = color2;
  }
}
i appreciate the responses bros but i know absolutely 0 about coding, this might as well be Chinese to me. that’s why i was offering to pay for help
Good news: I've attached li'l plugin that adds a filter to the map scene. The filter applies to all map sprites, including tiles, but not the window layer. You can customise the vertex and/or fragment shaders directly from its parameters in the Plugin Manager~
Spoiler: plugin code
JavaScript:
/*:
 * @target MZ
 * @plugindesc Custom always-on filter for map spriteset.
 * @url https://forums.rpgmakerweb.com/index.php?threads/152047/
 * @help Free to use and/or modify for any project, no credit required.
 * 
 * @param Vertex Shader
 * @type multiline_string
 * @desc Custom vertex shader. Leave blank for default.
 * @default
 *
 * @param Fragment Shader
 * @type multiline_string
 * @desc Custom fragment shader. Leave blank for default.
 * @default
 */

void (alias => {
'use strict';

  // ===== Read parameters ===== //

  const PLUGIN_NAME = 'MapFilter';

  const P = PluginManager.parameters(PLUGIN_NAME);
  const VERT = P['Vertex Shader'] || null;
  const FRAG = P['Fragment Shader'] || null;

  // ====== Define filter ====== //

  const F = globalThis.DitherFilter = function() {
    this.initialize(...arguments);
  };

  F.prototype = Object.create(PIXI.Filter.prototype);
  F.prototype.constructor = F;

  F.prototype.initialize = function() {
    PIXI.Filter.call(this, this._vertexSrc(), this._fragmentSrc());
  };

  F.prototype._vertexSrc   = function() { return VERT; };  
  F.prototype._fragmentSrc = function() { return FRAG; };

  // === Attach to spriteset === //

  Spriteset_Map.prototype.createOverallFilters = function() {
    alias.apply(this, arguments);
    this.filters.push(this._ditherFilter = new F());
  };

})(Spriteset_Map.prototype.createOverallFilters);
I don't know whether it'll play nice with the other plugins you may be using, but it worked OK for me when I tested with this in its Fragment Shader parameter (this is not a dither filter):

varying vec2 vTextureCoord; uniform sampler2D uSampler; void main() { vec4 color = texture2D(uSampler, vTextureCoord); float average = (color.r + color.g + color.b) / 3.0; gl_FragColor = vec4(vec3(average * 10.0 - 5.0), color.a); }
Bad news: I think you'll need different shader code, because the example you've linked doesn't work with WebGL...I don't know how much editing it would need to be compatible. WebGL doesn't support all features of OpenGL. 😴

Note that offers of payment should only be made on the paid request boards:
Classifieds are locked for newer members (I'm not sure of the exact requirements), so you may need to wait/contribute a bit around the site before you're allowed to post there.
Good news: I've attached li'l plugin that adds a filter to the map scene. The filter applies to all map sprites, including tiles, but not the window layer. You can customise the vertex and/or fragment shaders directly from its parameters in the Plugin Manager~
Spoiler: plugin code
JavaScript:
/*:
 * @target MZ
 * @plugindesc Custom always-on filter for map spriteset.
 * @url https://forums.rpgmakerweb.com/index.php?threads/152047/
 * @help Free to use and/or modify for any project, no credit required.
 *
 * @param Vertex Shader
 * @type multiline_string
 * @desc Custom vertex shader. Leave blank for default.
 * @default
 *
 * @param Fragment Shader
 * @type multiline_string
 * @desc Custom fragment shader. Leave blank for default.
 * @default
 */

void (alias => {
'use strict';

  // ===== Read parameters ===== //

  const PLUGIN_NAME = 'MapFilter';

  const P = PluginManager.parameters(PLUGIN_NAME);
  const VERT = P['Vertex Shader'] || null;
  const FRAG = P['Fragment Shader'] || null;

  // ====== Define filter ====== //

  const F = globalThis.DitherFilter = function() {
    this.initialize(...arguments);
  };

  F.prototype = Object.create(PIXI.Filter.prototype);
  F.prototype.constructor = F;

  F.prototype.initialize = function() {
    PIXI.Filter.call(this, this._vertexSrc(), this._fragmentSrc());
  };

  F.prototype._vertexSrc   = function() { return VERT; };
  F.prototype._fragmentSrc = function() { return FRAG; };

  // === Attach to spriteset === //

  Spriteset_Map.prototype.createOverallFilters = function() {
    alias.apply(this, arguments);
    this.filters.push(this._ditherFilter = new F());
  };

})(Spriteset_Map.prototype.createOverallFilters);
I don't know whether it'll play nice with the other plugins you may be using, but it worked OK for me when I tested with this in its Fragment Shader parameter (this is not a dither filter):

varying vec2 vTextureCoord; uniform sampler2D uSampler; void main() { vec4 color = texture2D(uSampler, vTextureCoord); float average = (color.r + color.g + color.b) / 3.0; gl_FragColor = vec4(vec3(average * 10.0 - 5.0), color.a); }

Bad news: I think you'll need different shader code, because the example you've linked doesn't work with WebGL...I don't know how much editing it would need to be compatible. WebGL doesn't support all features of OpenGL. 😴

Note that offers of payment should only be made on the paid request boards:
Classifieds are locked for newer members (I'm not sure of the exact requirements), so you may need to wait/contribute a bit around the site before you're allowed to post there.
Thank you for sending this and sorry for late response, I ended up working on other things while waiting to come back to this.
It does work, with the example param you sent which is black and white. How do i go about using this to get a dithered effect? is it as simple as finding a webgl compatible dither shader code on github and dropping it in the param?

Sorry for asking a lot of questions, i don't know anything about code

can this be used in anyway?
It does work, with the example param you sent which is black and white. How do i go about using this to get a dithered effect? is it as simple as finding a webgl compatible dither shader code on github and dropping it in the param?
Yes, if you find a WebGL shader written for MZ's version of PIXI.js, then you may be able to just copy+paste it into the parameter. This one is WebGL, which is a good start, but it isn't written for PIXI and it expects custom uniforms, which are basically shader parameters that can be updated during runtime to change how it looks. (My little plugin is too simple to handle any inputs other than PIXI's defaults.)

Fortunately, after making a few small edits I think I've got it working. Try pasting this into the Fragment Shader parameter of the plugin I posted earlier (leave the Vertex Shader blank):
Spoiler: Modified dither fragment shader
precision mediump float; // PIXI UNIFORMS varying vec2 vTextureCoord; uniform sampler2D uSampler; // CUSTOM VARIABLES lowp float f_dither = 0.8; lowp float f_scale = 0.01; lowp mat4 m4_ptn1 = mat4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0); lowp mat4 m4_ptn2 = mat4(1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0); lowp mat4 m4_ptn3 = mat4(0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0); lowp mat4 m4_ptn4 = mat4(1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0); lowp mat4 m4_ptn5 = mat4(1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0); lowp mat4 m4_ptn6 = mat4(0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0); lowp mat4 m4_ptn7 = mat4(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0); // SYSTEM METHOD void main(void) { // GRAB PIXEL INFO lowp vec4 v4_pixel = texture2D(uSampler, vTextureCoord); // SCALE COMES THROUGH AS A PERCENTAGE (0.00 - 1.00) - REQUESTED USE-CASE vec4 v4_scaled = vec4(f_scale * 100.0); // CHEAT - CREATES SCALED VIRTUAL PIXELS FROM SCALE VALUE AT PIXEL XY IN WINDOW SPACE // V4_X USED AS MATRIX MULTIPLIER TO REMOVE MATRIX ACCESSOR lowp vec4 v4_x = step(vec4(3.0, 3.0, 3.0, 3.0), mod((gl_FragCoord.xxxx / v4_scaled + vec4(3.0, 0.0, 1.0, 2.0)), vec4(4.0, 4.0, 4.0, 4.0))); // I_Y USED AS V4_X ACCESSOR lowp int i_y = int(mod((gl_FragCoord.y / v4_scaled.y), 4.0)); // SET PATTERN BASED ENTIRELY ON DITHER VALUE - REQUESTED USE-CASE lowp int i_pattern = int(floor((f_dither * 100.0 / 12.5) + 0.5)); // ASSUME POSITIVE ALPHA lowp float f_a = 1.0; // SET V4_X BASED ON PATTERN if (i_pattern == 0) { v4_x = vec4(0.0); } if (i_pattern == 1) { v4_x *= m4_ptn1; } if (i_pattern == 2) { v4_x *= m4_ptn2; } if (i_pattern == 3) { v4_x *= m4_ptn3; } if (i_pattern == 4) { v4_x *= m4_ptn4; } if (i_pattern == 5) { v4_x *= m4_ptn5; } if (i_pattern == 6) { v4_x *= m4_ptn6; } if (i_pattern == 7) { v4_x *= m4_ptn7; } if (i_pattern == 8) { v4_x = vec4(1.0); } // VECTOR ACCESSORS HAVE TO BE CONSTANTS; LOOP ITERATORS READ AS CONSTANTS // LOOP CAN BE UNROLLED MANUALLY IF ISSUES PRESENT ON SOME CARDS for (int i = 0; i < 4; i++) { if (i_y == i) { f_a = v4_x[i]; break; } } // PIXEL EITHER SET TO 0 BY PATTERN OR RETAINS INITIAL VALUE v4_pixel *= f_a; // OUTPUT PIXEL INFO gl_FragColor = v4_pixel; }
To configure it, edit these numbers:

// CUSTOM VARIABLES lowp float f_dither = 0.8; lowp float f_scale = 0.01;
It seems that f_dither affects dot spacing and f_scale affects dot size. Hopefully that's the kind of effect you wanted! 👋
never mind, i've figured it out
never mind, i've figured it out
Yes, if you find a WebGL shader written for MZ's version of PIXI.js, then you may be able to just copy+paste it into the parameter. This one is WebGL, which is a good start, but it isn't written for PIXI and it expects custom uniforms, which are basically shader parameters that can be updated during runtime to change how it looks. (My little plugin is too simple to handle any inputs other than PIXI's defaults.)

Fortunately, after making a few small edits I think I've got it working. Try pasting this into the Fragment Shader parameter of the plugin I posted earlier (leave the Vertex Shader blank):
Spoiler: Modified dither fragment shader
precision mediump float; // PIXI UNIFORMS varying vec2 vTextureCoord; uniform sampler2D uSampler; // CUSTOM VARIABLES lowp float f_dither = 0.8; lowp float f_scale = 0.01; lowp mat4 m4_ptn1 = mat4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0); lowp mat4 m4_ptn2 = mat4(1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0); lowp mat4 m4_ptn3 = mat4(0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0); lowp mat4 m4_ptn4 = mat4(1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0); lowp mat4 m4_ptn5 = mat4(1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0); lowp mat4 m4_ptn6 = mat4(0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0); lowp mat4 m4_ptn7 = mat4(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0); // SYSTEM METHOD void main(void) { // GRAB PIXEL INFO lowp vec4 v4_pixel = texture2D(uSampler, vTextureCoord); // SCALE COMES THROUGH AS A PERCENTAGE (0.00 - 1.00) - REQUESTED USE-CASE vec4 v4_scaled = vec4(f_scale * 100.0); // CHEAT - CREATES SCALED VIRTUAL PIXELS FROM SCALE VALUE AT PIXEL XY IN WINDOW SPACE // V4_X USED AS MATRIX MULTIPLIER TO REMOVE MATRIX ACCESSOR lowp vec4 v4_x = step(vec4(3.0, 3.0, 3.0, 3.0), mod((gl_FragCoord.xxxx / v4_scaled + vec4(3.0, 0.0, 1.0, 2.0)), vec4(4.0, 4.0, 4.0, 4.0))); // I_Y USED AS V4_X ACCESSOR lowp int i_y = int(mod((gl_FragCoord.y / v4_scaled.y), 4.0)); // SET PATTERN BASED ENTIRELY ON DITHER VALUE - REQUESTED USE-CASE lowp int i_pattern = int(floor((f_dither * 100.0 / 12.5) + 0.5)); // ASSUME POSITIVE ALPHA lowp float f_a = 1.0; // SET V4_X BASED ON PATTERN if (i_pattern == 0) { v4_x = vec4(0.0); } if (i_pattern == 1) { v4_x *= m4_ptn1; } if (i_pattern == 2) { v4_x *= m4_ptn2; } if (i_pattern == 3) { v4_x *= m4_ptn3; } if (i_pattern == 4) { v4_x *= m4_ptn4; } if (i_pattern == 5) { v4_x *= m4_ptn5; } if (i_pattern == 6) { v4_x *= m4_ptn6; } if (i_pattern == 7) { v4_x *= m4_ptn7; } if (i_pattern == 8) { v4_x = vec4(1.0); } // VECTOR ACCESSORS HAVE TO BE CONSTANTS; LOOP ITERATORS READ AS CONSTANTS // LOOP CAN BE UNROLLED MANUALLY IF ISSUES PRESENT ON SOME CARDS for (int i = 0; i < 4; i++) { if (i_y == i) { f_a = v4_x[i]; break; } } // PIXEL EITHER SET TO 0 BY PATTERN OR RETAINS INITIAL VALUE v4_pixel *= f_a; // OUTPUT PIXEL INFO gl_FragColor = v4_pixel; }
To configure it, edit these numbers:

// CUSTOM VARIABLES lowp float f_dither = 0.8; lowp float f_scale = 0.01;

It seems that f_dither affects dot spacing and f_scale affects dot size. Hopefully that's the kind of effect you wanted! 👋

sorry i did not see your response when i posted my message, i did get it work with multiple colors, but i will test what you sent as well
i did get it work with multiple colors
Oh, nice! 😂
1677969751845.png
this is the result im getting at the moment, before i messed it up i was at least getting dark blue on blue pixels, and pink on light.

openingcritter.png

maybe there are better way to do this than where i have been looking but what im trying to achieve is an on screen dither effect similar to the above image (dithered in photoshop)
the rest bellow were interesting mistakes7B228C8A-7248-4B69-8B19-73DBA55CC5B9.png2E3BACBF-77D4-4FAB-9BC5-AB5E82326A13.png
E347E48D-9E2E-4E80-B2DA-E56E30DCBAB8.png
5912386D-D077-44A8-9D1E-4973C8381EEE.png
im starting to get the desired results, but my one concern is this being applied to everything now, images and movies. Is there a way to add a toggle to enable/ disable the filter? should i look to pixi filter controller?

i apprecitate the help, later on i will share some of my fragment filters i made for others to use.

I updated the code to include a toggle command via events, works perfectly.


JavaScript: /*: * @target MZ * @plugindesc Custom always-on filter for map spriteset. * @url https://forums.rpgmakerweb.com/index.php?threads/152047/ * @help Free to use and/or modify for any project, no credit required. * * @param Vertex Shader * @type multiline_string * @desc Custom vertex shader. Leave blank for default. * @default * * @param Fragment Shader * @type multiline_string * @desc Custom fragment shader. Leave blank for default. * @default * @command toggleMapFilter * @text Toggle Map Filter * @desc Toggles the map filter on or off. */ void (alias => { 'use strict'; // ===== Read parameters ===== // const PLUGIN_NAME = 'MapFilter'; const P = PluginManager.parameters(PLUGIN_NAME); const VERT = P['Vertex Shader'] || null; const FRAG = P['Fragment Shader'] || null; // ====== Define filter ====== // const F = globalThis.DitherFilter = function() { this.initialize(...arguments); }; F.prototype = Object.create(PIXI.Filter.prototype); F.prototype.constructor = F; F.prototype.initialize = function() { PIXI.Filter.call(this, this._vertexSrc(), this._fragmentSrc()); }; F.prototype._vertexSrc = function() { return VERT; }; F.prototype._fragmentSrc = function() { return FRAG; }; // === Attach to spriteset === // Spriteset_Map.prototype.createOverallFilters = function() { alias.apply(this, arguments); this.filters.push(this._ditherFilter = new F()); }; // === Add plugin command === // PluginManager.registerCommand(PLUGIN_NAME, 'toggleMapFilter', args => { const spriteset = SceneManager._scene._spriteset; if (spriteset && spriteset._ditherFilter) { spriteset._ditherFilter.enabled = !(spriteset._ditherFilter.enabled); } }); })(Spriteset_Map.prototype.createOverallFilters);

I've been trying to modify this again to allow for multiple fragment shaders that can be switched between via event commands, but all my attempts failed. maybe someone can help with that?
sorry to keep posting here alone, this is my final edit. has 4 fragment shader slots and each can be toggled on and off via event command
Spoiler: code
JavaScript:

/*:
* @target MZ
* @plugindesc Custom filters for map spriteset.
* @url https://forums.rpgmakerweb.com/index.php?threads/152047/
* @Help Free to use and/or modify for any project, no credit required.
*
* @param Vertex Shader
* @type multiline_string
* @desc Custom vertex shader. Leave blank for default.
* @Default
*
* @param Fragment Shader 1
* @type multiline_string
* @desc Custom fragment shader. Leave blank for default.
* @Default
*
* @param Fragment Shader 2
* @type multiline_string
* @desc Custom fragment shader. Leave blank for default.
* @Default
*
* @param Fragment Shader 3
* @type multiline_string
* @desc Custom fragment shader. Leave blank for default.
* @Default
*
* @param Fragment Shader 4
* @type multiline_string
* @desc Custom fragment shader. Leave blank for default.
* @Default
*
* @command toggleMapFilter1
* @text Toggle Map Filter 1
* @desc Toggles the first map filter on or off.
*
* @command toggleMapFilter2
* @text Toggle Map Filter 2
* @desc Toggles the second map filter on or off.
*
* @command toggleMapFilter3
* @text Toggle Map Filter 3
* @desc Toggles the third map filter on or off.
*
* @command toggleMapFilter4
* @text Toggle Map Filter 4
* @desc Toggles the fourth map filter on or off.
*
*/

void (alias => {
'use strict';

// ===== Read parameters ===== //

const PLUGIN_NAME = 'MapFilter';

const P = PluginManager.parameters(PLUGIN_NAME);
const VERT = P['Vertex Shader'] || null;
const FRAG1 = P['Fragment Shader 1'] || null;
const FRAG2 = P['Fragment Shader 2'] || null;
const FRAG3 = P['Fragment Shader 3'] || null;
const FRAG4 = P['Fragment Shader 4'] || null;

// ===== Define filter ===== //

const F1 = globalThis.DitherFilter1 = function (enabled = true) {
this.initialize(...arguments);
this.enabled = enabled;
};

F1.prototype = Object.create(PIXI.Filter.prototype);
F1.prototype.constructor = F1;

F1.prototype.initialize = function () {
PIXI.Filter.call(this, this._vertexSrc(), this._fragmentSrc1());
};

F1.prototype._vertexSrc = function () {
return VERT;
};

F1.prototype._fragmentSrc1 = function () {
return FRAG1;
};

const F2 = globalThis.DitherFilter2 = function (enabled = true) {
this.initialize(...arguments);
this.enabled = enabled;
};

F2.prototype = Object.create(PIXI.Filter.prototype);
F2.prototype.constructor = F2;

F2.prototype.initialize = function () {
PIXI.Filter.call(this, this._vertexSrc(), this._fragmentSrc2());
};

F2.prototype._vertexSrc = function () {
return VERT;
};

F2.prototype._fragmentSrc2 = function () {
return FRAG2;
};

const F3 = globalThis.DitherFilter3 = function (enabled = true) {
this.initialize(...arguments);
this.enabled = enabled;
};

F3.prototype = Object.create(PIXI.Filter.prototype);
F3.prototype.constructor = F3;

F3.prototype.initialize = function () {
PIXI.Filter.call(this, this._vertexSrc(), this._fragmentSrc3());
};

F3.prototype._vertexSrc = function () {
return VERT;
};

F3.prototype._fragmentSrc3 = function () {
return FRAG3;
};

const F4 = globalThis.DitherFilter4 = function (enabled = true) {
this.initialize(...arguments);
this.enabled = enabled;
};

F4.prototype = Object.create(PIXI.Filter.prototype);
F4.prototype.constructor = F4;

F4.prototype.initialize = function () {
PIXI.Filter.call(this, this._vertexSrc(), this._fragmentSrc4());
};

F4.prototype._vertexSrc = function () {
return VERT;
};

F4.prototype._fragmentSrc4 = function () {
return FRAG4;
};

// === Attach to spriteset === //

Spriteset_Map.prototype.createOverallFilters = function () {
alias.apply(this, arguments);
this.filters.push(this._ditherFilter1 = new F1(false));
this.filters.push(this._ditherFilter2 = new F2(false));
this.filters.push(this._ditherFilter3 = new F3(false));
this.filters.push(this._ditherFilter4 = new F4(false));
};

// === Add plugin commands === //

PluginManager.registerCommand(PLUGIN_NAME, 'toggleMapFilter1', args => {
const spriteset = SceneManager._scene._spriteset;
if (spriteset && spriteset._ditherFilter1) {
spriteset._ditherFilter1.enabled = !(spriteset._ditherFilter1.enabled);
}
});

PluginManager.registerCommand(PLUGIN_NAME, 'toggleMapFilter2', args => {
const spriteset = SceneManager._scene._spriteset;
if (spriteset && spriteset._ditherFilter2) {
spriteset._ditherFilter2.enabled = !(spriteset._ditherFilter2.enabled);
}
});

PluginManager.registerCommand(PLUGIN_NAME, 'toggleMapFilter3', args => {
const spriteset = SceneManager._scene._spriteset;
if (spriteset && spriteset._ditherFilter3) {
spriteset._ditherFilter3.enabled = !(spriteset._ditherFilter3.enabled);
}
});

PluginManager.registerCommand(PLUGIN_NAME, 'toggleMapFilter4', args => {
const spriteset = SceneManager._scene._spriteset;
if (spriteset && spriteset._ditherFilter4) {
spriteset._ditherFilter4.enabled = !(spriteset._ditherFilter4.enabled);
}
});


})(Spriteset_Map.prototype.createOverallFilters);
Great! For future reference (you're not in trouble this time around), we generally ask people to refrain from posting multiple times in a row in a short period, like you've done here. It's mostly an anti-spam measure. Here's the message:

@rickteous, please avoid double posting, as it is against the forum rules. You can use the "Edit" function on your posts to add additional information you've forgotten or respond to multiple people. You can review our forum rules here. Thank you.

That said, edits don't (currently) send notifications, so that's something to bear in mind. 😴

Note that there are two kinds of code tag available here, each with their own button:
  • Inline: >_ = [icode][/icode]
  • Block: </> = [code=javascript][/code]
These help to preserve whitespace and avoid auto-formatting of code. I notice you used the inline style previously; the "block" style also offers syntax highlighting for supported languages, e.g. JS.

It looks like you've largely figured things out for yourself. Do you have any other questions on this topic? I might be able to help with MZ/JS, but I'm not personally very familiar with GLSL. 😅
Hope this doesn't count as necro-posting or breaking other rules, but I'm very interested in the same dithering concept, albeit with MV's engine instead.

Yes, if you find a WebGL shader written for MZ's version of PIXI.js, then you may be able to just copy+paste it into the parameter. This one is WebGL, which is a good start, but it isn't written for PIXI and it expects custom uniforms, which are basically shader parameters that can be updated during runtime to change how it looks. (My little plugin is too simple to handle any inputs other than PIXI's defaults.)

Fortunately, after making a few small edits I think I've got it working. Try pasting this into the Fragment Shader parameter of the plugin I posted earlier (leave the Vertex Shader blank):
Spoiler: Modified dither fragment shader
precision mediump float; // PIXI UNIFORMS varying vec2 vTextureCoord; uniform sampler2D uSampler; // CUSTOM VARIABLES lowp float f_dither = 0.8; lowp float f_scale = 0.01; lowp mat4 m4_ptn1 = mat4(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0); lowp mat4 m4_ptn2 = mat4(1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0); lowp mat4 m4_ptn3 = mat4(0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0); lowp mat4 m4_ptn4 = mat4(1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0); lowp mat4 m4_ptn5 = mat4(1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0); lowp mat4 m4_ptn6 = mat4(0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0); lowp mat4 m4_ptn7 = mat4(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0); // SYSTEM METHOD void main(void) { // GRAB PIXEL INFO lowp vec4 v4_pixel = texture2D(uSampler, vTextureCoord); // SCALE COMES THROUGH AS A PERCENTAGE (0.00 - 1.00) - REQUESTED USE-CASE vec4 v4_scaled = vec4(f_scale * 100.0); // CHEAT - CREATES SCALED VIRTUAL PIXELS FROM SCALE VALUE AT PIXEL XY IN WINDOW SPACE // V4_X USED AS MATRIX MULTIPLIER TO REMOVE MATRIX ACCESSOR lowp vec4 v4_x = step(vec4(3.0, 3.0, 3.0, 3.0), mod((gl_FragCoord.xxxx / v4_scaled + vec4(3.0, 0.0, 1.0, 2.0)), vec4(4.0, 4.0, 4.0, 4.0))); // I_Y USED AS V4_X ACCESSOR lowp int i_y = int(mod((gl_FragCoord.y / v4_scaled.y), 4.0)); // SET PATTERN BASED ENTIRELY ON DITHER VALUE - REQUESTED USE-CASE lowp int i_pattern = int(floor((f_dither * 100.0 / 12.5) + 0.5)); // ASSUME POSITIVE ALPHA lowp float f_a = 1.0; // SET V4_X BASED ON PATTERN if (i_pattern == 0) { v4_x = vec4(0.0); } if (i_pattern == 1) { v4_x *= m4_ptn1; } if (i_pattern == 2) { v4_x *= m4_ptn2; } if (i_pattern == 3) { v4_x *= m4_ptn3; } if (i_pattern == 4) { v4_x *= m4_ptn4; } if (i_pattern == 5) { v4_x *= m4_ptn5; } if (i_pattern == 6) { v4_x *= m4_ptn6; } if (i_pattern == 7) { v4_x *= m4_ptn7; } if (i_pattern == 8) { v4_x = vec4(1.0); } // VECTOR ACCESSORS HAVE TO BE CONSTANTS; LOOP ITERATORS READ AS CONSTANTS // LOOP CAN BE UNROLLED MANUALLY IF ISSUES PRESENT ON SOME CARDS for (int i = 0; i < 4; i++) { if (i_y == i) { f_a = v4_x[i]; break; } } // PIXEL EITHER SET TO 0 BY PATTERN OR RETAINS INITIAL VALUE v4_pixel *= f_a; // OUTPUT PIXEL INFO gl_FragColor = v4_pixel; }
To configure it, edit these numbers:

// CUSTOM VARIABLES lowp float f_dither = 0.8; lowp float f_scale = 0.01;

It seems that f_dither affects dot spacing and f_scale affects dot size. Hopefully that's the kind of effect you wanted! 👋
If I could find a MV compatible plugin, could I use a similar line of coding to achieve the same dithering outcome?
For what you're asking: you'd want a plugin and a shader that are compatible with both RMMV's core scripts and the associated PIXI version. The GLSL might work as-is if you're lucky. There may be other differences to address, e.g. if you're using any other plugins.

Technically your post is both a necropost (bumping someone else's inactive support thread) and a thread hijack (asking a different question on someone else's thread). Congrats! 😊

You can check out the general forum rules here:
If you have a similar question, I suggest you start a new thread instead. You can include a link back to this thread for reference purposes. 👋

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/trying-to-use-pixi-to-load-a-a-glsl-fragment-shader.152047/