vTextureCoord wrong coordination
See original GitHub issueHi, 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 )’
instead of this: (but if i write ‘if ( vTextureCoord.x < 0.4 )’ i get the 50% width that i want)
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
thanks for the reply!
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.