title

deconbatch's Land of 1000 Creative Codings. example codes of Processing / p5.js, how-to articles, generative art images, and much more!

Planet Mustafar


Description of this video.

This creative coding animation was made with Processing programming language and Kdenlive video editor.

I learned how to use blendMode() with this code.
And I'm sorry but I can't resolve this problem with hint(DISABLE_DEPTH_TEST);.


Thanks to nice music:
Mettle by Pipe Choir
2016/01/01
http://freemusicarchive.org/music/Pipe_Choir/Pipe_Choir/Mettle
Mettle by Pipe Choir is licensed under a Attribution License.
Based on a work at www.pipechoir.com
Permissions beyond the scope of this license may be available at www.pipechoir.com or contact artist via email.

クリエイティブ・コモンズ・ライセンス

Example code of Processing.


// Planet Mustafar
// Processing 3.2.1
// 2017.02.19
import processing.opengl.*;

World wd;
Surface sf;


void setup() {
  size(1280, 720, OPENGL);
  colorMode(HSB, 3600, 100, 100, 100);
  blendMode(SCREEN);
  hint(DISABLE_DEPTH_TEST);
  smooth();
  frameRate(30);

  wd = new World();
  sf = new Surface();

}

void draw() {
  wd.redraw();

  // surface
  sf.draw();

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

}

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

  World() {
    r_X = 0;
    r_Y = 0;
    r_Z = 0;
  }

  void redraw() {
    background(40);
    ambientLight(0, 0, 100);
    noStroke();
    translate(width / 2, height / 2, 0);

    // angle 1
    camera(-320, -10, 0,
           0, -180, 0,
           0, 1, 0);

    /*
    // angle 2
    camera(-300, -10, 0,
           0, -160, 0,
           0, 1, 0);

    // angle 3
    camera(-240, -110, 0,
           0, 0, 0,
           0, 1, 0);
    */

  }

}

class Surface {
  float nx_start, ny_start;
  float ni_start, nk_start;
  float radius_val;
  float div_ido, div_kdo;
  float ptsize_ido, ptsize_kdo;

  Surface() {
    nx_start = random(50);
    ny_start = random(50);
    ni_start = random(50);
    nk_start = random(50);
    radius_val = 200;
    div_ido = 0.5;
    ptsize_ido = div_ido * 3.51;
    ptsize_kdo = div_ido * 3.93;
    div_kdo = 1.0; // dummy
  }

  void draw() {

    nx_start += 0.002;
    ny_start += 0.001;
    nk_start += 0.030;
    ni_start += 0.020;
    
    float ny = ny_start;
    float ni = ni_start;

    for (float ido = 40; ido <=140; ido += div_ido) {

      float radian_ido = radians(ido);
      div_kdo = 180 / max(160 / div_ido * sin(radian_ido), 1);
      
      float nx = nx_start;
      float nk = nk_start;

      for (float kdo = 180; kdo <= 230; kdo += div_kdo) {

        // noises
        float bright_pow2 = pow(noise(ny, nx), 2);
        float bright_pow4 = pow(bright_pow2, 2);
        float bright_pow8 = pow(bright_pow4, 2);
        float noise_fluc = noise(ni, nk);
        float noise_basecolor = noise(nx, ny);

        // particle point
        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);

        // base surface
        fill(
             80 * noise_basecolor,
             100,
             //             160 * bright_pow2,
             70 * bright_pow2,
             100
             );

        rect(0, 0, ptsize_ido, ptsize_kdo);
        rect(noise_fluc, noise_fluc, ptsize_ido, ptsize_kdo);
        rect(-noise_fluc, -noise_fluc, ptsize_ido, ptsize_kdo);

        // hot lava
        fill(
             80 * (bright_pow2 + noise_fluc * 1),
             100,
             20 * bright_pow4,
             100
             );

        for (int i = 1; i < int(bright_pow2 * 6); i++) {
          ellipse(0, 0, ptsize_ido * 2, ptsize_kdo * 2);
          ellipse(noise_fluc, noise_fluc, ptsize_ido * 2, ptsize_kdo * 2);
          ellipse(-noise_fluc, -noise_fluc, ptsize_ido * 2, ptsize_kdo * 2);
        }

        // scalding hot lava
        fill(
             400 + 250 * noise_basecolor,
             100, // - (noise_fluc * 10),
             32 * bright_pow8 * (1 + pow(noise_fluc, 2)),
             100
             );
        for (int i = 1; i < int(bright_pow8 * 30); i++) {
          rect(0, 0, ptsize_ido, ptsize_kdo);
          rect(noise_fluc, noise_fluc, ptsize_ido, ptsize_kdo);
          rect(-noise_fluc, -noise_fluc, ptsize_ido, ptsize_kdo);
        }
        
        popMatrix();

        nx += div_kdo / 6;
        nk += 0.05;
      }

      ny += 0.1;
      ni += 0.05;

    }
  }

}

/*
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 
*/





Post a Comment

0 Comments