Commit Graph
438 Commits
Author SHA1 Message Date
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 02f81a26f4 Merging with alteredq's branch. 2010-12-20 22:16:04 +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
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
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
Mr.doob 5f0b6876e6 Optimised Minecraft AO demo (removing more unseen sides).
Made 0xffffff the default color on all materials (0xeeeeee was making the AO a bit darker).
2010-12-14 10:39:48 +00:00
alteredq 8e53294e62 Synced with mrdoob's branch. 2010-12-14 02:35:23 +01:00
alteredq 044a98c8ce Added WASD + strafing to minecraft AO demo.
Thanks to Paul Irish for gist:

https://gist.github.com/a9ce964c4dcd08aee976/63562a89d78d44b3a96e37dd361e1a65f51cb559
2010-12-14 00:51:01 +01:00
alteredq 45f47b89b7 Added minecraft fake ambient occlusion demo.
For some reason it doesn't work with the current Chrome canary (10.0.607.0) when using ANGLE :(.

Also OBJ converter demo is having problems with generated tiled texture in latest canary, so it looks like some bug was introduced in ANGLE's handling of UVs (baked AO relies on "zoomed" UVs).

Need to investigate more, maybe file a bug report.
2010-12-14 00:17:53 +01:00
Mr.doob 4225330065 WebGLRenderer2:
Added textures
2010-12-13 10:36:38 +00:00
Mr.doob 3af0b0fd16 WebGLRenderer2:
Added MeshNormalMaterial.
Moved mColor * mOpacity computation to the shader.
2010-12-13 09:08:04 +00:00
Mr.doob b84bca3bb0 WebGLRenderer optimisation: flattening camera matrices just once per render, it was doing it once per object before.
WebGLRenderer2: Trying to re-create WebGLRenderer from scratch... Creating a program per material instead of just one for everything. Seems to be 3x faster by now...
2010-12-12 21:22:25 +00:00
Mr.doob bf495aa486 Yet another geometry optimisation to the minecraft demo.
Added `lights_pointlight_smooth` example. To be used for tracking browser improvements affecting that technique.
2010-12-12 09:35:00 +00:00
alteredq 9e5017a2ed Another minecraft demo optimization: creating only one material per unique texture.
This also reduces number of VBOs. There aren't many of them anyways, but it's always nice to have less ;)
2010-12-10 19:08:27 +01:00
alteredq e3c9b9d045 Optimized minecraft demo: removed rest of unseen faces.
It did seem to help quite a bit ;)
2010-12-10 15:59:25 +01:00
Mr.doob 2a8abb5531 Implemented gero3 Rectangle optimisations. 2010-12-10 11:04:51 +00:00
Mr.doob cee1d4832f Merge remote branch 'alteredq/master' 2010-12-09 13:33:36 +00:00
Mr.doob 7aeaa8c663 Added translateX( amount ) and translateZ( amount ) to Camera. 2010-12-09 12:37:57 +00:00
alteredq ac5276b41f Added normal + ambient occlusion + displacement mapping demo.
A lot of things going on in this commit:

- added tangents computation for geometries
    - mesh must have UV coordinates
    - to be called explicitly once geometry is loaded like this: geometry.computeTangents()
    - tangents are stored in Vertex objects
    - quads are not solved properly (though workaround hack seems to work at least somehow, as far as each vertex appears at least somewhere)

- extended VBOs in WebGLRenderer to include tangent streams (when available)

- added "normal" shader to ShaderUtils (to be used with MeshShaderMaterial)
   - Blinn-Phong with one directional and one point light (7 varyings gone, just one spare)
   - normal maps are in tangent space
   - displacement maps use simple luminance value (could be changed if better precision is needed)

- displacement mapping uses vertex texture fetch
    - this requires GPU with Shader Model 3.0
    - not currently supported in ANGLE
    - for this, added "supportsVertexTextures" method to WebGLRenderer API, so that application can handle this
2010-12-09 12:27:49 +01:00
Mr.doob 01ffc10ea3 webgl terrain demo look slightly improved. 2010-12-09 09:17:54 +00:00
Mr.doob 10e21dde88 Geometry::computeNormalsGeometry::computeFaceNormals 2010-12-08 15:59:10 +00:00
alteredq 1053ab2444 Made WebGL terrain demo work in Firefox 4.
Firefox doesn't like Typed Array constructors without explicit sizes.

Also in Firefox there were some weird artefacts in Perlin noise when using Int8Array (patterns were repeated across diagonal lines).
2010-12-07 19:50:40 +01:00
Mr.doob 4290307b48 Optimised WebGL terrain demo. 2010-12-07 13:33:20 +00:00
Mr.doob 3f7ed6f939 Right ⇆ Left 2010-12-07 12:43:11 +00:00
Mr.doob 2dcbde4d69 Added webgl terrain example. 2010-12-07 09:13:32 +00:00
alteredq c8ee1c5dc2 Merge remote branch 'remotes/upstream/master' 2010-12-06 16:00:53 +01:00
alteredq 52ef987a79 Small optimization to Minecraft demo: not drawing bottom faces.
For this extended Cube primitive with "sides" parameter.

You can use it to switch off cube faces like this:

    var cube = new Cube( 100, 100, 100, 1, 1, materials, false, { ny: false } );

Default is all six faces on => { px: true, nx: true, py: true, ny: true, pz: true, nz: true }
2010-12-06 15:58:55 +01:00
Mr.doob e829542744 Restored the correct illumination for the Minecraft demo. 2010-12-06 14:30:59 +00:00
alteredq a0e29d1c67 Oops, texture pack attribution got lost in merge. 2010-12-06 14:58:31 +01:00
alteredq 89cd9198dd Fixed a subtle bug in texture parameters (with missing mapping, all other parameters were shifted).
Thanks again Firefox for verbose WebGL warnings.
2010-12-06 14:51:15 +01:00
alteredq 4dfadc00d5 Merge remote branch 'remotes/upstream/master' 2010-12-06 14:21:31 +01:00