Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

GLSL post-processing module for Voxel.js

branch: master

0.0.4

latest commit 357cc41a22
Hugh Kennedy authored March 02, 2013
Octocat-spinner-32 textures first commit January 28, 2013
Octocat-spinner-32 .gitignore first commit January 28, 2013
Octocat-spinner-32 .npmignore first commit January 28, 2013
Octocat-spinner-32 README.md Include addPass method for more flexibility February 03, 2013
Octocat-spinner-32 demo.js Fix texturePath January 28, 2013
Octocat-spinner-32 index.html first commit January 28, 2013
Octocat-spinner-32 index.js Fix for rename of `game.renderer` to `game.view.renderer` March 02, 2013
Octocat-spinner-32 logo-white.png first commit January 28, 2013
Octocat-spinner-32 maxogden.png first commit January 28, 2013
Octocat-spinner-32 package.json 0.0.4 March 02, 2013
Octocat-spinner-32 substack.png first commit January 28, 2013
README.md

voxel-pp

GLSL post-processing module for Voxel.js! This is a wrapper for @alteredq's THREE.EffectComposer, which allows you to stack fragment shaders for nice effects such as Bloom, Blur, Mosaic Filters and so on.

The demo is somewhat less graceful, but you get the idea.

Installation

npm install voxel-pp

Usage

postprocessor(game)

Enable post processing.

postprocessor(game).use(fragmentShader)

Add a shader pass using the fragmentShader string. Includes sampler2D tDiffuse (the screen texture) and vec2 vUv (the current pixel) by default.

postprocessor(game).use(options)

Same as above, but takes an object instead with the following properties, all optional:

  • fragmentShader
  • vertexShader
  • uniforms

postprocessor(game).addPass(pass)

Equivalent to EffectComposer.addPass - the following pass types are exposed with each instance of voxel-pp:

  • postprocessor(game).ShaderPass
  • postprocessor(game).RenderPass
  • postprocessor(game).MaskPass
  • postprocessor(game).ClearMaskPass

This method also returns the pass instead of the voxel-pp instance, so you can play around with it directly.

postprocessor(game).addPass(type, params, ...)

To keep things clean, you can pass the string name of the pass (e.g. ShaderPass or MaskPass) as the first argument, and the parameters as the rest:

postprocessor(game).addPass('MaskPass', scene, camera)

Example

See demo.js for the code used in the demo.

var game = require('voxel-engine')()
  , voxelpp = require('voxel-pp')

var postprocessor = voxelpp(game)

postprocessor
  .use(require('./some/fragment/shader.fs'))
  .use({
    fragmentShader: require('./another/fragment/shader.fs'),
    uniforms: {
      amount: { type: 'f', value: 1 }
    }
  })
Something went wrong with that request. Please try again.