Giter Site home page Giter Site logo

eyeo2012's Issues

can someone explain those lantern shaders in flocking app?

I tried that shader in shaderfrog here. Some thing looks wired about it. I also tried to use it in processing. here is what it looks like .
screen shot 2017-06-03 at 11 55 58 pm black cube is the light position.
one thing that seems wrong is when cube goes behind the sphere the red blob does not go back. I think its because in code mvpMatrix of cam is passed to shader but I am not getting it how to access mvpMatrix of camera in processing. it must be that problem that is causing the anomaily.
Hey robert please don't mind I am just trying to understand the shader. :) your work always amaze me and I love it just trying to understand how you create those visuals. I know its hard for you to explain the code but I would appreciate if some one might do that. Just learning shaders.

PShader lantern;

void setup() {
  size(700  , 600, P3D);
  noStroke();
  fill(204);
  lantern = loadShader("frag.glsl", "vert.glsl");
  float z =(height/2.0) / tan(PI*30.0 / 180.0);        //default camera pos for processing
  //println(z);
  lantern.set("eyePos",width/2.0, height/2.0, z);  //default camera pos for processing
  lantern.set("roomDim",7000.0,7000.0,7000.0);
  lantern.set("mainPower",05.99);
  
}
float t=0;float r=173;// ticker and radius of sphere
void draw() {
  float dirY = 0;
  float dirX = r*sin(t*2*PI);
  float dirZ = r*cos(t*2*PI);
  lantern.set("lightPos",-dirX,-dirY,dirZ,0);  //setting light pos for the shader 
  shader(lantern);          
  background(0);
  t+=0.01;
  translate(width/2, height/2,0);                 //moiving to center of screen
  //fill(255);
  //directionalLight(20, 204, 204, -dirX, -dirY, dirZ);  // setting directional  ,not need for this shader
  for(int i=0;i<1;i++){         //for if you wanted to create multiple spheres
  fill(120,100,80);
  pushMatrix();
  translate(0, 0, 0);           // translate multiple spheres to different positions : set the random values or some calculated locations(x= rad*sin(theta), y= rad*cos(theta))
  sphere(170);                   //main sphere with shader
  //box(900,900,0);
  popMatrix();
  }

  resetShader();
  pushMatrix();
  translate(-dirX, -dirY, dirZ);
  fill(255,0,0);
  box(10,10,10);           //virtual light box , just to see where the light is.
  popMatrix();
}````

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.