greggman / vertexshaderart

The repo for vertexshaderart.com
http://vertexshaderart.com
BSD 3-Clause "New" or "Revised" License
136 stars 16 forks source link
shader shaders shadertoy vertex-shaders vertex-shdaer

# vertexshaderart

vertexshaderart.com is changing to a static site

This repo contains the older meteor based version. The repo for the new static version is at https://github.com/greggman/vertexshaderart.com


See it live at vertexshaderart.com

Clearly 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

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.

  1. A stand alone editor/visualizer

    To run this cd to the folder you cloned this repo in and type

    npm run start

    Now 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 src folder. The main entry point is src/js/main.js

    The code is a little funky because 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 on function to attach events to elements. Instead of doing someElement.addEventListener(event, func) you instead do on(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=false to 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.

  2. A Meteor based website

    The meteor based website exists at server/vertexshaderart. To run it first copy settings.json to settings-dev.json

    cd server/vertexshaderart
    cp settings.json settings-dev.json

    Then from the server/vertershaderart folder run start.

    ./start

    This will launch meteor. Once it's running you can open a browser to http://localhost:3000 and 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.json to 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

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)

Deploying

See DEPLOY.md

Changelist

See CHANGELIST.md.

License

MIT