I’m presently writing a lengthy GLSL fragment shader to be used via ShaderFilter. I had hoped to use the DisplayObjectShader class, since extending completes much of the vertex and fragment shader code, and one really only needs to provide a small portion of the fragment shader with @:glFragmentBody, which I had successfully already done.
However, my fragment body is going to be quite complicated, and I want different GLSL functions used in it to be kept in separate modules (or just distinct locations). I’m not an advanced enough Haxe user yet to figure out how to import and concatenate several GLSL sources and then place them inside the proper annotation for DisplayObjectShader. I tried instantiating DisplayObjectShader and then just reassigning the glFragmentSource field with the full fragment header + body + source concatenated properly, with my custom code injected, but was just getting a white visual (unclear why this was the case, because when I traced both the glVertexSource and glFragmentSource fields for the two versions of a simple shader at runtime, they were the same, but only the metadata version worked).
I then instantiated the plain old Shader class, copying all of the vertex shader code and fragment shader code from the metadata annotations in the DisplayObjectShader class, and assigned my constructed GLSL to the fields for that vanilla Shader instance, and it worked properly.
My main question then, is if I’m to proceed like this, is what is considered proper attribution for reusing that code? Is attribution even required, given that it is necessary for pretty much any shader to run? I like to be conservative with attribution in any case, so I’ve gone ahead and added it to my THIRD_PARTY_LICENSES file, and will point to that file in a comment above the copied code where it appears in my source. I will also include it in a third-party licenses screen in release builds, so that all distribution methods are covered. However, any clarity on the official requirements and preferences of the OpenFL devs would be much appreciated.
A lesser question I have is, might there be a better way achieve what I’m trying to achieve with my shader, where the code to be used in the fragment body will be scattered in several places?
As always, any comments and assistance are much appreciated! I’ve asked this as well in the Discord server, so please excuse the redundancy.
