cachopixi Posted April 9, 2019 Share Posted April 9, 2019 Is there a way to globally set the values of certain uniforms, so they don't need to be set on a per shader basis? ie.: uniform vec2 u_resolution; uniform float u_time; It seems to be it might be inconvenient to have to update every shader each when we change resolution, or to update the time Thanks! Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted April 9, 2019 Share Posted April 9, 2019 Two-part answer u_resolution u_resolution is actually part of filter uniforms that depend on temporary pow2-sized texture. In v5 its available under another name for all filters. https://github.com/pixijs/pixi.js/wiki/v4-Creating-Filters v5: http://pixijs.download/dev/docs/PIXI.Filter.html working on new docs: https://github.com/pixijs/pixi.js/pull/5555 one of latest filter-related threads : u_time In v5 its possible to add stuff to global uniforms. Related code: https://github.com/pixijs/pixi.js/search?q=globalUniforms&unscoped_q=globalUniforms Maybe you can put something in "renderer.globalUniforms" before you create the shader. I did not test this approach so I do not know additional actions are required for it. You have to guess and debug. Quote Link to comment Share on other sites More sharing options...
cachopixi Posted April 10, 2019 Author Share Posted April 10, 2019 Thanks for your reply! I'm using version 4.8.7 which I got from npm. Is version 5 ready to use already? Even after checking the docs I don't understand how u_resolution is already defined, as I don't seem to be there unless I define it. Is there any sample code I can check? >u_resolution is actually part of filter uniforms that depend on temporary pow2-sized texture does this mean it only works for pow2-sized textures? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted April 10, 2019 Share Posted April 10, 2019 Look, I specified in https://github.com/pixijs/pixi.js/pull/5555 that we have 5 different spaces for coordinates. Its hell. There is u_resolution (sometimes called `dimensions`) that is needed for conversion between some of them, and it has special name in v5, but in v4 you have to add a hack to "Filter.apply" method to use it. The problem is discussed so many times that I really dont have time to discuss it right now unless you have a demo for me to fix. All that links I posted should help you to make your case, then I can help you to fix it "container.filterArea = renderer.screen" makes everything significantly easier, because all normalized coords are in screen, maybe that helps you. 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.