dullman

Villager
Member
Joined
Jun 7, 2015
Messages
20
Reaction score
0
Primarily Uses
Hello I have a problem with not working custom (made by me), I search for mistakes really hard but can't find solution what i get is few lines of errors which sounds like 

Cannot read property 'bind' of undefined

 which is called when trying to bind texture method from uniform which is by the way null, but from what i see in examples from pixi there weren't any example with setting example texture.


here is my code of filter class

Code:
	function ChangeColorPallete(usedColors, newColors, epsilon){
		var vertexSrc = [
			'attribute vec2 aVertexPosition;',
			'attribute vec2 aTextureCoord;',
			'uniform mat3 projectionMatrix;',
			'varying vec2 vTextureCoord;',

			'void main(void){',
			'	gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);',
			'	vTextureCoord = aTextureCoord;',
			'}'
    	].join('\n');

     	var fragmentSrc = [
			 'varying vec2 vTextureCoord;',
			 'uniform sampler2D texture;',
			 'uniform vec3 originalColor[10];',
			 'uniform vec3 newColor[10];',
			 'uniform float epsilon;',

			 'void main(void) {',
			 '	vec4 currentColor = texture2D(texture, vTextureCoord);',
			 '	if (currentColor.r - originalColor[0].r < epsilon && currentColor.g - originalColor[0].g < epsilon && currentColor.b - originalColor[0].b < epsilon)',
			 '		gl_FragColor = vec4(newColor[0].r, newColor[0].g, newColor[0].b, currentColor.a);',
			 ' 	else if (currentColor.r - originalColor[1].r < epsilon && currentColor.g - originalColor[1].g < epsilon && currentColor.b - originalColor[1].b < epsilon)',
			 '		gl_FragColor = vec4(newColor[1].r, newColor[1].g, newColor[1].b, currentColor.a);',
			 ' 	else if (currentColor.r - originalColor[2].r < epsilon && currentColor.g - originalColor[2].g < epsilon && currentColor.b - originalColor[2].b < epsilon)',
			 '		gl_FragColor = vec4(newColor[2].r, newColor[2].g, newColor[2].b, currentColor.a);',
			 ' 	else if (currentColor.r - originalColor[3].r < epsilon && currentColor.g - originalColor[3].g < epsilon && currentColor.b - originalColor[3].b < epsilon)',
			 '		gl_FragColor = vec4(newColor[3].r, newColor[3].g, newColor[3].b, currentColor.a);',
			 ' 	else if (currentColor.r - originalColor[4].r < epsilon && currentColor.g - originalColor[4].g < epsilon && currentColor.b - originalColor[4].b < epsilon)',
			 '		gl_FragColor = vec4(newColor[4].r, newColor[4].g, newColor[4].b, currentColor.a);',
			 ' 	else if (currentColor.r - originalColor[5].r < epsilon && currentColor.g - originalColor[5].g < epsilon && currentColor.b - originalColor[5].b < epsilon)',
			 '		gl_FragColor = vec4(newColor[5].r, newColor[5].g, newColor[5].b, currentColor.a);',
			 ' 	else if (currentColor.r - originalColor[6].r < epsilon && currentColor.g - originalColor[6].g < epsilon && currentColor.b - originalColor[6].b < epsilon)',
			 '		gl_FragColor = vec4(newColor[6].r, newColor[6].g, newColor[6].b, currentColor.a);',
			 ' 	else if (currentColor.r - originalColor[7].r < epsilon && currentColor.g - originalColor[7].g < epsilon && currentColor.b - originalColor[7].b < epsilon)',
			 '		gl_FragColor = vec4(newColor[7].r, newColor[7].g, newColor[7].b, currentColor.a);',
			 ' 	else if (currentColor.r - originalColor[8].r < epsilon && currentColor.g - originalColor[8].g < epsilon && currentColor.b - originalColor[8].b < epsilon)',
			 '		gl_FragColor = vec4(newColor[8].r, newColor[8].g, newColor[8].b, currentColor.a);',
			 ' 	else if (currentColor.r - originalColor[9].r < epsilon && currentColor.g - originalColor[9].g < epsilon && currentColor.b - originalColor[9].b < epsilon)',
			 '		gl_FragColor = vec4(newColor[9].r, newColor[9].g, newColor[9].b, currentColor.a);',
			 '}'
     	].join('\n');
		PIXI.Filter.call(this, vertexSrc, fragmentSrc);

		this.uniforms.epsilon = epsilon;
		console.log(this);
		this.uniforms.originalColor = usedColors;
		this.uniforms.newColor = newColors;
	}

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

	Object.defineProperty(ChangeColorPallete.prototype, 'epsilon', {
  		set: function (value) {
    		this.uniforms.epsilon = value;
			console.log(value);
 		}
	});

	Object.defineProperty(ChangeColorPallete.prototype, 'originalColor', {
  		set: function (value) {
			var colors = [10]  
			var emptyValue = new Float32Array([0, 0, 0])
			for (var i = 0; i < 10; i++){
				var nvalue = new Float32Array([1, 1, 1]);
				if (value.length > i)
					nvalue = value[i];
				colors[i] = {type: "v3v", value:[{x:nvalue[0], y: nvalue[1], z: nvalue[2]}]};
			}  
			console.log(this.uniforms);
    		this.uniforms.originalColor = colors;
			
  		}
	});

		Object.defineProperty(ChangeColorPallete.prototype, 'newColor', {
  			set: function (value) {
				  console.log(value);
    			var colors = [10]  
			var emptyValue = new Float32Array([0, 0, 0])
			for (var i = 0; i < 10; i++){
				var nvalue = new Float32Array([1, 1, 1]);
				if (value.length > i)
					nvalue = value[i];
				colors[i] = {type: "v3v", value:[{x:nvalue[0], y: nvalue[1], z: nvalue[2]}]};
			}  
			console.log(this.uniforms);
    		this.uniforms.newColor = colors;
  			}
	});
 

Latest Profile Posts

..of the major old school series that began in the 80s- early 90s, I still haven't beaten 'a' Zelda game. Mario 64 was the first Mario I've beaten. I don't know if I should give that honor to Link to the Past or A Link Between Worlds(I currently own both). Well technically I've haven't beaten a Sonic either (Game Genie doesn't count =P).
headshot_headinfo.jpg
Time to add the "headshot" concept into the game so that people may actually aim at the heads when shooting zombies and get massive damage and armor-pen bonus as rewards. :kaojoy:
(The red area is just for visually debug purposes right now. But, it's possible that I will add something that displays the weak spots of enemies in the future.)
Worked on a cutscene skip domino effect using Maker Systems' script as the basis. Basically if I have a batch of cutscenes in a row on different maps, now when you skip one cutscene it will skip the entire set. No more spamming X to skip a scene every new map.

Oh and it will work regardless of where you do it from in the set. Convenient!
seems absolutely WILD to me now all the hundreds of hours of work I used to do in 2k(3) over a decade ago with a resolution of 320x240. that seems so insanely TINY now, seemed so normal at the time!
Playing Aroma Indosiar theme song.
Aroma is an Indonesian TV show about cooking. :)

Forum statistics

Threads
115,380
Messages
1,089,402
Members
150,088
Latest member
lollwi
Top