Closed Quasimondo closed 11 months ago
Thanks a lot! This really gives a good idea of what a socket based approach would look like.
I still need to review the solution space, and probably the problem space a little bit :). I'd really like to come up with a solution that's be generic and versatile.
Anyhow, your proposition is a very good candidate, and gives us a good baseline to start with.
I'll keep you posted here ASAP.
Thanks - I am happy if this motivates you to improve this library since it is really great for standalone work on affordable hardware! But yeah this definitely needs to be generalized more and the socket stuff also needs some more error handling and recovery from disconnect.
@Quasimondo I've been able to iterate on this, and finally landed on another approach that provides a Python wrapper around the native library.
I've just merged #21 that contains the bulk of the work. You'll be able to find some examples on how to bring your own inputs in the glsl.py
file here:
Do not hesitate to share any feedback or ideas you might have 🙏🏼.
Since I saw that some other people also wanted to be able to pass in variables into a shader, I hacked this patch together (with the help of GPT-4) which adds four uniforms vec4 iAux0, iAux1, iAux2 and iAux3 to the shader code and which can be updated by sending new values via a socket connection (e.g. from a Python script). Since this alters the functionality I did not want to submit this as a pull request, so please the excuse the bloatedness of this post.
It is all very rough and basic, but maybe someone with better C skills than me can turn this into something more universal. Of course you can also alter the variable names or types depending on your needs.
In Makefile you will have to add -lpthread to the libs since the socket runs in a thread, so the line has to be changed to this
LDLIBS=-lGLESv2 -lEGL -ldrm -lgbm -lxcb-randr -lxcb -lpthread
Patched shadertoy.c
A simple python test script which sends new random values every 2 seconds: