GithubHelp home page GithubHelp logo

technologyarts / threejs-shadertoy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shakthi/threejs-shadertoy

0.0 0.0 0.0 3.25 MB

A simple THREE.js template code that make use of three-shadertoy-material on render on a mesh

Home Page: https://shakthi.github.io/threejs-shadertoy/dist/

License: MIT License

JavaScript 88.57% GLSL 11.43%

threejs-shadertoy's Introduction

THREE SHADERTOY

A simple THREE.js template code that make use of three-shadertoy-material to render on a mesh. You can edit the sourcecode or load shaders dynamically using shadertoy.com Api. Type the url of shader from shadertoy.com. This is still an experimental feature. Only public+api shaders can be loaded dynamically. Corresponding npm module three-shadertoy-material-loader.

Here is the sample rendering by a shadertoy code copied from https://en.wikipedia.org/wiki/Shadertoy (as of 31 Jul 18)

https://shakthi.github.io/threejs-shadertoy/dist/

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
    // input: pixel coordinates
    vec2 p = (-iResolution.xy + 2.0*fragCoord)/iResolution.y;

    // angle of each pixel to the center of the screen
    float a = atan(p.y,p.x);
    
    // modified distance metric
    float r = pow( pow(p.x*p.x,4.0) + pow(p.y*p.y,4.0), 1.0/8.0 );
    
    // index texture by (animated inverse) radious and angle
    vec2 uv = vec2( 1.0/r + 0.2*iTime, a );

    // pattern: cosines
    float f = cos(12.0*uv.x)*cos(6.0*uv.y);

    // color fetch: palette
    vec3 col = 0.5 + 0.5*sin( 3.1416*f + vec3(0.0,0.5,1.0) );
    
    // lighting: darken at the center    
    col = col*r;
    
    // output: pixel color
    fragColor = vec4( col, 1.0 );
}

And the screenshot of the THREE.PlaneGeometry

alt text

Other plublic+api shader demo

threejs-shadertoy's People

Contributors

shakthi 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.