Commit Graph
921 Commits
Author SHA1 Message Date
Mr.doob 4901440e2e Merging alteredq's branch 2010-11-19 17:40:05 +00:00
alteredq fbd12838b1 Added refractive mapping and mixing combination mode for the environment map and the underlying material.
This commit has handful of things going on:

- had to sacrifice one light to please ANGLE, making it again up to 4 instead of up to 5 total lights :(

- Basic / Lambert / Phong materials now have new parameters:

    "combine": THREE.Mix | THREE.Multiply [default]

      - tells how to combine environment map with the original material:

         - "Multiply" creates chrome-like metallic look (it's what was already there),
           color of the underlying material is multiplied with the environment map,
           this creates different colored metals

         - "Mix" creates shiny plastic look
            color of the underlying material is lerped with the environment map,
            amount of the contribution from the environment map is controlled
            by another new parameter "reflectivity"

    "reflectivity": <float> [from <0.0, 1.0>]

       - controls mixing of underlying material and environment map for "Mix" combine mode
          0: pure underlying material, zero contribution from environment map (Basic/Lambert/Phong)
          1: pure environment map, zero contribution from underlying material (uncolored chrome look)

    "refraction_ratio": <float>

      - controls refractive mapping, ratio of the index of refraction in the medium containing the incident ray
        to that of the medium being entered
      - sensible values seem to be from ~0.6 - 1.0
        (in theory, e.g. air/glass should be 0.75, but this looks weird, values between 0.9 - 1.0 give the most interesting results,
         though maybe there is bug somewhere in my code)

      - for use refraction mapping, just add parameter to TextureCube like this (default is reflection mapping)

          "new THREE.TextureCube( images, THREE.RefractionMap )"
2010-11-19 18:23:31 +01:00
Mr.doob d961ee52c8 Started GeometryUtils class.
MeshUtils.merge( object1, object2 [ geometry | mesh ] ): Merges object2 into object1. Implemented in materials_cubemap_sky.
2010-11-19 09:08:20 +00:00
Mr.doob 2be2673df3 Fixed skybox effect on cubemap demos
CanvasRenderer code clean up
2010-11-19 07:23:43 +00:00
Mr.doob eb9c33b2b4 Cubemap examples: Ambient lights aren't needed anymore... 2010-11-19 03:56:44 +00:00
Mr.doob d21c297993 Cleaned up the escher cubemap code a bit. Also, I think it looks much nicer without illumination... ?
At first I though the cube around the sphere was x-inverted (unless the in tention is to simulate refraction...) I've tried changing that but the effect is still weird. I guess those textures work mainly for the sphere and not for the panorama.

I reused the code and did another example using the skymap. More to come ;)

I can see some lines at the edges of the planes though. I guess that's antialiasing kicking in. Should be fixed with a proper cube mesh I guess.

CanvasRenderer has a property called `autoClear` which is true by default. By making it false you have control of when the renderer cleans the screen (by calling renderer.clear()). I wonder if something like that can be added to the WebGLRenderer? That way we can render the cube outside the spheres from a diferent camera (centered in the middle of the screen) than the spheres floating.

Also, added `shading` parameter to `MeshBasicMaterial` (environment mapping was being rendered faceted when using `MeshBasicMaterial` because `shading` was missing (and thus Faceted)).
2010-11-19 03:49:20 +00:00
Mr.doob 340cbccf6c Merge remote branch 'alteredq/master' 2010-11-19 00:25:10 +00:00
Mr.doob 7277cc4ade Added a link to the blog post that explains the 4 point gradient texture. 2010-11-19 00:24:31 +00:00
alteredq 9543cf2e25 Committed deployment version by mistake. 2010-11-19 01:20:43 +01:00
alteredq 1c6be1c70b Added second cube mapping example.
Also refactored a bit texture cube code, to make it easier to reuse.
2010-11-19 00:12:32 +01:00
alteredq d1931198ea Fixed wrong orientation of bottom and top textures in textured cube. 2010-11-18 18:53:52 +01:00
alteredq 0610f5734f Fixed vertex shader to work in Mac. 2010-11-18 04:55:05 +01:00
alteredq 3ee99dc4c5 Added cube mapping to WebGLRenderer. Also added cube map example. Finally ;)
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
2010-11-18 02:00:11 +01:00
alteredq 59280c0cbb Fixed performance issue in WebGL version of materials test. We are back at 60 fps ;) 2010-11-17 23:42:24 +01:00
alteredq 5535f71130 Added checks for nonexisting face materials if MeshFaceMaterial is used.
Cloned materials.html -> materials_gl.html to have easier test for WebGLRenderer.

TODO:

Investigate why this test is so slow. It shouldn't be, materials_shaders.html is more complex and yet it is much faster (36 vs 60 fps).

MeshFaceMaterial with every face different is pretty bad use case for WebGLRenderer, but this still doesn't fully explain slowdown :(.
2010-11-17 21:19:27 +01:00
alteredq bc11316ae9 Back at master branch.
Hooray. So long materials branch, you served us well ;)
2010-11-17 20:31:39 +01:00
Mr.doob c174157925 Compiled lib with julianwa's Line clipping fix. 2010-11-17 07:43:19 +00:00
Julian Walker 90d5ddf681 Fixed flickering issue when clipping lines with multiple segments. 2010-11-16 23:08:45 -08:00
Mr.doob aafc506270 Projector: Added header credit and reformated. 2010-11-17 06:20:48 +00:00
Mr.doob 2e38de39df Modified lines_test example to test Line clipping. Seems like there are some issues... 2010-11-17 06:11:36 +00:00
Mr.doob 9637daef88 Seems like the new Particle projection code got lost in the merge. Fixed. 2010-11-17 06:02:11 +00:00
Mr.doob c16394d2ec Updated README.
Pushed REVISION to 29.
r29
2010-11-17 05:45:35 +00:00
Mr.doob b025a6176d Projector merged succesfully. 2010-11-17 05:18:57 +00:00
Mr.doob 0d9dc84980 Merge remote branch 'julianwa/master' into materials 2010-11-17 05:07:25 +00:00
Mr.doob b8ae37245f Merging julianwa's branch 2010-11-17 05:07:16 +00:00
Mr.doob 2b92a824c2 Added FaceMaterial example in materials demo. 2010-11-17 04:56:47 +00:00
Mr.doob 9c12250c61 Merge remote branch 'alteredq/materials' into materials 2010-11-17 04:53:43 +00:00
Mr.doob ec0de29153 Merging alteredq branch 2010-11-17 04:53:21 +00:00
Mr.doob 7dd33d6df6 Merging with alteredq branch 2010-11-17 04:51:43 +00:00
Mr.doob 51f91fdd03 Removed alpha component from the Color class
GouraudShading and PhongShading ⟶ SmoothShading
2010-11-17 04:49:30 +00:00
alteredq e98d8da4ad Added poor man's additive blending to WebGLRenderer.
Render first objects / material groups that use normal blending, then render ones which use additive blending.

Proper solution should be: sort triangles by blending, render all the normal ones, sort additive ones by depth and then render them back to front.

http://www.opengl.org/resources/faq/technical/transparency.htm
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=08

While this is acceptable in C++ / OpenGL, with JavaScript / WebGL this would kill the performance (you would need to sort triangles in JS and also create new buffers every frame).

Also tried to come up with subtractive / darken blending, but didn't find any satisfactory formula :(.
2010-11-17 05:42:56 +01:00
Julian Walker 49f878c5a5 * Added near and far plane clipping for THREE.Line rendering in CanvasRenderer.
* Changed THREE.Vertex.positionScreen from a Vector3 to a Vector4 to support clipping.
2010-11-16 20:40:02 -08:00
alteredq 3d3708919b Added support to "shading" materials parameter in WebGLRenderer.
This is actually tricky due to multimaterials and vertex normals.

The practical effects of "shading" parameter in WebGLRenderer are currently following:

- if your model has vertex normals, now you can "dumb down" its shading by specifying THREE.FlatShading for MeshLambertMaterial and MeshPhongMaterial
- if your model has only face normals, it will always have just flat shading, no matter which shading you set, no escape from this
- if your model has multiple materials, smooth shading always "wins", meaning if there is at least one smooth shaded material in multimaterial group, all other materials in this group will be also smooth shaded (this is solvable by having multiple normal buffers, but seems wasteful, at least for the moment, till there are no practical use cases)

Currently implemented shading / material combinations:

  - MeshNormalMaterial: FlatShading [default], GouradShading
  - MeshDepthMaterial:  no shading parameter in material, uses own specific shading
  - MeshBasicMaterial: no shading parameter in material, uses own specific shading
  - MeshLambertMaterial: FlatShading, GouraudShading [default]
  - MeshPhongMaterial: FlatShading, PhongShading [default]
2010-11-16 22:38:06 +01:00
Mr.doob f7d71abc3e Improved materials demo. 2010-11-16 17:22:37 +00:00
Mr.doob 23688daf08 Added WIP materials example (showing all at once). 2010-11-16 14:57:06 +00:00
Mr.doob fbfa375d2c src/io/Loader.js ⟶ src/extras/io/Loader.js
Removed Loader.js from compiled lib
Fixed examples
2010-11-16 14:04:54 +00:00
Mr.doob b449fdf5a8 Added a variation of the interactive example (using Tween.js) 2010-11-16 13:35:47 +00:00
Mr.doob 5e4476bde8 Now using Closure Compiler (~2kbytes) 2010-11-16 12:53:00 +00:00
Mr.doob dc6e335dc9 Color: Nicer way to check whether the hex has the alpha component or not. Removed unused methods.
CanvasRenderer/SVGRenderer: More code clean up and optimisations.
2010-11-16 12:27:25 +00:00
Mr.doob fe82bdbda9 Came up with a crazy approach to get Vertex Colors. Gouraud yet on step closer.
Changed the DepthMaterial to use this approach instead.
2010-11-16 11:02:45 +00:00
Julian Walker 592ea71e48 Merge remote branch 'upstream/master' 2010-11-15 22:18:58 -08:00
Julian Walker 1f0b44a860 Added multiplyScalar and divideScalar to Vector4. 2010-11-15 22:18:40 -08:00
Mr.doob c6d69d8286 Refactored the CanvasRenderer a bit. 2010-11-16 05:54:37 +00:00
alteredq 9081529d84 Made all examples working again. 2010-11-16 03:06:46 +01:00
alteredq 007ee285fa Added MeshNormalMaterial support to WebGLRenderer. 2010-11-16 02:50:46 +01:00
Mr.doob 7b58b806d3 Fixed NormalToComponent function (it was over saturated). 2010-11-15 17:04:10 +00:00
Mr.doob bf3dede88a Implemented MeshNormalMaterial in SVGRenderer
SubstractiveBlending ⟶ SubtractiveBlending
2010-11-15 16:56:14 +00:00
Mr.doob 4d209ac433 Implemented material blendings (THREE.NormalBlending, THREE.AdditiveBlending, THREE.SubtractiveBlending) in CanvasRenderer
Added MeshNormalMaterial (per face)
2010-11-15 16:52:22 +00:00
Mr.doob 696bd4715f Added another depth material test. 2010-11-15 09:12:37 +00:00
Mr.doob 7d8fd5f874 CanvasRenderer now renders MeshDepthMaterial properly (per vertex). Gouraud is one step closer :)
Cleaned up CanvasRenderer and SVGRenderer code a bit.
2010-11-15 08:50:31 +00:00