Extra texture uniform to Fragment Shader #10358
Replies: 1 comment
-
I've been hitting the same problem and I think I may have just figured it out. Some of the examples in the API docs are partially right but not entirely and then like you I've been working off the same example that shows a shader actually working so my
It seems that textures can be passed in the resources object as a stand alone item as shown in the example here: https://pixijs.com/8.x/examples/mesh-and-shaders/shared-shader Judging from your fragment shader all you need to do is: const invertFilter = new PIXI.Filter({
glProgram: new PIXI.GlProgram({
fragment: fragmentShaderSource,
vertex: vertexShaderSource
}),
resources: {
uExtraTexture: extraTexture
}
}); This is how I am passing my texture to my shader which works but in my test I am doing this to get the texture: const asset= await PIXI.Assets.load(OBJECT_PATH + 'normal.png'); and resources: {
uNormal: asset.source
} Anyway, really hope this helps/works for you!! |
Beta Was this translation helpful? Give feedback.
-
Hi! I'm new to Pixi.
I'm trying to pass a texture to a Fragment shader, and I keep failing.
I want just a texture effect, so I copied the example from here:
https://pixijs.com/8.x/examples/filters-advanced/custom
My first question here is:
Why can this not be written as
?
Now I am trying to pass an extra texture to the fragment shader, like so:
I have tried
uniforms: { uExtraTexture: extraTexture, },
or adding
uniforms: { uExtraTexture: { value: extraTexture, type: 'sampler2D' }, },
But none of this seems to work. All the examples I can find use a different syntax, without the GlProgram constructor, like here:
https://stackoverflow.com/questions/64072964/passing-textures-to-fragment-shader-in-pixi-js
But changing to this syntax seems to break the custom shader example I am basing my code on:
https://pixijs.com/8.x/examples/filters-advanced/custom
This is currently my fragment shader (note I am not using uTexture at all, this is just to simplify, in the end I will need both):
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions