mattdesl / three-glslify

[OUTDATED] no longer needed as of glslify@2 and above
MIT License
8 stars 0 forks source link

glslify 2.0 compatibility #2

Open dy-dx opened 9 years ago

dy-dx commented 9 years ago

Looks like a bunch of changes were made to glslify, including the removal of the sourceOnly option. Are there any plans to update this module for compatibility?

mattdesl commented 9 years ago

Hey Chris,

I haven't gotten around to updating this repo. Eventually it will serve as a bridge, perhaps giving documentation/guidance or any code that might be necessary down the road.

But for now you should be able to use glslify@2.0 out of the box on a ThreeJS project. The only difference is that you will need to define uniforms/attributes manually, since this feature is (currently) part of gl-shader. Eventually this will get pulled out, and then we can revisit what to change in three-glslify.

Some example code:

var THREE = require('three')
var glslify = require('glslify')

var mat = new THREE.ShaderMaterial({
  vertexShader: glslify('./test.vert'),
  fragmentShader: glslify('./test.frag'),
  uniforms: {
    iChannel0: { type: 't', value: new THREE.Texture() },
    iResolution: { type: 'v2', value: new THREE.Vector2() } 
  }
})

A full example: https://github.com/mattdesl/three-glslify-example

I'll update this repo in a bit to note the migration plans.

dy-dx commented 9 years ago

OK, thanks for the example, this is great!