GithubHelp home page GithubHelp logo

crayon.js's Introduction

crayon.js

A Node-based Shader Library for Three.js

A complex code sample showcasing the API flexibility

	// Init Shader Nodes
	sceneNode = new CRAYON.SceneNode();
	sceneDepthNode = new CRAYON.SceneDepthNode( sceneNode );

	edgeNode = new CRAYON.EdgeFilterNode( renderer );
	multiplyNode = new CRAYON.MultiplyNode( renderer );
	edgeFloatNode = new CRAYON.FloatEncoderNode( edgeNode ); // Read texture back to floats

	screenNode = new CRAYON.RenderToScreenNode( renderer ); // Renders to screen

	executorNode = new CRAYON.ExecutorNode( renderer ); // All graph end points should connect to ExecutorNode to be executed
	
	// Connect the nodes
	sceneNode.connect( sceneDepthNode ); // For depth
	sceneDepthNode.connect(edgeNode, 'texture') // For applying sobel edge filter
	edgeNode.connect(multiplyNode, 'texture1') // MultipleNode takes in first texture from outlines
	sceneNode.connect(multiplyNode, 'texture2') // MultipleNode takes in 2nd texture from the scene
	multiplyNode.connect(screenNode, 'texture'); // Renders multiple operator to screen
	edgeFloatNode.connect(executorNode, 'edge'); // Connect float encoder and read pixels to Executor
	
	// In the render loop
	executorNode.renderAll(); // Calculates all node dependencies, execute them and render to screen
	

##Q&A

Why Crayon?

  • Useful for prototyping shader systems
  • Each node encapsulates its own code, so its resuable
  • Each node have a renderTarget or an output
  • Makes it easy to rewire nodes without spaghetti code
  • For managable post-processing rendering

Why is this called Crayon?

  1. Crayons are for drawing or learning how to. I think we started with crayon when we were kids. I hope this library is akin to digital crayons, where I start to explore creating beautiful drawing and paintings.
  2. This library was created to help myself when I decided to work on some NPR (Non-Photorealistic Rendering) experiments eg. pencil, toon, watercolor shadings. Perhaps, I might be able to create an interactive crayon shader one day.

Is this yet another post-processing / shader library?

Well kinda. Not that I think writing my own code is the the best, but...

  • It started from wanting to scratch my own itch
  • Because I wanted to explore writing some NPR filters which are slightly more complex,
  • I wanted to ease the pain working on post-processing with three.js
  • I thought a Node-based approach is the way to go. (Similar to WebAudioAPI, Quartz Composer, Houdini, Nuke I think. Perhaps one day I'll build a node base UI for this as well :)
  • I'm experimenting and learning on the way

Just in case you're looking for related node-based / post-processing stuff

  • Three.js examples uses EffectComposer by @alteredq. They come right out of the box with three.js
  • @thespite is working on Wagner, his improved version of EffectComposer
  • ShaderGraph by Unconed. Pretty much uses a node based approach, and is used to power MathBox.
  • PP.js also a post-processing library for three.js with a fluent-style api.
  • Seriously.js Node based compositor for videos with WebGL.
  • ThreeNodes.js A web-based Visual Node-base system for Three.js
  • Reflektor Sandbox Graph A rather nice node library for the Reflektor project.

crayon.js's People

Contributors

zz85 avatar

Stargazers

theconektd avatar Faded Weiss avatar BenMack avatar Chris Gervang avatar Nadeera Sampath avatar  avatar Coby Chapple avatar lumix avatar  avatar  avatar 王畅 avatar  avatar  avatar Oleg Chulkov avatar Forrest Desjardins avatar aceway avatar Fabio Dias Rollo avatar Faruk Sabanovic avatar Samuel Holt avatar syt123450 avatar danielsdesk avatar alex lines avatar Antonio Gómez-Maldonado avatar Sashko avatar Marshall Jones avatar wandergis avatar Ben Forest avatar Ryan avatar Erik Vavro avatar Theun Kohlbeck avatar Dan Butler avatar Swissrift avatar Dmitri Pyatkov avatar Alexander Buzin avatar  avatar Tyler Anderson avatar Michael Anthony avatar Denis Stoyanov avatar B avatar Vladimir Stegantsov avatar MATSUDA Kengo avatar h h avatar Mike Tahani avatar Seth Fitzsimmons avatar Bruno Meneguello avatar Tuan Kuranes avatar Paul Alexandre Long avatar PeterLiou avatar Sergii Danilov avatar  avatar Vyacheslav avatar  avatar Tore Holmberg avatar Matt Hayes avatar Evgeny Shcherbinin avatar Cameron avatar  avatar Daniel K. avatar Roman Liutikov avatar Erick Patrick avatar Brad Pillow avatar Tom Beddard avatar Austris avatar Pana avatar Patrick avatar Chris Witko avatar Jeff Zerger avatar Daniele Pelagatti avatar TKNR avatar David Mignot avatar Neil Carpenter avatar Ben Houston avatar Lucas Epp avatar urtt avatar Gerónimo Garcia Sgritta avatar Alexander Salas Bastidas avatar Jeff Gray avatar James Hicks avatar  avatar Peter Nitsch avatar Jérémie Girault avatar Philipp Kovalev avatar Artur Kot avatar Nidin Vinayakan avatar  avatar Macaque Chen avatar Water Lou avatar Elisée Maurer avatar Christopher Humphries avatar Harald Kirkerød avatar Justin Gitlin avatar Brett Camper avatar

Watchers

 avatar Brian Chirls avatar James Cloos avatar John Cook avatar aceway avatar Denis Stoyanov avatar Michael Anthony avatar  avatar  avatar  avatar  avatar

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.