question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

vTextureCoord wrong coordination

See original GitHub issue

Hi, I messing with filters but have some issue with fragment shader (i think the problem is more like with the vertex shader, or i just missing something). Anyway, i just create a basic project with a basic fragment shader and i noticed that the ‘filtered’ area is bigger than it should be.

the fragment shader

precision mediump float;

varying vec2 vTextureCoord;
uniform sampler2D uSampler;

void main() {


	if ( vTextureCoord.x < 0.5 )
	{
		gl_FragColor = vec4(1.0,0.5,0.5, 1.0);
	}
}

the project file

window.onload = function(){
	var app = new PIXI.Application(800, 600, {backgroundColor : 0x1099bb});
	document.body.appendChild(app.view);

	var base_rect = new PIXI.Graphics();
	base_rect.beginFill(0xff0080);
	base_rect.drawRect(0, 0, 800, 600);
	app.stage.addChild(base_rect);
        
       PIXI.loader.add('shader', 'vignette.frag').load(onLoaded);
       
       var filter;

       function onLoaded (loader,res) {
	    filter = new PIXI.Filter(null, res.shader.data);
	    app.stage.filterArea = new PIXI.Rectangle(0,0,800,600);
	    app.stage.filters = [filter];

	    app.start();
	}

	app.ticker.add(function(delta) {
	});
}

and the result is with the code ‘if ( vTextureCoord.x < 0.5 )’ screenshot 2017-03-01 21 54 03

instead of this: (but if i write ‘if ( vTextureCoord.x < 0.4 )’ i get the 50% width that i want) screenshot 2017-03-01 21 54 47

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
dmtthcommented, Mar 2, 2017

thanks for the reply!

0reactions
lock[bot]commented, Feb 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

vTextureCoord wrong coordination · Issue #3803 · pixijs/pixijs
Hi, I messing with filters but have some issue with fragment shader (i think the problem is more like with the vertex shader, ......
Read more >
Interpolation on fragment shader starts at 0 + half pixel
I pass the texture coordinate from the vertex shader to the fragment shader via varying variable, which works fine. vTextureCoord = ...
Read more >
PIXI.Filter
By default, input normalized coordinates are passed to fragment shader with vTextureCoord . Use it to sample the input.
Read more >
What is it with vTextureCoord (shaders) - Pixi.js
It says: vTextureCoord is between 0 and 1. It is not. I apply the shader to some 16x16 Images, scaled to 2, and...
Read more >
Using textures in WebGL - Web APIs | MDN
LINEAR); // Prevents s-coordinate wrapping (repeating). gl. ... the resulting image texture from having the wrong orientation when rendered, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found