Commit Graph
320 Commits
Author SHA1 Message Date
alteredq 0f5652390f Added dynamic geometry support also for WebGL lines. Changed line strip example to use Hilbert curves.
Also fixed tons of bugs in lines handling.

TODO: make some example for dynamic lines.
2011-01-13 14:12:18 +01:00
alteredq fe6008b616 Added basic support for dynamic geometry in WebGLRenderer (with silly ocean example).
If you want to refresh VBOs (and thus have geometry changes reflected in renderer), you need to set dirty flags on geometry object.

There are separate flags for different buffers (as not always all buffers need to be updated and oh my is updating costly):

    mesh.geometry.__dirtyVertices = true;
    mesh.geometry.__dirtyNormals = true;
    mesh.geometry.__dirtyUvs = true;
    mesh.geometry.__dirtyTangents = true;

    mesh.geometry.__dirtyElements = true;

That was quite tough feature, a lot of refactoring, yet performance is still quite bad :(

The biggest remaining bottleneck seems to be translation between Three.js internal data formats and buffers. I removed as much per-frame arrays creation as I could, but even just iterating through existing data and setting of values is still very costly. Also per-frame normals computation is expensive.
2011-01-12 00:57:04 +01:00
alteredq 5273e091d1 Merge remote branch 'remotes/upstream/master' 2011-01-09 07:38:22 +01:00
alteredq bc9cf2be75 Fixed scene check bug in allocateLights in WebGLRenderer.
Also some refactoring of initWebGLObjects slipped in this commit.
2011-01-09 07:37:20 +01:00
Mr.doob d5a2122598 Merge remote branch 'alteredq/master' 2011-01-09 02:47:06 +00:00
alteredq 2c2b9b81bf Optimized line strip example. 2011-01-08 05:27:35 +01:00
alteredq bbe2a3bf56 Refactored handling of continuous lines: now they are rendered using LINE_STRIP primitive. Added example for this.
Also renamed associated constant to THREE.LineStrip (was THREE.LineContinuous).
2011-01-08 01:15:01 +01:00
alteredq f90bc532c4 Fixed stats widget appearance issues that appeared with recent Chrome updates.
Unfortunately performance issues are still there and now already trickled down also to dev channel :(

I wonder what they did - fps numbers look more or less ok, problem is more with subtle yet very annoying choppiness. Like if somewhere suddenly bandwidth / memory is getting trashed.
2011-01-06 23:25:43 +01:00
alteredq a783870b61 Refactored OBJ converter demo not to have separate materials per each sphere.
Also first time I noticed issues with stats widget in latest Chrome canary 10.0.624.0 / Chromium continuous build 10.0.629.0:

 - it doesn't show in demos with mixed canvas / WebGL content (OBJ converter demo, lights test)
 - simply just adding it can significantly decrease performance (OBJ converter demo is choppy when invisible stats element exists)
 - in some demos it has different transparency (Walt cubemap demo)

Looks like with some Chrome update in last few days we hit some new compositing or 2d canvas issue (both OpenGL and ANGLE versions share the same issues).
2011-01-06 02:23:27 +01:00
Alex Schworer 3b9d05563f close style tag 2011-01-05 16:50:05 -08:00
alteredq 99bbc4880b Fixed bug in shader demo.
Texture wrapping had to be "repeat".
2011-01-04 08:05:28 +01:00
alteredq fb63495caf How to use 2d shaders as procedural animated textures.
Still some bug with textured one :(
2011-01-04 07:42:17 +01:00
alteredq 8ea0f27602 Refactored lines grid in materials_gl example. 2011-01-04 05:14:10 +01:00
alteredq 548c331519 Added crude lines support to WebGLRenderer.
As expected, performance of one-to-one conversion from CanvasRenderer was horrible, so I had to change a bit how lines are handled.

Line object now has "type" property:

    - default type is "THREE.LineContinuous" which should behave as before: geometry represents one continuous line (v0 ... vn)

    - new option is "THREE.LinePieces" which tells renderer that geometry represents collection of individual line segments (v0,v1) ... (vn-1, vn)

(one Line object corresponds to one VBO)

(same limitations as with meshes - once VBO is baked, no changes are possible except object transforms - scale / rotation / position)
2011-01-04 04:38:25 +01:00
alteredq 771674d705 Refactored Loader parameters to allow optional separate paths for texture and binary files.
loader.loadAscii and loader.loadBinary now take just one parameter with following properties:

    - model (required)
    - callback (required)
    - texture_path (optional: if not specified, textures will be assumed to be in the same folder as JS model file)
    - bin_path (optional: if not specified, binary file will be assumed to be in the same folder as JS model file)

Example use:

    loader.loadBinary( { model: "model.js", bin_path: "path/bin", texture_path: "path/img",
                         callback: function( geometry ) { createScene( geometry ) } } );
2011-01-02 19:52:40 +01:00
Mr.doob c186b37be3 Pushed revision to 32.
Updated README.
2010-12-31 17:59:11 +00:00
Mr.doob a964d27b72 Wrong repository =_= 2010-12-31 04:44:06 +00:00
Mr.doob f8e223258b testing... (data seems to be broken?) 2010-12-31 04:43:18 +00:00
alteredq ecad27eb11 Moved MeshPhongMaterial onto common shader builder machinery, ubershader is no more.
Code is still rough around edges (it can be made nicer), though it should already produce one-to-one results with ubershader.

Side-effect is that scene is no longer required as WebGLRenderer constructor parameter. Shader programs are now constructed upon first frame render and only then scene lights are examined.
2010-12-31 00:33:39 +01:00
alteredq 8ed9a9c403 Fixed shader demo to work with Firefox. 2010-12-30 01:11:47 +01:00
Mr.doob 9b755e827f Added "v2" uniform type to WebGLRenderer.
Added a shader demo (as in using only 2 triangles).
2010-12-29 23:09:59 +00:00
Mr.doob 041054283a Messing with a new terrain generator demo. 2010-12-29 03:22:30 +00:00
alteredq 0fe464c97a Refactored uniforms cloning into separate file so that it can be reused also for MeshShaderMaterials.
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.
2010-12-28 17:11:50 +01:00
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 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 ebaa3ae392 I knew it wasn't going to work. 2010-12-27 01:17:52 +00: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 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