Open brainmachine opened 7 years ago
If the shader is saved as files, you can use the vertexShaderFile / fragmentShaderFile arguments to BasicOperation to load it in from your application bundle.
You can also embed the string for the fragment and vertex shaders as a constant in your application code using something similar to what I do in the framework itself. Take the ShaderConverter.sh script and run it against a directory of shaders and it will generate Swift files containing them as inlined strings. Follow the naming convention I use to provide shaders for OpenGL and OpenGL ES as necessary.
Thanks Brad. I tried loading a fragment shader from the bundle as well as converting it to a constant but when I use the class I get a compiler error telling me that the class name is an unresolved identifier. When looking for solutions I came across this [stackoverflow post] (http://stackoverflow.com/questions/28996730/use-of-unresolved-identifier-in-swift). I may have overlooked something. I will look into this again.
I have a cocoapods workspace that contains my project and GPUImage2. I am trying to add custom shaders as a part of my project without adding them to the GPUImage2 framework. I created a class that subclasses BasicOperation and initializes the shader. However, I can not use this shader unless I add it to the GPUImage2 target, which is inaccessible when the class is part of my project. The only solution I've found right now is to add it to the framework.