Jump to content

Error with NormalMapFilter


Alexis
 Share

Recommended Posts

I am new to Pixi.js. I have tried to recreate the examples to learn this.

But i have an error when i try to recreate the normalMapFilter example. 

 

I have no problem when i use the same version of the demo (1.4)

 

But in my project i use the latest version (2.2.3) and then i have errors.

 

I get a lot of warnings and a blank canvas.

Errors look like this

pixi.dev.js:5829 Could not initialise shaderspixi.dev.js:5928 WebGL: INVALID_OPERATION: useProgram: program not validpixi.dev.js:5931 WebGL: INVALID_OPERATION: getUniformLocation: program not linked

I have correctly included the files

<script src="js/pixi.dev.js"></script><script src="js/vendor/pixi/filters/NormalMapFilter.js"></script>

And i use the same code of the demo

$(document).ready(function() { 		var viewWidth =  1920;	var viewHeight = 1080;	var renderer = PIXI.autoDetectRenderer(viewWidth, viewHeight);	$(renderer.view).addClass('pixi').appendTo('body');	var stage = new PIXI.Stage(0xFFFFFF); 	var texture = PIXI.Texture.fromImage("img/texture_norm.jpg");		var filter = new PIXI.NormalMapFilter(texture);	var sprite = PIXI.Sprite.fromImage("img/texture.jpg");	sprite.filters = [filter];		stage.addChild(sprite);	requestAnimationFrame(animate);		function animate() 	{				var mouse = stage.interactionManager.mouse;		if( mouse.global.x < 0) mouse.global.x = 0;		else if( mouse.global.x > viewWidth) mouse.global.x = viewWidth;		if( mouse.global.y < 0) mouse.global.y = 0;		else if( mouse.global.y > viewHeight) mouse.global.y = viewHeight;		filter.uniforms.LightPos.value[0] = mouse.global.x;		filter.uniforms.LightPos.value[1] = mouse.global.y;	    renderer.render(stage);	    	    requestAnimationFrame( animate );	}});	

Am i missing something ?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...