Commit Graph
100 Commits
Author SHA1 Message Date
Mr.doob daf2700ccb * Projector.js: Rather than calculating the screen space centrium of each face per render, seemed smarter to just project the precomputed centrium. Side effect: Polygon shaking is gone \o/ 2010-10-31 02:31:14 +00:00
alteredq b22bd9da2e Added face culling to WebGLRenderer (default is now backface culling on, front face is counter-clockwise).
Thanks to mrdoob for noticing :)
2010-10-31 02:32:36 +01:00
alteredq b150a74755 Synced with mrdoob's branch. 2010-10-31 01:40:25 +02:00
alteredq 1c35d90fd7 Added handling of multiple lights to WebGLRenderer.
Limitations:

 - Chrome can handle up to 5 lights in total (directional + point)
 - Firefox seems to handle up to 29 lights

These number are GPU specific (mine is ATI Mobility Radeon 3650).

This turned out to be quite tricky. The number of varying vectors in shaders is limited. Additionally Chrome and Firefox have different limitations (at least on Windows, probably due to Chrome using ANGLE as rendering backend).

Hence WebGLRenderer has hardcoded limit of maximum 5 lights.

WebGLRenderer constructor now takes (optional) scene argument, so that numbers and types of lights present in the scene can be used to generate minimal possible shader.

If no scene is passed, shader allowing 1 directional + 4 point lights will be generated.
2010-10-31 00:45:04 +02:00
Mr.doob 8ee8c9baf9 * three.js: Fixed terrain example (was still using Scene.add()) 2010-10-30 05:19:44 +01:00
Mr.doob 5b1a64e747 * Matrix4.makeOrtho() fixed 2010-10-30 05:05:02 +01:00
Mr.doob 7eacf2ae0e * Fixed Matrix4.makeOrtho(). bottom - top -> top - bottom
* Added `camera_orthographic` example.
2010-10-30 05:00:42 +01:00
Mr.doob 6f51ce7e8d * Trying to make the interaction stuff work... 2010-10-30 01:39:08 +01:00
alteredq 129a128ec1 Cleaned up WebGLRenderer. Made Blinn-Phong shader work also in Firefox 4. 2010-10-29 13:35:31 +02:00
Mr.doob a0e9935a0f * Minor change to SVGRenderer 2010-10-28 21:48:32 +01:00
Mr.doob 1b1fb7affe * Code clean up (yuicompressor doesn't throw a single warning :D) and some reformating
* Minor fixes (Geometry normal calculation)
* Isolated Matrix3 code into `Matrix3.js`
* README and TODO updated
2010-10-28 21:27:58 +01:00
alteredq 79ab4bf2e6 Merged with mrdoob's branch. Got WebGLRenderer working again :)
Changed OBJ -> Three.js converter to use new materials system (eventual old models need to be reconverted).

Limitations:

  - one use case is now much slower
    - when a mesh has each face with different color (e.g. polyfield in examples/test.html)
    - before this used FaceColorFill material and in WebGLRenderer it was rendered fast with color attribute array
    - now when FaceColorFill material is gone, each face gets own VBO :(

  - material sorting uses Materials "toString" methods for hashing, so it's very important to keep these in a good shape
2010-10-28 19:35:13 +02:00
alteredq b6904f3d72 Added Blinn-Phong material for WebGLRenderer.
In Chrome it looks more or less ok, but it has some problem in Firefox 4 (with some camera angles there are black areas around edges).

Also updated Python builder scripts and examples to include this new material.
2010-10-27 21:16:11 +02:00
Mr.doob 71f96a5f1b Merge remote branch 'alteredq/master' 2010-10-27 17:50:40 +01:00
alteredq 5d7e32a3af Changed camera matrix update in WebGLRenderer to happen just once per frame, no need to do it with every object. 2010-10-27 10:27:59 +02:00
Mr.doob 7464f5ff97 * MeshBitmapUVMappingMaterial -> MeshBitmapMaterial. Second param is mode, which is THREE.MeshBitmapMaterialMode.UVMAPPING by default.
* Removed MeshFaceColorFillMaterial and MeshFaceColorStrokeMaterial
* Added MeshFaceMaterial ( it uses the face.material for that pass )
* CanvasRenderer and SVGRenderer per face material logic changed.
* SVGRenderer supports particles again.
* WebGLRenderer currently broken :/
* Code clean up
2010-10-27 08:49:00 +01:00
alteredq 87e0d754bd Premultiplied alpha in WebGLRenderer for MeshColorFillMaterial and MeshColorStrokeMaterial (to get closer to CanvasRenderer look). 2010-10-26 15:22:31 +02:00
alteredq 277d117b3d Refactored multimaterials to also work with non-textured models composed from multiple material groups.
Old version was doing massive overdraw (whole mesh was drawn for each material).

Even current solution is still quite messy: there is a different behavior for stroke and fill materials (when used as secondary materials).

Stroke materials are applied to the complete mesh (as most common use case seems to be wireframe) while fill materials now apply only to faces within single material group (when "decalIndex" property of secondary fill material is set).
2010-10-26 12:18:30 +02:00
alteredq 9bf3db34d3 Updated WebGLRenderer to use light intensity. 2010-10-25 14:00:49 +02:00
alteredq 4a7082165a Synced with mrdoob's branch. 2010-10-24 19:53:36 +02:00
alteredq ca261ddca5 Added point light / fixed directional light in WebGLRenderer / added light test example.
Changed WebGLRenderer to use 3x3 normal matrix.

Limitations of WebGL lights:

- currently handles only single one of each ambient/directional/point light
- light intensity modifier not yet taken into account
- only diffuse term (this applies also in CanvasRenderer)
2010-10-24 18:52:42 +02:00
alteredq fdb1ee5ff2 Added inversion of 3x3 rotation submatrix.
Added rudimentary 3x3 matrix class (just transpose, as this is needed for normal matrix).
2010-10-24 16:44:19 +02:00
Mr.doob 369a8661dc * WebGLRenderer: update camera and object matrices if autoUpdateMatrix == true 2010-10-23 16:57:10 +02:00
Mr.doob 836f1b878f * CanvasRenderer light per particle and lines 2010-10-23 02:22:52 +02:00
alteredq ecae266e8a Added mesh stroke materials (wireframe) to WebGLRenderer.
Added multipass multimaterials to WebGLRenderer.

Refactored WebGLRenderer shader to become proto-mini-ubershader (untershader :).

Line width is currently not set properly on Chrome in Windows:

http://code.google.com/p/chromium/issues/detail?id=60124
2010-10-22 02:46:56 +02:00
alteredq ce000d482f Merged remote branch 'upstream/master' (original mrdoob's version) 2010-10-21 02:00:52 +02:00
alteredq dde831bf6f Extended CanvasRenderer to be able to handle decals (MeshBitmapUVMappingMaterials as secondary materials).
For decals you need to set "decalIndex" property of the material (corresponding to materials index of the original mesh UV material).

Added multimaterials example.

Fixed forgotten sphere smoothing in OBJ converter example.
2010-10-21 01:38:29 +02:00
Mr.doob db7003e88a * CanvasRenderer and SVGRenderer calculating light only when needed. 2010-10-20 05:14:45 +01:00
alteredq 0f69c71924 Experiment to get backwards compatibility with the original meaning of materials array in Mesh (= extra materials are drawn for whole mesh).
Limitations:
 - works just in CanvasRenderer
 - doesn't work for MeshBitmapUVMappingMaterial as secondary material
2010-10-20 01:23:56 +02:00
unknown 60c2354424 Added OBJ -> Three.js converter.
Added OBJ converter test example.

Modified Three.js to handle converted models:

 - extended WebGL renderer to use texturing
   - broke down model into multiple VBOs according to materials
   - textures are lazy created when images get loaded
     (converter takes care of resizing images to nearest power of 2
      dimensions using 2d canvas)

 - changed material array semantics in Mesh object
    - before: multiple materials were applied to all faces (broken in WebGL, needs multitexturing shader)
    - now: there is only single material per face, but one mesh can have faces with different materials

 - added per vertex normals (to get smooth shading in WebGL)
2010-10-18 11:33:32 +02:00
Mr.doob 647b4a57b8 * Added PointLight
* `CanvasRenderer` and `SVGRenderer` basic lighting support (`*ColorStroke`/`*ColorFill` only)
* `Renderer` > `Projector`. `CanvasRenderer`, `SVGRenderer` and `DOMRenderer` do not extend anymore
* Interactivity base code (hdi folder). To be refactored... ([mindlapse](http://github.com/mindlapse))
* Added `computeCentroids` method to `Geometry`
* Included `Stats.js` directly in the `/examples` folder to avoid the need of internet for playing around
2010-10-06 03:36:21 +01:00
mindlapseandMr.doob a89865bda8 3d onclick, see examples/hci_clickcube.html 2010-09-30 23:11:29 +08:00
Julian WalkerandMr.doob 7c94809ed2 Using projection * view * obj matrix to transform vertices in Renderer instead of transforming twice (once by view * obj and once by projection). 2010-09-29 07:19:32 +08:00
Julian WalkerandMr.doob 930faff1ef Matrix4.lookAt now initializes W row (omitted previously). 2010-09-29 07:19:32 +08:00
Julian WalkerandMr.doob 286402351b Spaces -> tabs in WebGLRenderer.js 2010-09-29 07:19:32 +08:00
Ben Nolan 0c6219b43f * Made vector methods chainable
* Added getCenter to Face4
2010-09-27 13:04:52 +13:00
Mr.doob 5ce7a10bbb - Added TODO
- Minor tweaks
2010-09-21 06:59:06 +01:00
philogbandMr.doob c88fa50a4c Add Matrix4.rotationAxisAngleMatrix 2010-09-18 23:08:08 +08:00
philogbandMr.doob c8aacd8cdc Add Color methods to prototype object. 2010-09-18 23:08:08 +08:00
Mr.doob e68109fdb2 - Clean up 2010-09-17 02:52:29 +01:00
Nicolas Garcia BelmonteandMr.doob 10681d6684 * Bug Fix: Matrix4.makeInvert was calling a non existent scale method. Replaced with multiplyScalar.
* Bug Fix: DirectionalLight wasn't normalizing the direction vector.
 * Added lights to the scene for test.html
2010-09-09 18:47:39 +08:00
Nicolas Garcia BelmonteandMr.doob ad73c981ee * Enable Scene light object management
* Add lighting code in the scene rendering loop
2010-09-09 18:47:39 +08:00
Nicolas Garcia BelmonteandMr.doob d342239c4a Added light objects 2010-09-09 18:47:39 +08:00
Nicolas Garcia BelmonteandMr.doob 24005fc1e1 Added basic lighting shader code 2010-09-09 18:47:38 +08:00
Nicolas Garcia BelmonteandMr.doob a53ad5a79a Added normals to WebGLRenderer 2010-09-09 18:47:38 +08:00
Nicolas Garcia BelmonteandMr.doob 78561a35e6 Fixed the computeNormals method. 2010-09-09 18:47:38 +08:00
Nicolas Garcia BelmonteandMr.doob 20be01f159 Added transpose method to Matrix4 2010-09-09 18:47:37 +08:00
Nicolas Garcia BelmonteandMr.doob 636d108e4b WebGLRenderer fixes:
* Added float precision in shader code to shaders compile now.
 * Changed occurrences of WebGL typed Arrays and UnsignedShort typed arrays to new array types
2010-09-03 20:54:54 +08:00
Nicolas Garcia BelmonteandMr.doob ab1d219eda Added flatten method to Matrix4 to be used in the WebGLRenderer. 2010-09-03 20:54:54 +08:00
Nicolas Garcia BelmonteandMr.doob d8c093c030 No files changed here. 2010-09-03 20:54:34 +08:00