♻️ Use a single GLSL files for each effect

This commit is contained in:
Simon Schneegans
2022-05-13 09:17:26 +02:00
parent 84d5ad9caf
commit 7b8d6e18b2
34 changed files with 1006 additions and 915 deletions
+8 -3
View File
@@ -148,11 +148,16 @@ if (utils.isInShellProcess()) {
// This is called by the constructor. This means, it's only called when the effect
// is used for the first time.
vfunc_build_pipeline() {
const decl =
utils.loadGLSLResource(`/shaders/${TVEffect.getNick()}-declarations.glsl`);
const code = utils.loadGLSLResource(`/shaders/${TVEffect.getNick()}.glsl`);
this.add_glsl_snippet(Shell.SnippetHook.FRAGMENT, decl, code, true);
// Match anything between the curly brackets of "void main() {...}".
const regex = RegExp('void main *\\(\\) *\\{([\\S\\s]+)\\}', 'd');
const match = regex.exec(code);
const declarations = code.substr(0, match.index);
const main = match[1];
this.add_glsl_snippet(Shell.SnippetHook.FRAGMENT, declarations, main, true);
}
});
}