Also changed MeshShaderMaterial demos to show how to use cloning. For these particular demos uniforms cloning is not really necessary as they use only one instance of shader material, but for example, if there were two normal mapped models in one scene, each model would need separate material with own uniforms.
For the moment, only one type of fog is baked into shader, depending on scene.fog initial value.
If use case arise for dynamic fog type switching, this could be changed, though than both fogs would need to be computed all the time :S.
For the moment, it works just on Basic / Lambert / Phong materials.
Fog must be added to the scene before initialization of WebGLRenderer and scene must be passed to WebGLRenderer constructor (like for lights).
I don't know yet how to solve properly MeshShaderMaterial & co :(
Instant performance boost in all cube mapping demos ;)
With panoramas there were insane amounts of unnecessary computations done in fragment shader - basically every pixel on the screen was computing the whole ubershader - ouch ouch ouch!
This was the lowest hanging fruit, still some more performance can be gained by removing other stuff from ubershader.
Big thanks to mrdoob for starting to question sanity of ubershader ;)
Also moved loadImageArray utility function from examples into TextureCube.js
To be used like this:
var urls = [ "px.jpg", "nx.jpg", "py.jpg", "ny.jpg", "pz.jpg", "nz.jpg" ];
var images = THREE.loadImageArray( urls );
var textureCube = new THREE.TextureCube( images );
// create scene
var objectMaterial = new THREE.MeshBasicMaterial( { color: 0xffffff, env_map: textureCube } )
createScene( objectMaterial );
// create panorama
var size = 100000;
var panoMaterial = new THREE.MeshCubeMaterial( { env_map: textureCube } );
var mesh = new THREE.Mesh( new Cube( size, size, size, 1, 1, null, true ), panoMaterial );
sceneCube.addObject( mesh );
Warning: this functionality is currently changing a lot, expect things to get broken before stabilization.
TODO:
- maybe image array loader should go into TextureCube.js so that people could just reuse the code
- it may be worth to be able to specify different combination of environment map and underlying material (in single render pass),
currently color/color map/environment map are multiplied, though addition also produces very interesting looking materials
Almost done porting CanvasRenderer to the new material system (plus some performance gains on the way :D)
`Color` now handles hex with no alpha byte (probably there is a nicer way of doing it...)
Models exported by this version should be loaded like this (the same as for slim OBJ converter):
var loader = new THREE.Loader();
loader.loadAscii( "path/to/model/Model.js", function( geometry ) { createScene( geometry ) }, "path/to/model" );
Compared to OBJ converter, currently only single mesh is exported (many models are composed of several meshes).
TODO
- model alignment
- copy used images to folder where exported file goes
- export all selected meshes / all meshes in the scene?
- binary format