tangshanghai Posted March 31, 2022 Share Posted March 31, 2022 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'); app.stage.addChild(sp); 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? Quote Link to comment Share on other sites More sharing options...
tangshanghai Posted March 31, 2022 Author Share Posted March 31, 2022 I know why. I'm sorry Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 31, 2022 Share Posted March 31, 2022 1. you might use mesh-shader instead, look in pixi examples 2. here is about filter coords: https://github.com/pixijs/pixijs/wiki/v4-Creating-Filters tangshanghai 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.