Commit Graph
631 Commits
Author SHA1 Message Date
alteredq ecdbb2ef91 Fixed broken uniforms cloning. Fixed broken uqbiquity test.
TODO: start using uniforms cloning also for MeshShaderMaterials.
2010-12-28 14:33:52 +01:00
Mr.doob 513563117b Added method setClearColor( color, opacity ) to CanvasRenderer. 2010-12-28 01:18:43 +00:00
Mr.doob 42fa72eca7 Updated README with new WebGL demos. 2010-12-27 20:06:23 +00:00
Mr.doob 674613a7ab Yet some minor tweaks to the normalmap2 demo. 2010-12-27 01:26:08 +00:00
Mr.doob 3488a53798 Recompiled builds.
Re-tweaked normalmap2 demo.
2010-12-27 01:22:48 +00:00
Mr.doob 385ce31b00 Merge remote branch 'alteredq/master' 2010-12-27 01:18:00 +00:00
Mr.doob ebaa3ae392 I knew it wasn't going to work. 2010-12-27 01:17:52 +00:00
Mr.doob 7e1321d084 Trying to avoid merge conflicts... I'm sure it's not going to work... 2010-12-27 01:16:14 +00:00
alteredq b5ac3abbb6 Fixed tangents generation for quads. 2010-12-27 02:11:19 +01:00
Mr.doob 897a2938c5 Merged with alteredq's normal shader improvements.
Tweaked normalmap2 demo parameters.
2010-12-27 01:08:29 +00:00
Mr.doob 4a486f858a Added uNormalScale to normal shader.
Updated normalmap2 demo inverting the X/Y components.
2010-12-26 23:54:35 +00:00
alteredq 46041d3650 Removed vertex lighting from normal mapping shader.
Normal-mapped ninja now looks slightly different from Phong ninja, but Lee looks less artificial ;)
2010-12-27 00:28:01 +01:00
alteredq 1722242ee1 Added cloning of uniforms for MeshShaderMaterial & co.
This is necessary for having multiple materials using the same shaders with different parameters.
2010-12-26 19:03:24 +01:00
alteredq fb7788f0c6 Resurrected exponential fog as FogExp2.
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.
2010-12-26 04:11:35 +01:00
alteredq 6e91de5d8a Added diffuse map to normal map shader. Changed Lee Perry-Smith demo to use normal map shader.
Diffuse map and ambient occlusion maps are now optional in normal map shader.

By default, both are disabled, so they need to be enabled explicitly like this:

    uniforms[ "enableAO" ].value = true;
    uniforms[ "enableDiffuse" ].value = true;
2010-12-26 03:03:28 +01:00
Mr.doob 03c5f0f859 Improving fog effect :) 2010-12-25 23:27:39 +00:00
alteredq 91b9539e02 Synced with mrdoob's branch. 2010-12-25 23:08:57 +01:00
alteredq 255c042b1e Added clear color parameter to WebGLRenderer constructor, also added setClearColor API call.
This allows to work around ANGLE antialiasing issue appearing when compositing WebGL framebuffer with transparent background color with HTML canvas element background (while keeping antialiasing on).

WebGLRenderer constructor now takes JSON object with few optional parameters:

    renderer = new THREE.WebGLRenderer { scene: scene,
                                         antialias: true,
                                         clearColor: 0x000000,
                                         clearAlpha: 0 };

Here is how to change clear color in runtime:

    renderer.setClearColor( 0xff0000, 1 );
2010-12-25 22:32:26 +01:00
Mr.doob b086c2c5af That demo wasn't supposed to go in... 2010-12-25 20:36:00 +00:00
Mr.doob 3993d3d576 Added Lee Perry-Smith Normal-notyet-Map demo. 2010-12-25 20:35:07 +00:00
Mr.doob 93fa1df174 Added Lee Perry-Smith Normal-notyet-Map demo. 2010-12-25 20:32:13 +00:00
Mr.doob e46346c9ba Cleaned up CanvasRenderer/MeshDepthMaterial code.
Moved near/far values from MeshDepthMaterial to Camera (CanvasRenderer/WebGLRenderer/WebGLRenderer2).
2010-12-25 18:14:10 +00:00
Mr.doob 0c3e69ccda WebGLRenderer2: Added env_map (SphericalReflectionMapping).
Eventually I'll have to continue in the experimental branch. Want to give it a go to the ColorPass/TexturePass material API. The color + map + env_map setup feels too limiting...

Now that I have more knowledge of WebGL and shaders, this is how the ColorPass/TexturePass API looks like:

	var material = [

		new THREE.MeshLambertMaterial( [

			new THREE.ColorPass( 0xff0000, 1, THREE.NormalBlending ),
			new THREE.TexturePass( new Texture( <image>, new THREE.UVMapping() ), 0.5, THREE.NormalBlending ),
			new THREE.TexturePass( new Texture( [ <image>, <image>, <image>, <image>, <image>, <image> ], new THREE.CubeRefractionMapping() ), 1, THREE.SubtractiveBlending ),
			new THREE.ColorPass( 0x0000ff, 1, THREE.AdditiveBlending )

		], { blending: THREE.NormalBlending } ),

		new THREE.MeshBasicMaterial( [

			new THREE.ColorPass( 0xff0000, 1 ),

		], { blending: THREE.AdditiveBlending, wireframe: true } ),

		new THREE.MeshPhongMaterial( [

			new THREE.ColorPass( 0xff0000, 1 ),

		], { ambient: 0x000000, specular: 0xbbaa99, shininess: 50, blending: THREE.NormalBlending } );

	];

Makes things a bit longer but I think it's more intuitive this way (and pretty powerful). However, the simplest material would be like this:

	var material = new THREE.MeshBasicMaterial( new THREE.ColorPass( 0xff0000 ) );

Mhh... Now I don't know whether they should called `*Pass`, or `*Layer`...
2010-12-25 16:03:07 +00:00
Mr.doob fbf26158fb Fog( color, density )Fog( color, near, far ) 2010-12-24 22:15:45 +00:00
Mr.doob bffdc03cf1 *.material*.materials 2010-12-24 21:24:58 +00:00
Mr.doob 309fffe98f Added fog parameter (boolean, true by default) to common materials.
Cleaned up shader snippets in WebGLRenderer2.
2010-12-24 16:27:46 +00:00
Mr.doob e89a1de8c2 Merge remote branch 'alteredq/master' 2010-12-24 06:23:27 +00:00
Mr.doob f2b21b5bf1 WebGLRenderer2: Added antialias parameter to constructor. Removed if from shader, using fog * instead. 2010-12-24 06:23:15 +00:00
alteredq 323228ac72 Added antialiasing parameter to WebGLRenderer constructor.
This is a workaround for Chrome ANGLE antialiasing issue manifested in geometry_terrain_fog demo:

http://twitpic.com/3iftyh

Problem happens in Chrome ANGLE when geometry is rendered with the same color as canvas background - then instead of expected nothing to be seen, there is a faint white outline at geometry borders.

This issue is not specific to fog, even just rendering geometry with MeshBasicMaterial having the same color as background produces the same outline.

TODO: create isolated test case and file ANGLE / Chromium bug.
2010-12-23 22:23:56 +01:00
Mr.doob 93d5529872 Added Terrain + Fog demo.
WebGLRenderer2: Fixed a possible issue when modifying scene parameters and having only one program (thx alteredq)
2010-12-22 15:48:18 +00:00
Mr.doob b7c78635cf Added Fog to WebGLRenderer2. 2010-12-21 15:19:43 +00:00
Mr.doob c39eca33ee Projector::projectScene now does a first pass through Projector::projectObject (which does frustum culling and object sorting).
So now CanvasRenderer and SVGRenderer feature frustum culling too.
2010-12-21 14:07:23 +00:00
alteredq 2c1e6a1368 Forgot to remove hardcoded fog color in shader. 2010-12-21 01:38:39 +01:00
alteredq 76a56f2f5c First attempt at fog ;)
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 :(
2010-12-21 01:22:44 +01:00
Mr.doob ffd0b40c4f Merge remote branch 'alteredq/master' 2010-12-20 22:16:12 +00:00
Mr.doob 02f81a26f4 Merging with alteredq's branch. 2010-12-20 22:16:04 +00:00
Mr.doob 17c1349d55 Starting to prepare stuff for adding Fog. Having Fog.js inside /scenes doesn't sound right, but I guess it can be there for now...
The idea would be to do `scene.fog = new THREE.Fog( color, near, far );` This way seems consistent with the rest of the API. By default `scene.fog` is `null`.
2010-12-20 22:15:22 +00:00
alteredq f02a5582f6 Moved normal and depth materials out of ubershader.
Depth material finally works also in ANGLE.
2010-12-20 22:03:03 +01:00
Mr.doob 1d8fae82eb Added MeshDepthMaterial to WebGLRenderer2. 2010-12-20 16:21:19 +00:00
Mr.doob 5e2c480b89 Implemented Frustum checking to Projector::projectObjects (thanks errynp)
Added `boundingBox`, `boundingSphere` and `computeBoundingSphere` to Geometry.
2010-12-20 00:28:31 +00:00
Mr.doob c13377d736 Added crappy grass WebGL example.
Added `sortElements` boolean (true by default) to `CanvasRenderer` and `SVGRenderer`. Also added `sortObjects` boolean but not being used yet.
2010-12-19 20:07:08 +00:00
Mr.doob a648315604 WebGLRenderer2 finally handles big geometries ^^
Projector sort boolean is now required (CanvasRenderer and SVGRenderer updated).
2010-12-18 22:57:58 +00:00
alteredq 5e74c741c1 Retired MeshCubeMaterial: replaced it with MeshShaderMaterial "cube" defined in ShaderUtils.
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 ;)
2010-12-18 02:48:59 +01:00
alteredq 3faf6566e3 Experimenting with Fresnel demo using just MeshShaderMaterials.
Instant performance boost by 50% ;).
2010-12-18 01:56:12 +01:00
alteredq d14ed35ae5 Synced with mrdoob's branch. 2010-12-18 01:39:51 +01:00
alteredq 2163691b59 Fixed subtle yet brutal bug also known as "don't mess with streams" ;)
This one kept me puzzled for days. Premature optimization is indeed evil.

Manifestation was that MeshShaderMaterial mysteriously didn't work depending on what was going on elsewhere in the scene. I think mrdoob's problem with "basic" shader was caused by this bug.
2010-12-18 01:32:54 +01:00
Mr.doob 15262507bd Added a sort parameter to Projector.projectObjects and Projector.projectScene. 2010-12-17 22:27:18 +00:00
alteredq 3b54505959 Synced with mrdoob's branch. 2010-12-17 22:02:46 +01:00
Mr.doob fca3aec67d Fixed Projector::projectObjects. 2010-12-17 19:49:23 +00:00
Mr.doob 3b54cf7918 Projector now checks for object.visible before projecting (alteredq: better late than never :P)
WebGLRenderer2 now uses Projector too (projecting objects + sorting, to slightly avoid transparency sorting glitches).
2010-12-17 11:05:53 +00:00