Open peabrainiac opened 3 years ago
Well we could have types be a dropdown on a variable block, and have structs be defined as a block holding variable blocks, right? And just program it to define that as a struct rather than a list/array/vector of those values. For mat, we could just have fields the user inputs to, and if the mat size requested doesn't exist just throw an error? I'm still unsure about how to go about the vec functions.
Regarding step 1: after 3 hours of working through weird errors, I've now finally managed to set up and build those four repositories locally. Build instructions are here now, so you'll hopefully have an easier time with this than I just had: https://github.com/ShaderScratch/organisation#setup
Perhaps we could use vector components and then parse adjacent components as a swizzled vector? This would allow us to retain a non-dynamic vector block.
Let's maybe keep the most important points of discussion about how we are planning on doing this here for now instead of on discord, so we can use markdown and this doesn't get buried too quickly. Unless one of you has a better idea, of course.
general vision
Just to be sure we're all on the same page: the goal of this is to build a scratch-like, block-based shader programming environment with similar capabilities as shadertoy, and possibly even hook it up to the shadertoy API later on. right?
The probably simplest / best way to do that would be to fork scratch (repos can be found here) and adapt it to fit our needs, We could in theory also fork blockly - the library scratch uses under the hood - but I feel like that is not only uglier than scratch, but also would be way more work to adapt, since with scratch we already have a full well-designed editor that takes care of having different code spaces (sprites, in our case buffers), a stage on which the project can be seen, controls for it, an ui bar at the top etc., while blockly basically only has the block editor itself.
The first long-term goal should probably be to get an editor to work than can load simple shadertoy shaders from json files like you can get by exporting them there, run them, display their code in the form of blocks, allow you to edit those blocks, and save them to a shadertoy-readable json file again. Starting things like a backend, further shadertoy integration or advanced features now would not make much sense, since they would end up as a waste of time if it later turns out that we can't even get a simple editor to work.
One thing to keep in mind though regarding possible shadertoy integration: while the Shadertoy API is open for anyone to use, I think it can only be used to fetch shaders, not upload them. It also requires us to get an API key, which should probably be kept private, so just accessing shadertoy from within the browser is most likely not an option. So, just keep in mind that even if this whole editor thing works out as planned, we'll still be limited in that regard.
scratch repo structure
Now, regarding what I have found out about the scratch codebase so far:
Those are at least the repositories that I think might be important for our work here; all of the other ones, like scratch-paint, scratch-audio and scratch-svg-renderer can probably be ignored.
licensing
All of those repositories are licensed under the BSD-3-Clause License, except for scratch-blocks, which is licensed under the Apache License 2.0. If I unterstand those correctly, that means we're allowed to modify, redistribute and use the code theoretically even commercially, as long as we keep the original license and copyright notice. However, we can't just continue to use the copyrighted name "scratch" for those modifications; I'm not sure if the derived name ShaderScratch would be ok or if we need to come up with something else, so someone should probably look into that further.
next steps
Based on all of this, I think the next logical steps would be:
vec2(float)
,vec2(float,float)
,vec2(vec2)
,vec3(float)
etc., or something simpler, which may though possibly be harder to impose type-checks on?mat2
,mat3
andmat4
, but alsomat2x3
and other asymmetric matrices. how will we support those?inout
andout
parameters? if we want to be compatible with shadertoy we should probably support those (especially since every single main function there already depends on those), but how exactly should that look?The order of the steps here is of course somewhat arbitrary, and many of them can of course be worked on simultaniously. However, I think aside from such smaller deviations, the order outlined here is what would make the most sense.
To be honest, I kind of doubt we'll ever make it past step 3 - but of course, it doesn't hurt to try. I'm still sort of busy with university right now, but I'll see if I can spend some more time on this during the next semester break. And of course, having this many or even more people potentially working on the project doesn't hurt our chances of actually managing to do this too.