Jump to content

How can I move the position of a shader?


Kayna
 Share

Recommended Posts

I ported a shader from Shadertoy but I'm stuck on how to move it around (right now it's at the bottom-left), does anyone know how it could be done?

 

I tried with quad.position.set(X, Y); but seems like that only crops it, it doesn't move it... Is there a function like .set(X, Y) for shaders where you can declare a specific position and the shader is placed there?

Edited by Kayna
Link to comment
Share on other sites

On 7/5/2022 at 8:55 AM, ivan.popelyshev said:

you have to use projectionMatrix and translationMatrix uniforms in shader, otherwise pixi transform tree wont affect it. https://pixijs.io/examples/#/mesh-and-shaders/shadertoy-mesh.js

I included the projectionMatrix & translationMatrix but seems like the shadertoy-mesh example isn't moving it from the center, but rather it crops/cuts it from the sides... here I'm doing the same thing:

But what if you want to place the shader in the top-right corner (or any corner)? Is there an example of that?

I also tried changing the values of gl_Position at the vertexSrc but that also doesn't move the shader, it just crops/cuts it

 

Edited by Kayna
Link to comment
Share on other sites

On 7/6/2022 at 1:50 AM, Kayna said:

I included the projectionMatrix & translationMatrix but seems like the shadertoy-mesh example isn't moving it from the center, but rather it crops/cuts it from the sides... here I'm doing the same thing: https://www.pixiplayground.com/#/edit/Nj1q7mDQGdkOz7LxUsrfo

But what if you want to place the shader in the top-right corner (or any corner)? Is there an example of that?

I also tried changing the values of gl_Position at the vertexSrc but that also doesn't move the shader, it just crops/cuts it

 

vec2 p = -.5 + gl_FragCoord.xy / iResolution.xy;
        p.x *= iResolution.x/iResolution.y;

You have to use UV's here, normalized coords inside the mesh, not the "pixel coord" that webgl gives you. PixiJS cannot affect shader insides, sorry )

Further questions please relay to discord, because im not the one currently who is in charge of answering questions

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...