Water Planet Impression

Beautiful color surface on 3D sphere.
Beautiful color surface on 3D sphere.

Description of this video.

It was made with Processing programming code and Kdenlive video editor.
I learned HSB color mode on this code and made beautiful surface on 3D sphere.

Thanks to nice music:
Sunset by Kai Engel
2015/09/19
http://freemusicarchive.org/music/Kai_Engel/Idea/Kai_Engel_-_Idea_-_09_Sunset
Sunset by Kai Engel is licensed under a Attribution License.
For more permissions:
contact artist
クリエイティブ・コモンズ・ライセンス


An example code of Processing.


// Water Planet Impression
// Processing 3.2.1
// 2017.02.12
import processing.opengl.*;

World wd;
Particle pt;

void setup() {
  size(1280, 720, OPENGL);
  colorMode(HSB, 360, 100, 100, 100);
  smooth();
  sphereDetail(12);
  frameRate(30);

  wd = new World();
  pt = new Particle();
}

void draw() {
  wd.redraw();

  // rotate the world
  wd.rotate();

  // particles
  pt.draw();
  

  saveFrame("frames/####.png");
  if (frameCount >= 3300) {
    exit();
  }


}

class World {
  float r_X;
  float r_Y;
  float r_Z;
  float noise_seed;

  World() {
    r_X = 0;
    r_Y = 0;
    r_Z = 0;
    noise_seed = random(100);
  }

  void redraw() {
    background(40);
    ambientLight(0, 0, 100);
    translate(width / 2, height / 2, 0);
    camera(0, -90, 310,
           0, -125, 0,
           0, 1, 0);
  }
    
  void rotate() {
    float cicle_rotate = (frameCount % 1441) / 4.0;
    float rollnoise = noise(noise_seed);
    r_X = 0.04 * sin(radians(cicle_rotate + (0.5 - rollnoise) * 15));
    r_Y = 0.16 * cos(radians(cicle_rotate)) + (0.5 - rollnoise) * 0.08;
    rotateX(r_X);
    rotateY(r_Y);
    noise_seed += 0.002;
  }

}

class Particle {
  float nx_start, ny_start, nr_start;
  float radius_val;
  float div_nx_start, div_ny_start;
  float div_ido, div_kdo;

  Particle() {
    nx_start = random(10);
    ny_start = random(10);
    nr_start = random(10);
    radius_val = 200;
    div_ido = 1.5;
    div_kdo = 1.0;
    div_nx_start = 0.0008;
    div_ny_start = 0.0002;
  }

  void draw() {

    
    fill(260, 100, 80, 100);
    sphere(radius_val);
    
    nx_start += div_nx_start;
    ny_start += div_ny_start;
    nr_start += 0.001;

    div_nx_start += 0.000001;
    div_ny_start += 0.000003;
        
    float ny = ny_start;
    float nr = nr_start;

    for (float ido = 0; ido <=90; ido += div_ido) {
      float radian_ido = radians(ido);
      div_kdo = 180 / max(160 / div_ido * sin(radian_ido), 1);
      
      float nx = nx_start;
      for (float kdo = 180; kdo <= 360; kdo += div_kdo) {

        float radian_kdo = radians(kdo);

      
        float thisx = radius_val * cos(radian_kdo) * sin(radian_ido);
        float thisy = radius_val * sin(radian_kdo) * sin(radian_ido);
        float thisz = radius_val * cos(radian_ido);


        pushMatrix();

        translate(thisx, thisy, thisz);
        rotateZ(radian_kdo);
        rotateY(radian_ido);

        noStroke();
        fill(
             160 + 100 * noise(nx, ny),
             100 - 30 * customNoise(nr),
             100 - 50 * noise(ny, ny, nx),
             100 - 30 * noise(ny, nx)
             );
        rect(0, 0, div_ido * 3.8, div_ido * 4.6);

        popMatrix();

        nx += 0.04;
        nr += 0.08;
      }
      ny += 0.04;
    }
  }

  float customNoise(float value) {
    return abs(pow(sin(value), 3) * cos(value));
  }

}


/*
Copyright (C) 2017- deconbatch

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see 
*/




Next Post Previous Post
No Comment
Add Comment
comment url