cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <canvas id="omega" width="800px" height="600px"/>
            
          
!
            
              body {
  margin: 0;
  overflow: hidden;
}
            
          
!
            
              /**
 * OMEGA 3D Framework - http://lab.rackdoll.nl/js/omega/
 * v.0.0.1.8 Alpha - Sexy HDR Bloom Demo.
 * author: Rackdoll.
 */

var images, sb_images, scene, cam, renderer;
var light_01, light_02, light_03;
var chain, chain_HDR;
var objects = [];
var spread = 45;
var halfSpread = spread * 0.5;
var renderHDR = false;

function timeout() {
  setTimeout(function() {
    init();
  }, 500);
}

function init() {

  var gui = new dat.GUI();
  gui.width = 300;

  gui.add(this, "renderHDR").name("HDR_Bloom").onChange(function(newValue) {
    if (newValue) {
      light_01.SetDiffuse(2.0, 0.0, 0.0);
      light_02.SetDiffuse(0.0, 2.0, 0.0);
      light_03.SetDiffuse(0.0, 0.0, 2.0);
      renderer.SetRenderChain(chain_HDR);
    } else {
      light_01.SetDiffuse(1.0, 0.0, 0.0);
      light_02.SetDiffuse(0.0, 1.0, 0.0);
      light_03.SetDiffuse(0.0, 0.0, 1.0);
      renderer.SetRenderChain(chain);
    }
  });

  //adjust on window
  Omega3D.Recalibrate();

  //scene
  scene = new Omega3D.Scene();
  scene.setColor(0, 0, 0);

  //camera.
  cam = new Omega3D.cameras.Camera();
  cam.ratio = OMEGA.Omega3D.GL.viewPortWidth / OMEGA.Omega3D.GL.viewPortHeight;
  cam.LookAt(0, 0, 0, [0, 0, -6]);

  //light.
  light_01 = new Omega3D.Light(Omega3D.POINT_LIGHT);
  light_01.SetPosition(0.1, 0.1, 0.1);
  light_01.SetAmbient(0.0, 0.0, 0.0);
  light_01.SetDiffuse(1.0, 0.0, 0.0);
  light_01.SetSpecular(1.0, 1.0, 1.0);
  light_01.SetRadius(150.0);
  scene.addLight(light_01);

  light_02 = new Omega3D.Light(Omega3D.POINT_LIGHT);
  light_02.SetPosition(0.1, 0.1, 0.1);
  light_02.SetAmbient(0.0, 0.0, 0.0);
  light_02.SetDiffuse(0.0, 1.0, 0.0);
  light_02.SetSpecular(1.0, 1.0, 1.0);
  light_02.SetRadius(150.0);
  scene.addLight(light_02);

  light_03 = new Omega3D.Light(Omega3D.POINT_LIGHT);
  light_03.SetPosition(0.1, 0.1, 0.1);
  light_03.SetAmbient(0.0, 0.0, 0.0);
  light_03.SetDiffuse(0.0, 0.0, 1.0);
  light_03.SetSpecular(1.0, 1.0, 1.0);
  light_03.SetRadius(150.0);
  scene.addLight(light_03);

  //material.
  var material = new Omega3D.BasicMaterial([], scene, [1.0, 1.0, 1.0]);

  //object.
  var torus_geom = new Omega3D.Geometry.TorusGeometry(1.0, 0.5, 25, 25);
  var sphere_geom = new Omega3D.Geometry.SphereGeometry(1.0, 25, 25);

  for (var i = 0; i < 250; ++i) {
    objects.push(new Omega3D.Object3D(new Omega3D.Mesh(i % 2 == 0 ? torus_geom : sphere_geom),
      material));
    objects[i].SetPosition(Math.random() * spread - halfSpread,
      Math.random() * spread - halfSpread,
      Math.random() * spread - halfSpread);
    objects[i].SetRotation(Math.random() * 2.0 - 1.0,
      Math.random() * 2.0 - 1.0,
      Math.random() * 2.0 - 1.0);
    scene.addChild(objects[i]);
  }

  //create render chain.
  renderer = new Omega3D.WebGLRenderer;

  //Normal Rendering.
  chain = new Omega3D.RenderChain();
  chain.AddRenderPass(new RenderPass(renderer, scene, cam));
  renderer.SetRenderChain(chain);

  //HDR Rendering.
  var fbo_scene = new Omega3D.Scene();

  var size = 1024;
  var fbo_normal = new Omega3D.FrameBufferTexture(size, size, 0);
  var fbo_tonemap = new Omega3D.FrameBufferTexture(size, size, 0);
  var fbo_bloom_map = new Omega3D.FrameBufferTexture(size, size, 0);
  var fbo_bloom_downsample01   = new Omega3D.FrameBufferTexture(size/2, size/2, 0);
  
  var fbo_bloom01 = new Omega3D.FrameBufferTexture(size / 4, size / 4, 0);
  var fbo_bloom02 = new Omega3D.FrameBufferTexture(size / 4, size / 4, 0); 

  var fbo_mat = new Omega3D.Material(new Omega3D.Shaders.TextureBlend(), [fbo_tonemap, fbo_bloom01]);
  var geometry = new Omega3D.Geometry.SquareGeometry(1, 1);
  var mesh = new Omega3D.Mesh(geometry);
  var quad = new Omega3D.Object3D(mesh, fbo_mat);
  fbo_scene.addChild(quad);

  chain_HDR = new Omega3D.RenderChain();
  chain_HDR.AddRenderPass(new RenderToTexturePass(renderer, scene, cam, fbo_normal));
  chain_HDR.AddRenderPass(new FilterPass(renderer, new Omega3D.Shaders.ExposureToneMapping(), fbo_normal, fbo_tonemap));
  chain_HDR.AddRenderPass(new FilterPass(renderer, new Omega3D.Shaders.BloomMap(0.75), fbo_normal, fbo_bloom_map));
  chain_HDR.AddRenderPass(new FilterPass(renderer, new Omega3D.Shaders.DownSample(), fbo_bloom_map, fbo_bloom_downsample01));
  chain_HDR.AddRenderPass( new FilterPass( renderer,new Omega3D.Shaders.DownSample(),fbo_bloom_downsample01, fbo_bloom01));
  chain_HDR.AddRenderPass(new FilterPass(renderer, new Omega3D.Shaders.DirectionalBlur("1", size / 4), fbo_bloom01, fbo_bloom02));
  chain_HDR.AddRenderPass(new FilterPass(renderer, new Omega3D.Shaders.DirectionalBlur("0", size / 4), fbo_bloom02, fbo_bloom01));
  chain_HDR.AddRenderPass(new RenderPass(renderer, fbo_scene, cam));

  //start render.
  render();
}

//RENDER.
var time = 0;
var radius = 5.0;

function render() {
  requestAnimationFrame(render);

  for (var i = 1; i < scene.children.length; ++i)
    scene.children[i].Rotate(0.02, 0.01, 0.01);

  time = scene.getTime() / 5;

  light_01.SetPosition(10 * Math.sin(10 * time + (time * (Math.PI))),
    10 * Math.sin(8 * time) * Math.cos(time),
    20 * Math.cos((10 / 8) * (time * (Math.PI))));

  light_02.SetPosition(10 * Math.sin(6 * (time - Math.PI / 2) + ((time - Math.PI / 2) * (Math.PI))),
    10 * Math.sin(8 * (time - Math.PI / 2)) * Math.cos(time),
    20 * Math.cos((6 / 8) * ((time - Math.PI / 2) * (Math.PI))));

  cam.LookAt(Math.sin(time) * Math.cos(time * 1.5) * 10,
    Math.sin(time) * 10,
    Math.cos(time) * Math.cos(time * 0.5) * 10, [halfSpread * Math.sin(time) * Math.cos(time * 1.5),
      halfSpread * Math.sin(time),
      halfSpread * Math.cos(time) * Math.cos(time * 0.5)
    ]);

  //render step.
  renderer.render();
}

document.getElementsByTagName("body")[0].onload = timeout();
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console