Jump to content

What range does vtexturecoord [0,1] refer to?


Recommended Posts

const shaderFrag=`
precision highp float;
varying vec2 vTextureCoord;
uniform vec4 inputSize;
uniform vec4 outputFrame;
uniform sampler2D uSampler;
void main() {
    vec2 uv = vTextureCoord;
    vec4 color = texture2D(uSampler, uv);
    if(uv.x < 0.4){
        color.r = 1.0;
        color.a = 1.0;
    }else if(uv.x > 0.6){
        color.g = 1.0;
        color.a = 1.0;
    gl_FragColor = color;

const sp = new PIXI.Sprite.from('./dlrb.png');
sp.x = 0;
sp.y = 0;

const filter = new PIXI.Filter(null, shaderFrag);
sp.filters = [filter];

I intend to keep only the pixel range of 0.4 to 0.6, but the result is offset. If you set SP object x to - 100 at this time, the offset will only be more. What is the reason?

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.

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.


  • Recently Browsing   0 members

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