Java Code Examples for processing.opengl.PGraphics3D#textureSampling()

The following examples show how to use processing.opengl.PGraphics3D#textureSampling() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Skylight_PoissonSphereSamples.java    From PixelFlow with MIT License 4 votes vote down vote up
public void setup(){
  surface.setLocation(viewport_x, viewport_y);
  
  cam = new PeasyCam(this, 0, 0, 0, 1400);

  float sx = bounds[3] - bounds[0];
  float sy = bounds[4] - bounds[1];
  float sz = bounds[5] - bounds[2];
  
  float px = (bounds[3] + bounds[0]) * 0.5f;
  float py = (bounds[4] + bounds[1]) * 0.5f;
  float pz = (bounds[5] + bounds[2]) * 0.5f;
  float rad = (float)(Math.sqrt(sx*sx + sy*sy + sz*sz) * 0.5f);
  
  DwBoundingSphere scene_bs = new DwBoundingSphere();
  scene_bs.set(px, py, pz, rad*1.5f);
  
  mat_scene_bounds = scene_bs.getUnitSphereMatrix();

  // callback for rendering the scene
  DwSceneDisplay scene_display = new DwSceneDisplay(){
    @Override
    public void display(PGraphics3D canvas) {
      displayScene(canvas);  
    }
  };
  
  // library context
  context = new DwPixelFlow(this);
  context.print();
  context.printGL();
  
  
  
  smaa = new SMAA(context);
  // postprocessing AA
  pg_aa = (PGraphics3D) createGraphics(width, height, P3D);
  pg_aa.smooth(0);
  pg_aa.textureSampling(5);


  pg_tmp = (PGraphics3D) createGraphics(width, height, P3D);
  pg_tmp.smooth(0);
  pg_tmp.textureSampling(5);
  
  
  
  // init skylight renderer
  skylight = new DwSkyLight(context, scene_display, mat_scene_bounds);
  
  // parameters for sky-light
  skylight.sky.param.iterations     = 60;
  skylight.sky.param.solar_azimuth  = 0;
  skylight.sky.param.solar_zenith   = 0;
  skylight.sky.param.sample_focus   = 1; // full sphere sampling
  skylight.sky.param.intensity      = 1.0f;
  skylight.sky.param.rgb            = new float[]{1,1,1};
  skylight.sky.param.shadowmap_size = 512; // quality vs. performance
  
  // parameters for sun-light
  skylight.sun.param.iterations     = 60;
  skylight.sun.param.solar_azimuth  = 45;
  skylight.sun.param.solar_zenith   = 55;
  skylight.sun.param.sample_focus   = 0.10f;
  skylight.sun.param.intensity      = 1.0f;
  skylight.sun.param.rgb            = new float[]{1,1,1};
  skylight.sun.param.shadowmap_size = 512;
  
  
  
  generatePoissonSampling();

  frameRate(60);
}
 
Example 2
Source File: Skylight_Cubes.java    From PixelFlow with MIT License 4 votes vote down vote up
public void setup(){
  surface.setLocation(viewport_x, viewport_y);
  
  cam = new PeasyCam(this, 0, 0, 0, 1400);
  
  perspective(60 * PI/180f, width/(float)height, 2, 4000);
  
  float sx = bounds[3] - bounds[0];
  float sy = bounds[4] - bounds[1];
  float sz = bounds[5] - bounds[2];
  
  float px = (bounds[3] + bounds[0]) * 0.5f;
  float py = (bounds[4] + bounds[1]) * 0.5f;
  float pz = (bounds[5] + bounds[2]) * 0.5f;
  float rad = (float)(Math.sqrt(sx*sx + sy*sy + sz*sz) * 0.5f);
  
  DwBoundingSphere scene_bs = new DwBoundingSphere();
  scene_bs.set(px, py, pz, rad*1.5f);
  
  mat_scene_bounds = scene_bs.getUnitSphereMatrix();

  // callback for rendering the scene
  DwSceneDisplay scene_display = new DwSceneDisplay(){
    @Override
    public void display(PGraphics3D canvas) {
      displayScene(canvas);  
    }
  };
  
  // library context
  context = new DwPixelFlow(this);
  context.print();
  context.printGL();
  
  
  
  smaa = new SMAA(context);
  // postprocessing AA
  pg_aa = (PGraphics3D) createGraphics(width, height, P3D);
  pg_aa.smooth(0);
  pg_aa.textureSampling(5);


  pg_tmp = (PGraphics3D) createGraphics(width, height, P3D);
  pg_tmp.smooth(0);
  pg_tmp.textureSampling(5);
  
  
  
  // init skylight renderer
  skylight = new DwSkyLight(context, scene_display, mat_scene_bounds);
  
  // parameters for sky-light
  skylight.sky.param.iterations     = 100;
  skylight.sky.param.solar_azimuth  = 0;
  skylight.sky.param.solar_zenith   = 0;
  skylight.sky.param.sample_focus   = 1f; // full sphere sampling
  skylight.sky.param.intensity      = 2.0f;
  skylight.sky.param.rgb            = new float[]{1,1,1};
  skylight.sky.param.shadowmap_size = 512; // quality vs. performance
  
  // parameters for sun-light
  skylight.sun.param.iterations     = 100;
  skylight.sun.param.solar_azimuth  = 35;
  skylight.sun.param.solar_zenith   = 45;
  skylight.sun.param.sample_focus   = 0.1f;
  skylight.sun.param.intensity      = 1.0f;
  skylight.sun.param.rgb            = new float[]{1,1,1};
  skylight.sun.param.shadowmap_size = 512;
  
  
  createScene();
  
  frameRate(60);
}
 
Example 3
Source File: Skylight_BulletPhysics_Cubes.java    From PixelFlow with MIT License 4 votes vote down vote up
public void setup() {
  
  surface.setLocation(viewport_x, viewport_y);
  
  float SCENE_SCALE = 1000;
  
  // for screenshot
  capture = new DwFrameCapture(this, "examples/");
  
  font12 = createFont("../data/SourceCodePro-Regular.ttf", 12);

  cam = new PeasyCam(this, 0, 0, 0, SCENE_SCALE);
  perspective(60 * DEG_TO_RAD, width/(float)height, 2, SCENE_SCALE * 250);

  group_bulletbodies = createShape(GROUP);
  
  physics = new BPhysics(); // no bounding box
  physics.world.setGravity(new Vector3f(0, 0, -50));
 
  pg_render = (PGraphics3D) createGraphics(width, height, P3D);
  pg_render.smooth(0);
  pg_render.beginDraw();
  pg_render.endDraw();
  
  
  // compute scene bounding-sphere
  DwBoundingSphere scene_bs = new DwBoundingSphere();
  scene_bs.set(0, 0, 200, 450);
  PMatrix3D mat_bs = scene_bs.getUnitSphereMatrix();

  // matrix, to place (centering, scaling) the scene in the viewport
  mat_scene_view = new PMatrix3D();
  mat_scene_view.scale(SCENE_SCALE);
  mat_scene_view.apply(mat_bs);

  // matrix, to place the scene in the skylight renderer
  mat_scene_bounds = mat_scene_view.get();
  mat_scene_bounds.invert();
  mat_scene_bounds.preApply(mat_bs);

  // callback for rendering the scene
  DwSceneDisplay scene_display = new DwSceneDisplay(){
    @Override
    public void display(PGraphics3D canvas) {
      displayScene(canvas);  
    }
  };
  
  // library context
  context = new DwPixelFlow(this);
  context.print();
  context.printGL();
  
  // postprocessing filters
  filter = DwFilter.get(context);
  
  // init skylight renderer
  skylight = new DwSkyLight(context, scene_display, mat_scene_bounds);
  
  // parameters for sky-light
  skylight.sky.param.iterations     = 50;
  skylight.sky.param.solar_azimuth  = 0;
  skylight.sky.param.solar_zenith   = 0;
  skylight.sky.param.sample_focus   = 1; // full sphere sampling
  skylight.sky.param.intensity      = 1.0f;
  skylight.sky.param.rgb            = new float[]{1,1,1};
  skylight.sky.param.shadowmap_size = 512; // quality vs. performance
  
  // parameters for sun-light
  skylight.sun.param.iterations     = 50;
  skylight.sun.param.solar_azimuth  = 35;
  skylight.sun.param.solar_zenith   = 70;
  skylight.sun.param.sample_focus   = 0.1f;
  skylight.sun.param.intensity      = 1.0f;
  skylight.sun.param.rgb            = new float[]{1,1,1};
  skylight.sun.param.shadowmap_size = 512;
  
  // postprocessing AA
  smaa = new SMAA(context);
  pg_aa = (PGraphics3D) createGraphics(width, height, P3D);
  pg_aa.smooth(0);
  pg_aa.textureSampling(5);
  
  
  dof = new DepthOfField(context);
  geombuffer = new DwScreenSpaceGeometryBuffer(context, scene_display);
  
  pg_tmp = (PGraphics3D) createGraphics(width, height, P3D);
  pg_tmp.smooth(0);
  DwUtils.changeTextureFormat(pg_tmp, GL2.GL_RGBA16F, GL2.GL_RGBA, GL2.GL_FLOAT);

  // fresh start
  reset();
  
  createFractureShape();
  
  frameRate(60);
}
 
Example 4
Source File: Skylight_BulletPhysics_CellFracture.java    From PixelFlow with MIT License 4 votes vote down vote up
public void setup() {
  
  surface.setLocation(viewport_x, viewport_y);
  
  float SCENE_SCALE = 1000;
  
  // for screenshot
  capture = new DwFrameCapture(this, "examples/");
  
  font12 = createFont("../data/SourceCodePro-Regular.ttf", 12);

  cam = new PeasyCam(this, 0, 0, 0, SCENE_SCALE);
  perspective(60 * DEG_TO_RAD, width/(float)height, 2, SCENE_SCALE * 250);

  group_bulletbodies = createShape(GROUP);
  
  physics = new BPhysics(); // no bounding box
  physics.world.setGravity(new Vector3f(0, 0, -100));
 
  pg_render = (PGraphics3D) createGraphics(width, height, P3D);
  pg_render.smooth(0);
  pg_render.beginDraw();
  pg_render.endDraw();
  
  
  // compute scene bounding-sphere
  DwBoundingSphere scene_bs = new DwBoundingSphere();
  scene_bs.set(0, 0, 200, 450);
  PMatrix3D mat_bs = scene_bs.getUnitSphereMatrix();

  // matrix, to place (centering, scaling) the scene in the viewport
  mat_scene_view = new PMatrix3D();
  mat_scene_view.scale(SCENE_SCALE);
  mat_scene_view.apply(mat_bs);

  // matrix, to place the scene in the skylight renderer
  mat_scene_bounds = mat_scene_view.get();
  mat_scene_bounds.invert();
  mat_scene_bounds.preApply(mat_bs);

  // callback for rendering the scene
  DwSceneDisplay scene_display = new DwSceneDisplay(){
    @Override
    public void display(PGraphics3D canvas) {
      displayScene(canvas);  
    }
  };
  
  // library context
  context = new DwPixelFlow(this);
  context.print();
  context.printGL();
  
  // postprocessing filters
  filter = DwFilter.get(context);
  
  // init skylight renderer
  skylight = new DwSkyLight(context, scene_display, mat_scene_bounds);
  
  // parameters for sky-light
  skylight.sky.param.iterations     = 50;
  skylight.sky.param.solar_azimuth  = 0;
  skylight.sky.param.solar_zenith   = 0;
  skylight.sky.param.sample_focus   = 1; // full sphere sampling
  skylight.sky.param.intensity      = 1.0f;
  skylight.sky.param.rgb            = new float[]{1,1,1};
  skylight.sky.param.shadowmap_size = 512; // quality vs. performance
  
  // parameters for sun-light
  skylight.sun.param.iterations     = 50;
  skylight.sun.param.solar_azimuth  = 35;
  skylight.sun.param.solar_zenith   = 65;
  skylight.sun.param.sample_focus   = 0.1f;
  skylight.sun.param.intensity      = 1.0f;
  skylight.sun.param.rgb            = new float[]{1,1,1};
  skylight.sun.param.shadowmap_size = 512;
  
  // postprocessing AA
  smaa = new SMAA(context);
  pg_aa = (PGraphics3D) createGraphics(width, height, P3D);
  pg_aa.smooth(0);
  pg_aa.textureSampling(5);
  
  
  dof = new DepthOfField(context);
  geombuffer = new DwScreenSpaceGeometryBuffer(context, scene_display);
  
  pg_tmp = (PGraphics3D) createGraphics(width, height, P3D);
  pg_tmp.smooth(0);
  DwUtils.changeTextureFormat(pg_tmp, GL2.GL_RGBA16F, GL2.GL_RGBA, GL2.GL_FLOAT);


  // fresh start
  reset();
  
  createFractureShape();
  
  frameRate(60);
}
 
Example 5
Source File: Skylight_BulletPhysics_MengerSponge.java    From PixelFlow with MIT License 4 votes vote down vote up
public void setup() {
  
  surface.setLocation(viewport_x, viewport_y);
  
  float SCENE_SCALE = 1000;
  
  // for screenshot
  capture = new DwFrameCapture(this, "examples/");
  
  font12 = createFont("../data/SourceCodePro-Regular.ttf", 12);

  cam = new PeasyCam(this, 0, 0, 0, SCENE_SCALE);
  perspective(60 * DEG_TO_RAD, width/(float)height, 2, SCENE_SCALE * 250);

  group_bulletbodies = createShape(GROUP);
  
  physics = new BPhysics(); // no bounding box
  physics.world.setGravity(new Vector3f(0, 0, -50));
 
  pg_render = (PGraphics3D) createGraphics(width, height, P3D);
  pg_render.smooth(0);
  pg_render.beginDraw();
  pg_render.endDraw();
  
  
  // compute scene bounding-sphere
  DwBoundingSphere scene_bs = new DwBoundingSphere();
  scene_bs.set(0, 0, 200, 450);
  PMatrix3D mat_bs = scene_bs.getUnitSphereMatrix();

  // matrix, to place (centering, scaling) the scene in the viewport
  mat_scene_view = new PMatrix3D();
  mat_scene_view.scale(SCENE_SCALE);
  mat_scene_view.apply(mat_bs);

  // matrix, to place the scene in the skylight renderer
  mat_scene_bounds = mat_scene_view.get();
  mat_scene_bounds.invert();
  mat_scene_bounds.preApply(mat_bs);

  // callback for rendering the scene
  DwSceneDisplay scene_display = new DwSceneDisplay(){
    @Override
    public void display(PGraphics3D canvas) {
      displayScene(canvas);  
    }
  };
  
  // library context
  context = new DwPixelFlow(this);
  context.print();
  context.printGL();
  
  // postprocessing filters
  filter = DwFilter.get(context);
  
  // init skylight renderer
  skylight = new DwSkyLight(context, scene_display, mat_scene_bounds);
  
  // parameters for sky-light
  skylight.sky.param.iterations     = 50;
  skylight.sky.param.solar_azimuth  = 0;
  skylight.sky.param.solar_zenith   = 0;
  skylight.sky.param.sample_focus   = 1; // full sphere sampling
  skylight.sky.param.intensity      = 1.0f;
  skylight.sky.param.rgb            = new float[]{1,1,1};
  skylight.sky.param.shadowmap_size = 512; // quality vs. performance
  
  // parameters for sun-light
  skylight.sun.param.iterations     = 50;
  skylight.sun.param.solar_azimuth  = 35;
  skylight.sun.param.solar_zenith   = 70;
  skylight.sun.param.sample_focus   = 0.1f;
  skylight.sun.param.intensity      = 1.0f;
  skylight.sun.param.rgb            = new float[]{1,1,1};
  skylight.sun.param.shadowmap_size = 512;
  
  // postprocessing AA
  smaa = new SMAA(context);
  pg_aa = (PGraphics3D) createGraphics(width, height, P3D);
  pg_aa.smooth(0);
  pg_aa.textureSampling(5);
  
  
  dof = new DepthOfField(context);
  geombuffer = new DwScreenSpaceGeometryBuffer(context, scene_display);
  
  pg_tmp = (PGraphics3D) createGraphics(width, height, P3D);
  pg_tmp.smooth(0);
  DwUtils.changeTextureFormat(pg_tmp, GL2.GL_RGBA16F, GL2.GL_RGBA, GL2.GL_FLOAT);

  // fresh start
  reset();
  
  createFractureShape();
  
  frameRate(60);
}
 
Example 6
Source File: Skylight_Movie2.java    From PixelFlow with MIT License 4 votes vote down vote up
public void setup(){
  surface.setLocation(viewport_x, viewport_y);
  
  cam = new PeasyCam(this, 0, 0, 0, 1400);
  
  perspective(60 * PI/180f, width/(float)height, 2, 4000);

  float sx = bounds[3] - bounds[0];
  float sy = bounds[4] - bounds[1];
  float sz = bounds[5] - bounds[2];
  
  float px = (bounds[3] + bounds[0]) * 0.5f;
  float py = (bounds[4] + bounds[1]) * 0.5f;
  float pz = (bounds[5] + bounds[2]) * 0.5f;
  float rad = (float)(Math.sqrt(sx*sx + sy*sy + sz*sz) * 0.5f);
  
  DwBoundingSphere scene_bs = new DwBoundingSphere();
  scene_bs.set(px, py, pz, rad*1.5f);
  
  mat_scene_bounds = scene_bs.getUnitSphereMatrix();

  // callback for rendering the scene
  DwSceneDisplay scene_display = new DwSceneDisplay(){
    @Override
    public void display(PGraphics3D canvas) {
      displayScene(canvas);  
    }
  };
  
  // library context
  context = new DwPixelFlow(this);
  context.print();
  context.printGL();
  
  

  
  // opticalflow
  opticalflow = new DwOpticalFlow(context, src_w, src_h);
  
  // some flow parameters
  opticalflow.param.flow_scale         = 100;
  opticalflow.param.temporal_smoothing = 0.8f;
  opticalflow.param.display_mode       = 0;
  opticalflow.param.grayscale          = true;
  
  // render target
  pg_oflow = (PGraphics2D) createGraphics(src_w, src_h, P2D);
  pg_oflow.smooth(8);

  // drawing canvas, used as input for the optical flow
  pg_src = (PGraphics2D) createGraphics(src_w, src_h, P2D);
  pg_src.smooth(8);
  
  
  
  smaa = new SMAA(context);
  // postprocessing AA
  pg_aa = (PGraphics3D) createGraphics(width, height, P3D);
  pg_aa.smooth(0);
  pg_aa.textureSampling(5);


  pg_tmp = (PGraphics3D) createGraphics(width, height, P3D);
  pg_tmp.smooth(0);
  pg_tmp.textureSampling(5);
  
  
  
  // init skylight renderer
  skylight = new DwSkyLight(context, scene_display, mat_scene_bounds);
  
  // parameters for sky-light
  skylight.sky.param.iterations     = 100;
  skylight.sky.param.solar_azimuth  = 0;
  skylight.sky.param.solar_zenith   = 0;
  skylight.sky.param.sample_focus   = 1f; // full sphere sampling
  skylight.sky.param.intensity      = 2.0f;
  skylight.sky.param.rgb            = new float[]{1,1,1};
  skylight.sky.param.shadowmap_size = 512; // quality vs. performance
  
  // parameters for sun-light
  skylight.sun.param.iterations     = 100;
  skylight.sun.param.solar_azimuth  = 35;
  skylight.sun.param.solar_zenith   = 45;
  skylight.sun.param.sample_focus   = 0.1f;
  skylight.sun.param.intensity      = 1.0f;
  skylight.sun.param.rgb            = new float[]{1,1,1};
  skylight.sun.param.shadowmap_size = 512;
  
  
  createScene();
  
  frameRate(60);
}
 
Example 7
Source File: Skylight_Capture1.java    From PixelFlow with MIT License 4 votes vote down vote up
public void setup(){
  surface.setLocation(viewport_x, viewport_y);
  
  cam = new PeasyCam(this, 0, 0, 0, 1400);
  
  // webcam capture
  capture = new Capture(this, src_w, src_h, 30);
  capture.start();
  
  perspective(60 * PI/180f, width/(float)height, 2, 4000);

  float sx = bounds[3] - bounds[0];
  float sy = bounds[4] - bounds[1];
  float sz = bounds[5] - bounds[2];
  
  float px = (bounds[3] + bounds[0]) * 0.5f;
  float py = (bounds[4] + bounds[1]) * 0.5f;
  float pz = (bounds[5] + bounds[2]) * 0.5f;
  float rad = (float)(Math.sqrt(sx*sx + sy*sy + sz*sz) * 0.5f);
  
  DwBoundingSphere scene_bs = new DwBoundingSphere();
  scene_bs.set(px, py, pz, rad*1.5f);
  
  mat_scene_bounds = scene_bs.getUnitSphereMatrix();

  // callback for rendering the scene
  DwSceneDisplay scene_display = new DwSceneDisplay(){
    @Override
    public void display(PGraphics3D canvas) {
      displayScene(canvas);  
    }
  };
  
  // library context
  context = new DwPixelFlow(this);
  context.print();
  context.printGL();
  
  

  
  // opticalflow
  opticalflow = new DwOpticalFlow(context, src_w, src_h);
  
  // some flow parameters
  opticalflow.param.flow_scale         = 100;
  opticalflow.param.temporal_smoothing = 0.5f;
  opticalflow.param.display_mode       = 0;
  opticalflow.param.grayscale          = true;
  
  // render target
  pg_oflow = (PGraphics2D) createGraphics(src_w, src_h, P2D);
  pg_oflow.smooth(8);

  // drawing canvas, used as input for the optical flow
  pg_src = (PGraphics2D) createGraphics(src_w, src_h, P2D);
  pg_src.smooth(8);
  
  
  
  smaa = new SMAA(context);
  // postprocessing AA
  pg_aa = (PGraphics3D) createGraphics(width, height, P3D);
  pg_aa.smooth(0);
  pg_aa.textureSampling(5);


  pg_tmp = (PGraphics3D) createGraphics(width, height, P3D);
  pg_tmp.smooth(0);
  pg_tmp.textureSampling(5);
  
  
  
  // init skylight renderer
  skylight = new DwSkyLight(context, scene_display, mat_scene_bounds);
  
  // parameters for sky-light
  skylight.sky.param.iterations     = 100;
  skylight.sky.param.solar_azimuth  = 0;
  skylight.sky.param.solar_zenith   = 0;
  skylight.sky.param.sample_focus   = 1f; // full sphere sampling
  skylight.sky.param.intensity      = 2.0f;
  skylight.sky.param.rgb            = new float[]{1,1,1};
  skylight.sky.param.shadowmap_size = 512; // quality vs. performance
  
  // parameters for sun-light
  skylight.sun.param.iterations     = 100;
  skylight.sun.param.solar_azimuth  = 35;
  skylight.sun.param.solar_zenith   = 45;
  skylight.sun.param.sample_focus   = 0.1f;
  skylight.sun.param.intensity      = 1.0f;
  skylight.sun.param.rgb            = new float[]{1,1,1};
  skylight.sun.param.shadowmap_size = 512;
  
  
  createScene();
  
  frameRate(60);
}
 
Example 8
Source File: Skylight_Movie3.java    From PixelFlow with MIT License 4 votes vote down vote up
public void setup(){
  surface.setLocation(viewport_x, viewport_y);
  
  cam = new PeasyCam(this, 0, 0, 0, 1000);
  
  // webcam capture
  // movie file is not contained in the library release
  // to keep the file size small. please use one of your own videos instead.
  movie = new Movie(this, "examples/data/Pulp_Fiction_Dance_Scene.mp4");
  movie.loop();

  
  perspective(60 * PI/180f, width/(float)height, 2, 4000);

  float sx = bounds[3] - bounds[0];
  float sy = bounds[4] - bounds[1];
  float sz = bounds[5] - bounds[2];
  
  float px = (bounds[3] + bounds[0]) * 0.5f;
  float py = (bounds[4] + bounds[1]) * 0.5f;
  float pz = (bounds[5] + bounds[2]) * 0.5f;
  float rad = (float)(Math.sqrt(sx*sx + sy*sy + sz*sz) * 0.5f);
  
  DwBoundingSphere scene_bs = new DwBoundingSphere();
  scene_bs.set(px, py, pz, rad);
  
  mat_scene_bounds = scene_bs.getUnitSphereMatrix();

  // callback for rendering the scene
  DwSceneDisplay scene_display = new DwSceneDisplay(){
    @Override
    public void display(PGraphics3D canvas) {
      displayScene(canvas);  
    }
  };
  
  // library context
  context = new DwPixelFlow(this);
  context.print();
  context.printGL();
  
  
  smaa = new SMAA(context);
  // postprocessing AA
  pg_aa = (PGraphics3D) createGraphics(width, height, P3D);
  pg_aa.smooth(0);
  pg_aa.textureSampling(5);


  pg_tmp = (PGraphics3D) createGraphics(width, height, P3D);
  pg_tmp.smooth(0);
  pg_tmp.textureSampling(5);
  
  // init skylight renderer
  skylight = new DwSkyLight(context, scene_display, mat_scene_bounds);
  
  // parameters for sky-light
  skylight.sky.param.iterations     = 100;
  skylight.sky.param.solar_azimuth  = 0;
  skylight.sky.param.solar_zenith   = 0;
  skylight.sky.param.sample_focus   = 1f; // full sphere sampling
  skylight.sky.param.intensity      = 2.0f;
  skylight.sky.param.rgb            = new float[]{1,1,1};
  skylight.sky.param.shadowmap_size = 512; // quality vs. performance
  
  // parameters for sun-light
  skylight.sun.param.iterations     = 80;
  skylight.sun.param.solar_azimuth  = 35;
  skylight.sun.param.solar_zenith   = 45;
  skylight.sun.param.sample_focus   = 0.05f;
  skylight.sun.param.intensity      = 1.0f;
  skylight.sun.param.rgb            = new float[]{1,1,1};
  skylight.sun.param.shadowmap_size = 512;
  
  
  
  
  // opticalflow
  opticalflow = new DwOpticalFlow(context, src_w, src_h);
  
  // some flow parameters
  opticalflow.param.flow_scale         = 100;
  opticalflow.param.temporal_smoothing = 0.8f;
  opticalflow.param.display_mode       = 0;
  opticalflow.param.grayscale          = true;
  opticalflow.param.threshold = 2;
  
  tex_vel_small.resize(context, opticalflow.frameCurr.velocity);
  

  resize();
  
  frameRate(60);
}
 
Example 9
Source File: Skylight_Movie1.java    From PixelFlow with MIT License 4 votes vote down vote up
public void setup(){
  surface.setLocation(viewport_x, viewport_y);
  
  cam = new PeasyCam(this, 0, 0, 0, 1400);
  
  perspective(60 * PI/180f, width/(float)height, 2, 4000);

  float sx = bounds[3] - bounds[0];
  float sy = bounds[4] - bounds[1];
  float sz = bounds[5] - bounds[2];
  
  float px = (bounds[3] + bounds[0]) * 0.5f;
  float py = (bounds[4] + bounds[1]) * 0.5f;
  float pz = (bounds[5] + bounds[2]) * 0.5f;
  float rad = (float)(Math.sqrt(sx*sx + sy*sy + sz*sz) * 0.5f);
  
  DwBoundingSphere scene_bs = new DwBoundingSphere();
  scene_bs.set(px, py, pz, rad*1.5f);
  
  mat_scene_bounds = scene_bs.getUnitSphereMatrix();

  // callback for rendering the scene
  DwSceneDisplay scene_display = new DwSceneDisplay(){
    @Override
    public void display(PGraphics3D canvas) {
      displayScene(canvas);  
    }
  };
  
  // library context
  context = new DwPixelFlow(this);
  context.print();
  context.printGL();
  
  
  
  smaa = new SMAA(context);
  // postprocessing AA
  pg_aa = (PGraphics3D) createGraphics(width, height, P3D);
  pg_aa.smooth(0);
  pg_aa.textureSampling(5);


  pg_tmp = (PGraphics3D) createGraphics(width, height, P3D);
  pg_tmp.smooth(0);
  pg_tmp.textureSampling(5);
  
  
  
  // init skylight renderer
  skylight = new DwSkyLight(context, scene_display, mat_scene_bounds);
  
  // parameters for sky-light
  skylight.sky.param.iterations     = 100;
  skylight.sky.param.solar_azimuth  = 0;
  skylight.sky.param.solar_zenith   = 0;
  skylight.sky.param.sample_focus   = 1f; // full sphere sampling
  skylight.sky.param.intensity      = 2.0f;
  skylight.sky.param.rgb            = new float[]{1,1,1};
  skylight.sky.param.shadowmap_size = 512; // quality vs. performance
  
  // parameters for sun-light
  skylight.sun.param.iterations     = 100;
  skylight.sun.param.solar_azimuth  = 35;
  skylight.sun.param.solar_zenith   = 45;
  skylight.sun.param.sample_focus   = 0.1f;
  skylight.sun.param.intensity      = 1.0f;
  skylight.sun.param.rgb            = new float[]{1,1,1};
  skylight.sun.param.shadowmap_size = 512;
  
  
  createScene();
  
  frameRate(60);
}
 
Example 10
Source File: Skylight_Movie.java    From PixelFlow with MIT License 4 votes vote down vote up
public void setup(){
  surface.setLocation(viewport_x, viewport_y);
  background(BACKGROUND_COLOR);
  
  // viewport camera
  double   distance = 554;
  double[] look_at  = {-78.294, -57.279, 148.413};
  double[] rotation = { -1.413,  -0.412,   0.083};
  
  Rotation rot = new Rotation(RotationOrder.XYZ, rotation[0], rotation[1], rotation[2]);
  Vector3D center = new Vector3D(look_at[0], look_at[1], look_at[2]);
  CameraState state = new CameraState(rot, center, distance);
  
  cam = new PeasyCam(this, distance);
  cam.setState(state);
  
  // projection
  perspective(60 * PI/180f, width/(float)height, 2, 4000);
  
  
  font = createFont("../data/SourceCodePro-Regular.ttf", 12);
  
 
  // INPUT: capture
  movie = new Movie(this, "examples/data/Pulp_Fiction_Dance_Scene.mp4");
  movie.loop();
  
  
  
  timeline = new TimeLine(movie, width/4, height-30, 2*width/4, 20);


  // pixelflow library context
  context = new DwPixelFlow(this);
  context.print();
  context.printGL();
  
  
  
  // scene bounds for skylight
  float sx = scene_bounds[3] - scene_bounds[0];
  float sy = scene_bounds[4] - scene_bounds[1];
  float sz = scene_bounds[5] - scene_bounds[2];
  float px = (scene_bounds[3] + scene_bounds[0]) * 0.5f;
  float py = (scene_bounds[4] + scene_bounds[1]) * 0.5f;
  float pz = (scene_bounds[5] + scene_bounds[2]) * 0.5f;
  float rad = (float)(Math.sqrt(sx*sx + sy*sy + sz*sz) * 0.5f);
  
  DwBoundingSphere scene_bs = new DwBoundingSphere();
  scene_bs.set(px, py, pz, rad);
  
  mat_scene_bounds = scene_bs.getUnitSphereMatrix();

  // callback for rendering the scene
  DwSceneDisplay scene_display = new DwSceneDisplay(){
    @Override
    public void display(PGraphics3D canvas) {
      displayScene(canvas);  
    }
  };
  
  // init skylight renderer
  skylight = new DwSkyLight(context, scene_display, mat_scene_bounds);
  // parameters for sky-light
  skylight.sky.param.iterations     = 50;
  skylight.sky.param.solar_azimuth  = 0;
  skylight.sky.param.solar_zenith   = 0;
  skylight.sky.param.sample_focus   = 1f; // full sphere sampling
  skylight.sky.param.intensity      = 2.0f;
  skylight.sky.param.rgb            = new float[]{1,1,1};
  skylight.sky.param.shadowmap_size = 512; // quality vs. performance
  // parameters for sun-light
  skylight.sun.param.iterations     = 80;
  skylight.sun.param.solar_azimuth  = 35;
  skylight.sun.param.solar_zenith   = 45;
  skylight.sun.param.sample_focus   = 0.05f;
  skylight.sun.param.intensity      = 1.0f;
  skylight.sun.param.rgb            = new float[]{1,1,1};
  skylight.sun.param.shadowmap_size = 512;
  
  
  // opticalflow
  opticalflow = new DwOpticalFlow(context, 0, 0);
  // parameters
  opticalflow.param.flow_scale         = 100;
  opticalflow.param.temporal_smoothing = 0.8f;
  opticalflow.param.display_mode       = 0;
  opticalflow.param.grayscale          = true;
  opticalflow.param.threshold = 2;
  
  
  // postprocessing AA
  smaa = new SMAA(context);
  // canvas, AA
  pg_aa = (PGraphics3D) createGraphics(width, height, P3D);
  pg_aa.smooth(0);
  pg_aa.textureSampling(5);


  frameRate(60);
}
 
Example 11
Source File: Skylight_BulletPhysics_Breakable3.java    From PixelFlow with MIT License 4 votes vote down vote up
public void setup() {
  
  surface.setLocation(viewport_x, viewport_y);
  
  float SCENE_SCALE = 1000;
  
  // for screenshot
  capture = new DwFrameCapture(this, "examples/");
  
  font12 = createFont("../data/SourceCodePro-Regular.ttf", 12);

  cam = new PeasyCam(this, 0, 0, 0, SCENE_SCALE);
  perspective(60 * DEG_TO_RAD, width/(float)height, 2, SCENE_SCALE * 250);

  group_bulletbodies = createShape(GROUP);
  
  physics = new MyBPhysics(); // no bounding box
  physics.world.setGravity(new Vector3f(0, 0, -100));
 
  pg_render = (PGraphics3D) createGraphics(width, height, P3D);
  pg_render.smooth(0);
  pg_render.beginDraw();
  pg_render.endDraw();
  
  
  // compute scene bounding-sphere
  DwBoundingSphere scene_bs = new DwBoundingSphere();
  scene_bs.set(0, 0, 200, 450);
  PMatrix3D mat_bs = scene_bs.getUnitSphereMatrix();

  // matrix, to place (centering, scaling) the scene in the viewport
  mat_scene_view = new PMatrix3D();
  mat_scene_view.scale(SCENE_SCALE);
  mat_scene_view.apply(mat_bs);

  // matrix, to place the scene in the skylight renderer
  mat_scene_bounds = mat_scene_view.get();
  mat_scene_bounds.invert();
  mat_scene_bounds.preApply(mat_bs);

  // callback for rendering the scene
  DwSceneDisplay scene_display = new DwSceneDisplay(){
    @Override
    public void display(PGraphics3D canvas) {
      displayScene(canvas);  
    }
  };
  
  // library context
  context = new DwPixelFlow(this);
  context.print();
  context.printGL();
  
  // postprocessing filters
  filter = DwFilter.get(context);
  
  // init skylight renderer
  skylight = new DwSkyLight(context, scene_display, mat_scene_bounds);
  
  // parameters for sky-light
  skylight.sky.param.iterations     = 50;
  skylight.sky.param.solar_azimuth  = 0;
  skylight.sky.param.solar_zenith   = 0;
  skylight.sky.param.sample_focus   = 1; // full sphere sampling
  skylight.sky.param.intensity      = 1.0f;
  skylight.sky.param.rgb            = new float[]{1,1,1};
  skylight.sky.param.shadowmap_size = 512; // quality vs. performance
  
  // parameters for sun-light
  skylight.sun.param.iterations     = 50;
  skylight.sun.param.solar_azimuth  = 35;
  skylight.sun.param.solar_zenith   = 65;
  skylight.sun.param.sample_focus   = 0.1f;
  skylight.sun.param.intensity      = 1.0f;
  skylight.sun.param.rgb            = new float[]{1,1,1};
  skylight.sun.param.shadowmap_size = 512;
  
  // postprocessing AA
  smaa = new SMAA(context);
  pg_aa = (PGraphics3D) createGraphics(width, height, P3D);
  pg_aa.smooth(0);
  pg_aa.textureSampling(5);
  
  
  dof = new DepthOfField(context);
  geombuffer = new DwScreenSpaceGeometryBuffer(context, scene_display);
  
  pg_tmp = (PGraphics3D) createGraphics(width, height, P3D);
  pg_tmp.smooth(0);
  DwUtils.changeTextureFormat(pg_tmp, GL2.GL_RGBA16F, GL2.GL_RGBA, GL2.GL_FLOAT);
  
  // fresh start
  reset();
  
  createFractureShape();
  
  frameRate(60);
}
 
Example 12
Source File: Skylight_BulletPhysics_TowerDemolition.java    From PixelFlow with MIT License 4 votes vote down vote up
public void setup() {
    
    surface.setLocation(viewport_x, viewport_y);
    
    float SCENE_SCALE = 1000;
    
    capture = new DwFrameCapture(this, "examples/");
    
    font12 = createFont("../data/SourceCodePro-Regular.ttf", 12);
    font96 = createFont("../data/SourceCodePro-Regular.ttf", 32);
    
    cam = new PeasyCam(this, 0, 0, 0, SCENE_SCALE);
    perspective(60 * DEG_TO_RAD, width/(float)height, 2, SCENE_SCALE * 250);

    group_bulletbodies = createShape(GROUP);
    
//    Vector3f min = new Vector3f(-300, -300,    0);
//    Vector3f max = new Vector3f(+300, +300, +1000);
//    physics = new BPhysics(min, max);
    physics = new BPhysics(); // no bounding box
    physics.world.setGravity(new Vector3f(0, 0, -30));
   
    pg_render = (PGraphics3D) createGraphics(width, height, P3D);
    pg_render.smooth(0);
    pg_render.beginDraw();
    pg_render.endDraw();
    
    
    // compute scene bounding-sphere
    DwBoundingSphere scene_bs = new DwBoundingSphere();
    scene_bs.set(0, 0, 200, 450);
    PMatrix3D mat_bs = scene_bs.getUnitSphereMatrix();

    // matrix, to place (centering, scaling) the scene in the viewport
    mat_scene_view = new PMatrix3D();
    mat_scene_view.scale(SCENE_SCALE);
    mat_scene_view.apply(mat_bs);

    // matrix, to place the scene in the skylight renderer
    mat_scene_bounds = mat_scene_view.get();
    mat_scene_bounds.invert();
    mat_scene_bounds.preApply(mat_bs);

    // callback for rendering the scene
    DwSceneDisplay scene_display = new DwSceneDisplay(){
      @Override
      public void display(PGraphics3D canvas) {
        displayScene(canvas);  
      }
    };
    
    // library context
    context = new DwPixelFlow(this);
    context.print();
    context.printGL();
    
    // postprocessing filters
    filter = DwFilter.get(context);
    
    // init skylight renderer
    skylight = new DwSkyLight(context, scene_display, mat_scene_bounds);
    
    // parameters for sky-light
    skylight.sky.param.iterations     = 50;
    skylight.sky.param.solar_azimuth  = 0;
    skylight.sky.param.solar_zenith   = 0;
    skylight.sky.param.sample_focus   = 1; // full sphere sampling
    skylight.sky.param.intensity      = 1.0f;
    skylight.sky.param.rgb            = new float[]{1,1,1};
    skylight.sky.param.shadowmap_size = 512; // quality vs. performance
    
    // parameters for sun-light
    skylight.sun.param.iterations     = 50;
    skylight.sun.param.solar_azimuth  = 35;
    skylight.sun.param.solar_zenith   = 65;
    skylight.sun.param.sample_focus   = 0.1f;
    skylight.sun.param.intensity      = 1.0f;
    skylight.sun.param.rgb            = new float[]{1,1,1};
    skylight.sun.param.shadowmap_size = 512;
    
    // postprocessing AA
    smaa = new SMAA(context);
    pg_aa = (PGraphics3D) createGraphics(width, height, P3D);
    pg_aa.smooth(0);
    pg_aa.textureSampling(5);
    
    
    dof = new DepthOfField(context);
    geombuffer = new DwScreenSpaceGeometryBuffer(context, scene_display);
    
    pg_tmp = (PGraphics3D) createGraphics(width, height, P3D);
    pg_tmp.smooth(0);
    DwUtils.changeTextureFormat(pg_tmp, GL2.GL_RGBA16F, GL2.GL_RGBA, GL2.GL_FLOAT);
    
    // fresh start
    reset();
    createBuildings(BUILDING);
    frameRate(60);
  }
 
Example 13
Source File: Skylight_BulletPhysics_Basic.java    From PixelFlow with MIT License 4 votes vote down vote up
public void setup() {
    
    surface.setLocation(viewport_x, viewport_y);
    
    float SCENE_SCALE = 1000;
    
    capture = new DwFrameCapture(this, "examples/");
    font12 = createFont("../data/SourceCodePro-Regular.ttf", 12);

    cam = new PeasyCam(this, 0, 0, 0, SCENE_SCALE);
    perspective(60 * DEG_TO_RAD, width/(float)height, 2, SCENE_SCALE * 250);

    group_bulletbodies = createShape(GROUP);
    
//    Vector3f min = new Vector3f(-200, -200,    0);
//    Vector3f max = new Vector3f(+200, +200, +400);
//    physics = new BPhysics(min, max);
    physics = new BPhysics(); // no bounding box
    physics.world.setGravity(new Vector3f(0, 0, -300));
   
    pg_render = (PGraphics3D) createGraphics(width, height, P3D);
    pg_render.smooth(0);
    pg_render.beginDraw();
    pg_render.endDraw();
    
    
    // compute scene bounding-sphere
    DwBoundingSphere scene_bs = new DwBoundingSphere();
    scene_bs.set(0, 0, 200, 450);
    PMatrix3D mat_bs = scene_bs.getUnitSphereMatrix();

    // matrix, to place (centering, scaling) the scene in the viewport
    mat_scene_view = new PMatrix3D();
    mat_scene_view.scale(SCENE_SCALE);
    mat_scene_view.apply(mat_bs);

    // matrix, to place the scene in the skylight renderer
    mat_scene_bounds = mat_scene_view.get();
    mat_scene_bounds.invert();
    mat_scene_bounds.preApply(mat_bs);

    // callback for rendering the scene
    DwSceneDisplay scene_display = new DwSceneDisplay(){
      @Override
      public void display(PGraphics3D canvas) {
        displayScene(canvas);  
      }
    };
    
    // library context
    context = new DwPixelFlow(this);
    context.print();
    context.printGL();
    
    // postprocessing filters
    filter = DwFilter.get(context);
    
    // init skylight renderer
    skylight = new DwSkyLight(context, scene_display, mat_scene_bounds);
    
    // parameters for sky-light
    skylight.sky.param.iterations     = 50;
    skylight.sky.param.solar_azimuth  = 0;
    skylight.sky.param.solar_zenith   = 0;
    skylight.sky.param.sample_focus   = 1; // full sphere sampling
    skylight.sky.param.intensity      = 1.0f;
    skylight.sky.param.rgb            = new float[]{1,1,1};
    skylight.sky.param.shadowmap_size = 512; // quality vs. performance
    
    // parameters for sun-light
    skylight.sun.param.iterations     = 50;
    skylight.sun.param.solar_azimuth  = 35;
    skylight.sun.param.solar_zenith   = 65;
    skylight.sun.param.sample_focus   = 0.1f;
    skylight.sun.param.intensity      = 1.0f;
    skylight.sun.param.rgb            = new float[]{1,1,1};
    skylight.sun.param.shadowmap_size = 512;
    
    // postprocessing AA
    smaa = new SMAA(context);
    pg_aa = (PGraphics3D) createGraphics(width, height, P3D);
    pg_aa.smooth(0);
    pg_aa.textureSampling(5);
    
    
    dof = new DepthOfField(context);
    geombuffer = new DwScreenSpaceGeometryBuffer(context, scene_display);
    
    pg_tmp = (PGraphics3D) createGraphics(width, height, P3D);
    pg_tmp.smooth(0);
    DwUtils.changeTextureFormat(pg_tmp, GL2.GL_RGBA16F, GL2.GL_RGBA, GL2.GL_FLOAT);

    
    // fresh start
    reset();
    
    frameRate(60);
  }