Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
279 changes: 229 additions & 50 deletions build/three.cjs

Large diffs are not rendered by default.

213 changes: 196 additions & 17 deletions build/three.module.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/three.module.min.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions examples/jsm/lines/LineMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,6 @@ ShaderLib[ 'line' ] = {

gl_FragColor = vec4( diffuseColor.rgb, alpha );

#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>

Expand Down
2 changes: 0 additions & 2 deletions examples/jsm/materials/LDrawConditionalLineMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ class LDrawConditionalLineMaterial extends ShaderMaterial {
#include <color_fragment>
outgoingLight = diffuseColor.rgb; // simple shader
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}
Expand Down
4 changes: 0 additions & 4 deletions examples/jsm/materials/MeshGouraudMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ const GouraudShader = {
#endif

#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
Expand Down Expand Up @@ -300,11 +299,8 @@ const GouraudShader = {
#include <envmap_fragment>

#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>

}`

Expand Down
Binary file modified examples/screenshots/games_fps.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/misc_controls_arcball.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/misc_controls_map.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/misc_exporter_gltf.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webaudio_orientation.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webaudio_visualizer.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgl_animation_skinning_ik.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgl_animation_walk.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgl_batch_lod_bvh.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgl_buffergeometry.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgl_buffergeometry_attributes_integer.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgl_buffergeometry_attributes_none.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgl_buffergeometry_drawrange.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgl_buffergeometry_glbufferattribute.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgl_buffergeometry_instancing.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgl_buffergeometry_lines.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgl_buffergeometry_lines_indexed.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgl_buffergeometry_points.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgl_buffergeometry_rawshader.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgl_buffergeometry_selective_draw.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgl_buffergeometry_uint.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgl_camera.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/screenshots/webgl_camera_array.jpg
Binary file modified examples/screenshots/webgl_clipculldistance.jpg
Binary file modified examples/screenshots/webgl_clipping_stencil.jpg
Binary file modified examples/screenshots/webgl_custom_attributes.jpg
Binary file modified examples/screenshots/webgl_custom_attributes_lines.jpg
Binary file modified examples/screenshots/webgl_custom_attributes_points.jpg
Binary file modified examples/screenshots/webgl_custom_attributes_points2.jpg
Binary file modified examples/screenshots/webgl_custom_attributes_points3.jpg
Binary file modified examples/screenshots/webgl_effects_stereo.jpg
Binary file modified examples/screenshots/webgl_framebuffer_texture.jpg
Binary file modified examples/screenshots/webgl_geometry_colors.jpg
Binary file modified examples/screenshots/webgl_geometry_convex.jpg
Binary file modified examples/screenshots/webgl_geometry_shapes.jpg
Binary file modified examples/screenshots/webgl_geometry_terrain.jpg
Binary file modified examples/screenshots/webgl_geometry_text.jpg
Binary file modified examples/screenshots/webgl_geometry_text_shapes.jpg
Binary file modified examples/screenshots/webgl_geometry_text_stroke.jpg
Binary file modified examples/screenshots/webgl_gpgpu_birds.jpg
Binary file modified examples/screenshots/webgl_helpers.jpg
Binary file modified examples/screenshots/webgl_instancing_morph.jpg
Binary file modified examples/screenshots/webgl_instancing_performance.jpg
Binary file modified examples/screenshots/webgl_interactive_buffergeometry.jpg
Binary file modified examples/screenshots/webgl_interactive_cubes_ortho.jpg
Binary file modified examples/screenshots/webgl_interactive_points.jpg
Binary file modified examples/screenshots/webgl_interactive_raycasting_points.jpg
Binary file modified examples/screenshots/webgl_lensflares.jpg
Binary file modified examples/screenshots/webgl_lights_hemisphere.jpg
Binary file modified examples/screenshots/webgl_lines_colors.jpg
Binary file modified examples/screenshots/webgl_loader_3dm.jpg
Binary file modified examples/screenshots/webgl_loader_collada_skinning.jpg
Binary file modified examples/screenshots/webgl_loader_gcode.jpg
Binary file modified examples/screenshots/webgl_loader_gltf_instancing.jpg
Binary file modified examples/screenshots/webgl_loader_ifc.jpg
Binary file modified examples/screenshots/webgl_loader_ldraw.jpg
Binary file modified examples/screenshots/webgl_loader_md2_control.jpg
Binary file modified examples/screenshots/webgl_loader_mdd.jpg
Binary file modified examples/screenshots/webgl_loader_nrrd.jpg
Binary file modified examples/screenshots/webgl_loader_pcd.jpg
Binary file modified examples/screenshots/webgl_loader_svg.jpg
Binary file modified examples/screenshots/webgl_loader_texture_dds.jpg
Binary file modified examples/screenshots/webgl_loader_texture_ktx.jpg
Binary file modified examples/screenshots/webgl_loader_ttf.jpg
Binary file modified examples/screenshots/webgl_lod.jpg
Binary file modified examples/screenshots/webgl_materials_blending.jpg
Binary file modified examples/screenshots/webgl_materials_blending_custom.jpg
Binary file modified examples/screenshots/webgl_materials_channels.jpg
Binary file modified examples/screenshots/webgl_materials_modified.jpg
Binary file modified examples/screenshots/webgl_materials_physical_transmission.jpg
Binary file modified examples/screenshots/webgl_materials_texture_filters.jpg
Binary file modified examples/screenshots/webgl_materials_toon.jpg
Binary file modified examples/screenshots/webgl_materials_wireframe.jpg
Binary file modified examples/screenshots/webgl_math_orientation_transform.jpg
Binary file modified examples/screenshots/webgl_mesh_batch.jpg
Binary file modified examples/screenshots/webgl_modifier_tessellation.jpg
Binary file modified examples/screenshots/webgl_multiple_elements_text.jpg
Binary file modified examples/screenshots/webgl_multiple_rendertargets.jpg
Binary file modified examples/screenshots/webgl_multiple_views.jpg
Binary file modified examples/screenshots/webgl_points_billboards.jpg
Binary file modified examples/screenshots/webgl_points_sprites.jpg
Binary file modified examples/screenshots/webgl_postprocessing_godrays.jpg
Binary file modified examples/screenshots/webgl_postprocessing_procedural.jpg
Binary file modified examples/screenshots/webgl_rendertarget_texture2darray.jpg
Binary file modified examples/screenshots/webgl_shader.jpg
Binary file modified examples/screenshots/webgl_shaders_sky.jpg
Binary file modified examples/screenshots/webgl_shadow_contact.jpg
Binary file modified examples/screenshots/webgl_shadowmap_viewer.jpg
Binary file modified examples/screenshots/webgl_sprites.jpg
Binary file modified examples/screenshots/webgl_test_memory.jpg
Binary file modified examples/screenshots/webgl_texture2darray.jpg
Binary file modified examples/screenshots/webgl_texture2darray_compressed.jpg
Binary file modified examples/screenshots/webgl_texture2darray_layerupdate.jpg
Binary file modified examples/screenshots/webgl_texture3d.jpg
Binary file modified examples/screenshots/webgl_ubo.jpg
Binary file modified examples/screenshots/webgl_ubo_arrays.jpg
Binary file modified examples/screenshots/webgl_volume_cloud.jpg
Binary file modified examples/screenshots/webgl_volume_instancing.jpg
Binary file modified examples/screenshots/webgl_volume_perlin.jpg
Binary file modified examples/screenshots/webxr_xr_dragging_custom_depth.jpg
63 changes: 62 additions & 1 deletion src/renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
FrontSide,
DoubleSide,
HalfFloatType,
UnsignedByteType,
NoToneMapping,
LinearMipmapLinearFilter,
SRGBColorSpace,
LinearSRGBColorSpace,
RGBAIntegerFormat,
RGIntegerFormat,
RedIntegerFormat,
UnsignedByteType,
UnsignedIntType,
UnsignedShortType,
UnsignedInt248Type,
Expand All @@ -31,6 +31,7 @@
import { WebGLBufferRenderer } from './webgl/WebGLBufferRenderer.js';
import { WebGLCapabilities } from './webgl/WebGLCapabilities.js';
import { WebGLClipping } from './webgl/WebGLClipping.js';
import { WebGLComposite } from './webgl/WebGLComposite.js';
import { WebGLCubeMaps } from './webgl/WebGLCubeMaps.js';
import { WebGLCubeUVMaps } from './webgl/WebGLCubeUVMaps.js';
import { WebGLExtensions } from './webgl/WebGLExtensions.js';
Expand Down Expand Up @@ -339,6 +340,10 @@

let _renderBackground = false;

// internal composite pass for tonemapping, color space conversion, and dithering
let _composite = null;
let _isRenderingComposite = false;

function getTargetPixelRatio() {

return _currentRenderTarget === null ? _pixelRatio : 1;
Expand Down Expand Up @@ -454,6 +459,10 @@

info.programs = programCache.programs;

// Initialize composite pass for tonemapping, color space conversion, and dithering
_composite = new WebGLComposite( extensions, capabilities );
_composite.setSize( _width * _pixelRatio, _height * _pixelRatio );

/**
* Holds details about the capabilities of the current rendering context.
*
Expand Down Expand Up @@ -655,6 +664,9 @@

}

// Resize composite render target
_composite.setSize( width * _pixelRatio, height * _pixelRatio );

this.setViewport( 0, 0, width, height );

};
Expand Down Expand Up @@ -694,6 +706,9 @@
canvas.width = Math.floor( width * pixelRatio );
canvas.height = Math.floor( height * pixelRatio );

// Resize composite render target
_composite.setSize( width * pixelRatio, height * pixelRatio );

this.setViewport( 0, 0, width, height );

};
Expand Down Expand Up @@ -1007,6 +1022,9 @@
uniformsGroups.dispose();
programCache.dispose();

// Dispose composite pass
_composite.dispose();

xr.dispose();

xr.removeEventListener( 'sessionstart', onXRSessionStart );
Expand Down Expand Up @@ -1563,6 +1581,36 @@

}

// Determine if we should use composite pass for tonemapping, color space conversion, and dithering
const useComposite = scene.isScene === true && _currentRenderTarget === null && _isRenderingComposite === false;
const useXR = xr.enabled === true && xr.isPresenting === true;
const userToneMapping = _this.toneMapping;

let compositeRenderTarget = null;

if ( useComposite ) {

// Choose render target based on XR mode
if ( useXR ) {

compositeRenderTarget = _composite.xrRenderTarget;

// Resize XR render target to match the XR framebuffer
const size = _this.getDrawingBufferSize( _vector2 );

Check warning on line 1599 in src/renderers/WebGLRenderer.js

View workflow job for this annotation

GitHub Actions / Lint, Unit, Unit addons, Circular dependencies & Examples testing

'_vector2' is not defined
_composite.setXRSize( size.x, size.y );

} else {

compositeRenderTarget = _composite.renderTarget;

}

// Render to internal MSAA target, disable tone mapping (will be applied in composite pass)
_this.setRenderTarget( compositeRenderTarget );
_this.toneMapping = NoToneMapping;

}

//
if ( scene.isScene === true ) scene.onBeforeRender( _this, scene, camera, _currentRenderTarget );

Expand Down Expand Up @@ -1684,6 +1732,19 @@

}

// Perform composite pass for tonemapping, color space conversion, and dithering
if ( useComposite ) {

// Restore tone mapping for composite pass
_this.toneMapping = userToneMapping;

// Render composite pass to canvas
_isRenderingComposite = true;
_composite.render( _this, compositeRenderTarget );
_isRenderingComposite = false;

}

//

if ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera );
Expand Down
3 changes: 0 additions & 3 deletions src/renderers/shaders/ShaderLib/background.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,5 @@ void main() {

gl_FragColor = texColor;

#include <tonemapping_fragment>
#include <colorspace_fragment>

}
`;
3 changes: 0 additions & 3 deletions src/renderers/shaders/ShaderLib/backgroundCube.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,5 @@ void main() {

gl_FragColor = texColor;

#include <tonemapping_fragment>
#include <colorspace_fragment>

}
`;
3 changes: 0 additions & 3 deletions src/renderers/shaders/ShaderLib/cube.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,5 @@ void main() {
gl_FragColor = texColor;
gl_FragColor.a *= opacity;

#include <tonemapping_fragment>
#include <colorspace_fragment>

}
`;
3 changes: 0 additions & 3 deletions src/renderers/shaders/ShaderLib/equirect.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,5 @@ void main() {

gl_FragColor = texture2D( tEquirect, sampleUV );

#include <tonemapping_fragment>
#include <colorspace_fragment>

}
`;
2 changes: 0 additions & 2 deletions src/renderers/shaders/ShaderLib/linedashed.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ void main() {
outgoingLight = diffuseColor.rgb; // simple shader

#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>

Expand Down
4 changes: 0 additions & 4 deletions src/renderers/shaders/ShaderLib/meshbasic.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ uniform float opacity;
#endif

#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
Expand Down Expand Up @@ -106,11 +105,8 @@ void main() {
#include <envmap_fragment>

#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>

}
`;
4 changes: 0 additions & 4 deletions src/renderers/shaders/ShaderLib/meshlambert.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ uniform vec3 emissive;
uniform float opacity;

#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
Expand Down Expand Up @@ -114,11 +113,8 @@ void main() {

#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>

}
`;
4 changes: 0 additions & 4 deletions src/renderers/shaders/ShaderLib/meshmatcap.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ uniform sampler2D matcap;
varying vec3 vViewPosition;

#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
Expand Down Expand Up @@ -102,11 +101,8 @@ void main() {
vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;

#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>

}
`;
4 changes: 0 additions & 4 deletions src/renderers/shaders/ShaderLib/meshphong.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ uniform float shininess;
uniform float opacity;

#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
Expand Down Expand Up @@ -116,11 +115,8 @@ void main() {

#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>

}
`;
4 changes: 0 additions & 4 deletions src/renderers/shaders/ShaderLib/meshphysical.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ uniform float opacity;
varying vec3 vViewPosition;

#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
Expand Down Expand Up @@ -214,11 +213,8 @@ void main() {
#endif

#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>

}
`;
4 changes: 0 additions & 4 deletions src/renderers/shaders/ShaderLib/meshtoon.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ uniform vec3 emissive;
uniform float opacity;

#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
Expand Down Expand Up @@ -108,11 +107,8 @@ void main() {
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;

#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>

}
`;
2 changes: 0 additions & 2 deletions src/renderers/shaders/ShaderLib/points.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ void main() {
outgoingLight = diffuseColor.rgb;

#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>

Expand Down
2 changes: 0 additions & 2 deletions src/renderers/shaders/ShaderLib/shadow.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ void main() {

gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );

#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>

}
Expand Down
2 changes: 0 additions & 2 deletions src/renderers/shaders/ShaderLib/sprite.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ void main() {
outgoingLight = diffuseColor.rgb;

#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>

}
Expand Down
Loading
Loading