Giter Site home page Giter Site logo

arthur100500 / glsl-node-editor Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 92.12 MB

A Web-based visual editor for GLSL fragment shaders

License: MIT License

Python 23.31% CSS 14.54% JavaScript 49.24% HTML 12.90%
editor glsl glsl-shaders shaders visual-editor visual-programming website

glsl-node-editor's Introduction

GLSL Node Editor

GLSL node editor is a web-based editor for WebGL fragment shaders. It uses visual programming to model a work of shader, but you can always write your own node with the code you want.

Shader Editor

Creates shaders using nodes

How to run

Make sure you have python installed
Clone the repo with
git clone https://github.com/arthur100500/glsl-node-editor.git
Install dependecies with
pip install requirements.txt
If it is your first run, initialize the database
python3 src/app.py init
Run app with
python3 src/app.py

How to use

How to create a new shader

  • Register an account, clicking on the button Sign in
  • Click on Projects button, click + Create new project
  • You can change a name and description of your project just with clicking and editing its data

How to use Shader Editor

  • To move around, use mouse, scroll to zoom in/out
  • To place a node, right click and choose one from the list that drops
  • To move a specific, drag its header
  • To connect nodes, click on one anchor and click on the other, starting from input to output
    • Alternatively, you can just click once, drag and drop onto the other node output
  • To see the output and see if shader is correct, press the Compile button
  • To save the project, press the Save Project button, changes you have made will not change automatically
  • To download the shader text, press the Save as Shader button

Program correctness

  • As all inputs are typed, you are unlikely to have an issue if:
    • All nodes inputs are connected
  • Programs should have an output, a colorOutput node

Node Editor

Creates nodes using GLSL code

How to create a new node

  • Register an account, clicking on the button Sign in
  • Click on Nodes button, click + Create new node

How to edit nodes name

  • Name of the node is defined by its name. _ symbols will be replaced by space

How to add custom uniforms

You can add custom uniforms to your node. Just write them above the function like this

// Uniforms you want to add
uniform vec3 colorBase;
uniform float transparency;
uniform int index;

// Your function
vec4 your_function(){
    if (index > 1) 
        return vec4(1.0);
    return vec4(colorBase, transparency);
}

Built-in nodes

Inputs:

  • texCoord, texCoordX and texCoordY - position of pixel on screen from (0, 0) to (1, 1)
  • time - float time in secods, 1s = 1.0
  • mousePos - position of mouse cursor on screen, from (0, 0) to (1, 1)

Outputs:

  • outputColor - vec4, color of pixel, from (0, 0, 0, 0) to (1, 1, 1, 1), in RGBA format

Math:

  • sin - sin(value)
  • pow - value to the power of power
  • rand - random number for each position on screen
  • noise - perlin noise
  • avg - avarage between 4 floats
  • multiplyff - float * float
  • multiplyfv2 float * vec2
  • multiplyfv4 float * vec4
  • plus - float + float
  • plusv2 - vec2 + vec2
  • plusv4 - vec4 + vec4
  • minus - float - float

Conversions:

  • vec2x - the first component of vec2
  • vec2y - the second component of vec2
  • vec4r - the first component of vec2, red channel of a color
  • vec4g - the second component of vec2, green channel of a color
  • vec4b - the third component of vec2, blue channel of a color
  • vec4a - the fourth component of vec2, alpha channel of a color
  • fromFloatV2 - vec2 from 2 floats, (x, y)
  • fromFloatV4 - vec4 from 4 floats, (r, g, b, a)

Constants:

  • int - integer constant
  • float - float constant
  • vec2 - vec2 constant for position
  • vec4 - vec4 constant for color

Logic:

  • multiplex - chooses between two floats, if the bool is true picks first, else second
  • isBigger - a > b

Textures:

  • textureN - gets a color from a texture with the position given

Custom:

Nodes you added

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.