vertexshaderart
vertexshaderart copied to clipboard
The repo for vertexshaderart.com
vertexshaderart
See it live at vertexshaderart.com
Cleary inspired by glslsandbox.com this one
only lets you edit a vertex shader. The vertex shaders main input is
just a vertexId that counts vertices.
Why?
Because limits are AWESOME! Like 4k demos (or 1k) setting limits almost always leads to more creativity.
Tips
A few tips when making art
-
Consider making things as resolution independent as possible.
-
gl_PointSizeYou might have a 2000x1000 desktop but someone might be viewing on a phone. If you set
gl_PointSize = 50.0that might be perfect on your desktop but too big for a phone.You could do something like this at the bottom of your shader
#define RESOLUTION_OF_MY_DISPLAY 2000.0 gl_PointSize *= resolution.x / RESOLUTION_OF_MY_DISPLAY; -
the aspect of the display
Remember that the user might be on a phone (so display taller than it is wide) vs a desktop (usually wider than tall). Consider taking that into account. For example scaling by the larger of resolution.x or resolution.y
-
-
Use
vertexCountwere appropriateYou can certainly set a specific count and design your art around that but, if you'd like to it can be nice to try to make it self adjust.
Example:
#define POINTS_PER_CUBE 24. float cubeVertexId = mod(vertexId, POINTS_PER_CUBE); // counts vertices in a cube float cubeId = floor(vertexCount / POINTS_PER_CUBE); // counts cubes
Embedding
You can embed a piece on your blog or whatever by putting the url in an iframe. Example
<iframe width="700" height="400" src="http://www.vertexshaderart.com/art/uqWtxuQpEkfxqWXCK" frameborder="0" allowfullscreen></iframe>
The UI will be removed and there will put a ▶ icon to start it.
Contributing
Pull requests or suggestions welcome. Please open an issue.
Building
Prerequsites
Visualizer vs Website
The site is split into 2 parts.
-
A stand alone editor/visualizer
To run this cd to the folder you cloned this repo in and type
npm run startNow open a browser to
http://localhost:8080/src/.You should see the shader editor with a shader running.
The source for this editor is in the
srcfolder. The main entry point issrc/js/main.jsThe code is a little funky becaue this was created first and then fitted into Meteor. Because Meteor replaces the entire DOM on the fly, when running in Meteor the code inits once, keeps the canvas and editor DOM elements around and inserts and removes them when required. Any variable that starts with
s.is something that survives across pages when on the website.There's also a special
onfunction to attach events to elements. Instead of doingsomeElement.addEventListener(event, func)you instead doon(someElement, event, func). This allows the code track and remove all event listeners when Meteor destroys the DOM because otherwise there would be a bunch of handlers still attached on those elements.Note: The visualizer is set to pause when its window does not have the focus. That includes if the URL bar or the devtools have the focus. This is to save battery when I'm doing dev but it can be a problem for debugging. depending on what code you're working on. It checks if it's running on
'localhost'to enable this feature. You can override this by adding?pauseOnBlur=falseto the URL.Note: You will not be able to use soundcloud tracks in the standalone editor. They changed their API (2021/7) so that a server is required.
-
A Meteor based website
The meteor based website exists at
server/vertexshaderart. To run it first copysettings.jsontosettings-dev.jsoncd server/vertexshaderart cp settings.json settings-dev.jsonThen from the
server/vertershaderartfolder runstart../startThis will launch meteor. Once it's running you can open a browser to
http://localhost:3000and you should see effectively the same site as http://www.vertexshaderart.com though you'll have no data or users.Note: You will need a soundcloud client and secret in your
settings-dev.jsonto use soundcloud tracks.
Updating the visualizer into the meteor website.
To update the visiualizer/editor into the meteor website cd to the root folder of this repo
and type npm run build.
That will
-
Compile all the JavaScript used in the visualizer app into 1 file and copy it to
server/vertexshaderart/client/vsart.js -
Convert
src/index.htmlinto meteor templates and save them inserver/vertexshaderart/client/vsart.htmlnote: a comment in the form of
<!--template=name-->will be converted to{{> name}}. This lets you insert other templates into the HTML from the visualizer. -
Concat all the css used by the visualizer and save in
server/vertexshaderart/client/vsart.css
Options for the visualizer/editor
The standalone visualizer/editor has a few options you can pass in on the URL. Options
are passed in by adding a ? and then key=value&key=value.
(eg: http://localhost:8080/src/?settings=audio2&local=true)
-
local=trueThis makes it use local music instead of going through soundcloud.
-
settings=<name>Where name is one of
audio,audio2,spiro,default.There are 4 built in visualiations. In the code search for
s.sets -
showHistory=trueThis fills the screen with the texture that contains the music history.
-
showFloatHistory=trueThis fills the screen with the texture that contains the float music history.
-
showTouchHistory=trueThis fills the screen with the texture that contains the touch data history.
-
long=trueAlong with
local=trueas inlocal=true&long=trueprovides a really long name and title for the music to test that layout doesn't get broken. -
pauseOnBlur=falseSee above.
-
pause=trueA more extreme version of
pauseOnBlur'. It's effectively the same aspauseOnBlur=true` and clicking the stop button at the top so that rendering is not running. I use this when I want to test UI layout on battery. I can muck with the CSS etc and not having it rendering the heavy graphics.
Deploying
See DEPLOY.md
Changelist
See CHANGELIST.md.
License
MIT