New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PIXI fails to create a Filter from custom shader code #4476
Comments
The example works for me, what browser are you testing you in? |
@doebi nice catch! Yeah, optimization removed something (I bet its sampler) and we forgot to check it. For now, are you sure that you need filter without usage of sampler? In some cases its better to make renderer plugin like https://github.com/pixijs/pixi-plugin-example ? Second time this day, Im sorry for the mess that shader and filters are in v4. We'll fix it in v5. |
To be honest, i haven't really dug deep into this topic yet. Just wanted to experiment with that feature the other day. I will do some testing with the renderer plugin approach. Thanks for the hint. Is there already some ETA for v5? |
2 months or so :) There are many tricks about filters, that's why I made that article: https://github.com/pixijs/pixi.js/wiki/v4-Creating-Filters |
@ivanpopelyshev Following your tutorial, i ran into the same issue. diff --git a/js/pixi.js b/js/pixi.js
index 363f09c..d0a321b 100644
--- a/js/pixi.js
+++ b/js/pixi.js
@@ -2344,6 +2344,9 @@ VertexArrayObject.prototype.activate = function()
*/
VertexArrayObject.prototype.addAttribute = function(buffer, attribute, type, normalized, stride, start)
{
+ if (!attribute) {
+ return this;
+ }
this.attributes.push({
buffer: buffer,
attribute: attribute,
I know this is not a solution, but it enables me to play with shader codes in v4 until v5 is out. (with possibly a better fix) :) |
That's a good hack! You can move it into separate js file: PIXI.glCore.VertexArrayObject.prototype.addAttribute = ... |
I got the same problem. Also with Ubuntu 17.10 artful. Are shaders at all stable in Pixi.js? Can I use them in production? How do I import a pixel shader? |
Either as filter either as renderer plugin. They are stable but require serious knowledge both about webgl and about pixi architecture. https://github.com/pixijs/pixi.js/wiki/v4-Creating-Filters For N-th time I assure people that it'll be easier in v5. |
const filterCode = `void main(){
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
}`;
const filter = new PIXI.Filter(null, filterCode);
someSprite.filters = [filter]; This much code leads to this error. Maybe I should go for a different constructor of the Filter? Or should I substitute null with something? |
For a filter, you have to use texture coord and sampler , otherwise FilterManager fails to get location of attribute. Renderer plugin doesnt have that requirement, try it. Yeah, its big boilerplate. |
Try that thing: https://github.com/TazOen/createShaderPlugin . However it ignores the texture, there's no |
You say it need texture coords and "sampler". Was sample or sampler? A typo? |
Sampler. However its uniform and I dont think somebody will miss it. Our problem is about attributes. Thanks to you, it does :) https://github.com/pixijs/pixi.js/wiki/v4-Creating-Filters#cannot-read-property-location-of-undefined |
Oh, so that's where it was. I missed the wiki. |
I've added it just now. Also added notice in filter-mouse demo. We cant fix the issue in v4. We'll do something about it in v5. |
How about to list these properties in there? |
only the attribute, aTextureCoord -> vTextureCoord |
This is getting very strange.
But if I add |
@germansokolov13 this behaviour makes total sense. Just think about it: If you add If glsify optimizes the call to texture2D, webgl does not allocate memory for You got some options:
Hopefully, this helps. |
Nice catch, @doebi! Or use renderer plugin. |
Oh, now I get it! Maybe we should add Doebi's patch to the next minor release of Pixi.js? Should I create a PR? |
Yep, PR, but different place. https://github.com/pixijs/pixi.js/blob/dev/src/core/renderers/webgl/utils/Quad.js#L93 I suggest extra class which overrides method and that is used in FilterManager. |
Hi there, It's working fine on Windows, MacOS and Android as far as I tested I only have issues in iOS.
fragment:
for comparision here are the shaders of the default BlurYFilter:
frag:
Does Anybody have any ideas why this could go wrong? |
@tyleet are you sure its the same issue? What do you see in the console? |
@ivanpopelyshev shall we close this issue to prevent others from warming it up with similar issues? |
@doebi closing. |
@tyleet the number of samples taken from texture can be limited on different systems. |
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. |
I am struggling to get a custom Filter with my own shader code working with this error message:
Even the official example is failing with this bug:
http://pixijs.io/examples/#/filters/filter-mouse.js
This error message has been related to some compiler optimizations where glslify removed some unused uniforms, which pixi still tried to access. But this even occurs with a completely static fragShader without any uniforms.
gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0)
The text was updated successfully, but these errors were encountered: