Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidating glsl shaders to a common directory #454

Open
bencbartlett opened this issue Jun 15, 2022 · 1 comment
Open

Consolidating glsl shaders to a common directory #454

bencbartlett opened this issue Jun 15, 2022 · 1 comment

Comments

@bencbartlett
Copy link
Collaborator

Trello card: https://trello.com/c/dwCvAw2N

Talked about this with @alejot127 last week. I'm still trying to familiarize myself with the codebase and how shows and scenes are constructed; I was hoping to merge a couple of new shaders I've written, but there doesn't seem to be any common library for where all our shaders are stored. It looks like most of the shaders just get added as stringified glsl code in a .sparkle file.

At the moment, if I go to make a new show, I'm limited to only using the shaders provided by the template show. Having shows maintain their own separate list of shaders is good especially if we add a ton of new shaders in the future, but when you go to make a new show, I think it could be good to have a "add shader" button which shows the list of all available shaders codebase. Then you can add whichever ones you want into the show's shader library, and the .sparkle file will only need to maintain a reference to where the code is, rather than maintaining its own independent version of the shader code.

Proposal:

Instead of including the body of the code for each in the show's .sparkle file, can we just include the name of the shader and have it pull the code from the directory at src/commonMain/resources/shader-libraries/built-in? This would make it a lot easier to add/edit shaders and would also mean that new shows could access all of the shader assets. We could either assume that the shaders are named as <Shader Name>.glsl or have it reference the existing _libraryIndex.json file.

@xian Does this sound like a good idea? I can start consolidating all of the shaders into a common library and add a few of my own if it seems feasible for you to make the changes of how the shader code is referenced on the Kotlin side of things.

@xian
Copy link
Member

xian commented Jun 16, 2022

Actually you can add shaders from that built-in shader library:

Screen.Recording.2022-06-15.at.5.01.03.PM.mov

… errr, you're supposed to be able to. Not sure what that error at the end is about. I'll investigate.

But, yeah, currently shaders live in the show JSON (.sparkle) file. It'd be nice to have a way to link out to resources like shaders, but it quickly gets into versioning questions and stuff... Def interested in talking it through though. I'd really like to come up with an easy way for people to share their work, maybe via git repos or some other community-accessible thing.

For now maybe just drop stuff into the built-in dir though?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To do
Development

No branches or pull requests

2 participants