cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

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

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console