Jump to content

Need help converting Filter from v4 to v5.


doehyunbaek
 Share

Recommended Posts

Hi. My application is written in v5([email protected]) and I am trying to reproduce this brush filter(alchemancy/brush-node-filter.ts at master · wonderunit/alchemancy (github.com) which uses v4([email protected]).

The problem is, it would not even initialize :(. Error it gives are :

 

Pixi.js Error: Could not initialize shader.

gl.VALIDATE_STATUS false

gl.getError() 0

TypeError: Failed to execute 'getProgramParameter' on 'WebGL2RenderingContext': parameter 1 is not of type 'WebGLProgram'

at Program.getAttributeData

at Program.extractData

at new Program

at Function.Program.from

at BrushNodeFilter.Filter [as constructor]

at new BrushNodeFilter

 

I have changed constructor to use v4 default vertex shader and fragment shader of above link and there seems to be some part of fragment shader that makes it work with v4 but not v5. The same fragment shader works like charm in above repository but not in my application :(. I have read about their differing behaviors in (v5 Creating filters · pixijs/pixi.js Wiki (github.com)) but I have not found a reason why it won't even let me initialize the filter. I am sorry for crude description of my problem and would appericate any hint or quick guess you guys could give. Thanks in advance.

Link to comment
Share on other sites

Ivan, thanks for your kind reply. I turned off warning like an idiot :(. There was a warning. They are

instrument.ts:129 StatLogger: CanvasRenderer.dispatch:entityBuild was not finished

instrument.ts:129 Pixi.js Warning: gl.getProgramInfoLog() Varyings with the same name but different type, or statically used varyings in fragment shader are not declared in vertex shader: vFilterCoord

I am pretty new to Pixi so I think I would take some time to whip up example. I'll try to post an example by tomorrow night. Wait for me kindly :).

As for example, you want a reproducible code which above error occurs?

Link to comment
Share on other sites

Hi.

I made up a codesandbox example(https://codesandbox.io/s/confident-chatterjee-lcrxz?file=/src/index.ts). There is actually not much to it. Right now I am failing to initialize Filter so I just made a filter with sprite made from empty texture.

I will try to update above drawing repo to v6 if I can get a hang of it. Such a great example but it's a shame it won't work on Pixi v5 :(. Should keep passing the torch!

Link to comment
Share on other sites

Hi Ivan. Sorry for making so many dumb mistakes :( Didn't mean to waste your time.

Actually I fixed above warning and error message by adding a line to vertex shader, though it does not solve my problem. It just draws nothing. 

I think it is pretty hopeless for me to use this brush in my project because of such a huge discrepancy between v4 and v5, and I changed my plan to refactor above alchemancy repository to pixi v6. I can't promise on anything because I got other things to do. But I'll certainly try in my free time :). Will update about it.

Link to comment
Share on other sites

If you want to try to do it from start, that's how its usually done in pixi-v5 : through mesh-shader: https://pixijs.io/examples/#/mesh-and-shaders/triangle-textured.js

V6 is the same regarding filters and mesh-shaders.

As for current filter solution, it should be easy enough to port your old shader if you just stop , explain me how to set up example from your project manually, i remember that i helped with conversion of that project to typescript

Edited by ivan.popelyshev
Link to comment
Share on other sites

Sorry. I just tried to fix the shader initialization error message first. I am sorry it made your work hard by not supplying context and giving no sprite and texture. I should have supplied something more. It's my bad.

I'll try to cook up PIXI rendering part of my project in the above sandbox. I'll update when I'm done with it. 

Again sorry for my carelessness and thank you for your kind reply.

Link to comment
Share on other sites

OK, i checked out the project, again , and i looked in the filter and sources.

They rotate sprite by 45 degrees to get more edge, then take brush, multiply it by grain. However coordinates work is so obscene that i cant even change filterArea - coordinates are beyond repair. I can try to do that, but only for money or if original author of the project asks me. That's because im not the one who wrote that thing, and it will really consume some of my important brain time.

To show how everything is fubar, try "sprite.filterArea = this.app.screen" after "filter.padding = 1"
 

Edited by ivan.popelyshev
Link to comment
Share on other sites

Actually, that's the thing. Only this line is important:

((brushSample.r * grainSample.r * (1.0+uBleed))- uBleed ) * (1.0+ uBleed) * uOpacity;

Everything else can be done with usual mesh-shader stuff. Just take mesh-shader example, pass "translationMatrix * vertexPosition / grainSize" to fragment through varying, "grainSize" should be size of grain texture. Combine two textures in fragment shader, use uBleed and uOpacity too. Dont do any extra tricks with coords of brush sprite. That should work.

Edited by ivan.popelyshev
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...