Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced TwoPassDoubleSide with material.forceSinglePass #25239

Merged
merged 10 commits into from
Jan 26, 2023
4 changes: 0 additions & 4 deletions docs/api/en/constants/Materials.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,11 @@ <h2>Side</h2>
THREE.FrontSide
THREE.BackSide
THREE.DoubleSide
THREE.TwoPassDoubleSide
</code>
<p>
Defines which side of faces will be rendered - front, back or both.
Default is [page:Constant FrontSide].
</p>
<p>
[page:Materials TwoPassDoubleSide] will renderer double-sided transparent materials in two passes in back-front order to mitigate transparency artifacts.
</p>

<h2>Blending Mode</h2>
<code>
Expand Down
2 changes: 1 addition & 1 deletion docs/api/en/materials/Material.html
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ <h3>[property:Integer side]</h3>
<p>
Defines which side of faces will be rendered - front, back or both.
Default is [page:Materials THREE.FrontSide].
Other options are [page:Materials THREE.BackSide], [page:Materials THREE.DoubleSide] or [page:Materials THREE.TwoPassDoubleSide].
Other options are [page:Materials THREE.BackSide] or [page:Materials THREE.DoubleSide].
</p>

<h3>[property:Boolean toneMapped]</h3>
Expand Down
4 changes: 0 additions & 4 deletions docs/api/fr/constants/Materials.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,11 @@ <h2>Côté</h2>
THREE.FrontSide
THREE.BackSide
THREE.DoubleSide
THREE.TwoPassDoubleSide
</code>
<p>
Définit quel côté des faces sera rendu - avant, arrière ou les deux.
La valeur par défaut est [page:Constant FrontSide].
</p>
<p>
[page:Materials TwoPassDoubleSide] will renderer double-sided transparent materials in two passes in back-front order to mitigate transparency artifacts.
</p>

<h2>Mode de fusion</h2>
<code>
Expand Down
4 changes: 0 additions & 4 deletions docs/api/it/constants/Materials.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,11 @@ <h2>Lato (Side)</h2>
THREE.FrontSide
THREE.BackSide
THREE.DoubleSide
THREE.TwoPassDoubleSide
</code>
<p>
Definisce quale lato delle facce sarà visualizzato - frontale, retro o entrambi.
Il valore predefinito è [page:Constant FrontSide].
</p>
<p>
[page:Materials TwoPassDoubleSide] will renderer double-sided transparent materials in two passes in back-front order to mitigate transparency artifacts.
</p>

<h2>Modalità Blending</h2>
<code>
Expand Down
2 changes: 1 addition & 1 deletion docs/api/it/materials/Material.html
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ <h3>[property:Integer side]</h3>
<p>
Definisce quale lato delle facce sarà visualizzato - frontale, posteriore o entrambi.
Il valore predefinito è [page:Materials THREE.FrontSide].
Altre opzioni sono [page:Materials THREE.BackSide], [page:Materials THREE.DoubleSide] e [page:Materials THREE.TwoPassDoubleSide].
Altre opzioni sono [page:Materials THREE.BackSide] e [page:Materials THREE.DoubleSide].
</p>

<h3>[property:Boolean toneMapped]</h3>
Expand Down
1 change: 0 additions & 1 deletion docs/api/ko/constants/Materials.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ <h2>측면</h2>
THREE.FrontSide
THREE.BackSide
THREE.DoubleSide
THREE.TwoPassDoubleSide
</code>
<p>
어느 측면(앞,뒤 혹은 둘 다)이 렌더링 될 지 정의합니다.
Expand Down
4 changes: 0 additions & 4 deletions docs/api/pt-br/constants/Materials.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@ <h2>Lado (Side)</h2>
THREE.FrontSide
THREE.BackSide
THREE.DoubleSide
THREE.TwoPassDoubleSide
</code>
<p>
Define qual lado das faces será renderizado - frente, verso ou ambos.
O padrão é [page:Constant FrontSide].
</p>
<p>
[page:Materials TwoPassDoubleSide] will renderer double-sided transparent materials in two passes in back-front order to mitigate transparency artifacts.
</p>

<h2>Modo de Mesclagem (Blending Mode)</h2>
<code>
Expand Down
4 changes: 0 additions & 4 deletions docs/api/zh/constants/Materials.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,11 @@ <h2>面</h2>
THREE.FrontSide
THREE.BackSide
THREE.DoubleSide
THREE.TwoPassDoubleSide
</code>
<p>
定义了哪一边的面将会被渲染 —— 正面,或是反面,还是两个面都渲染。
默认值是[page:Constant FrontSide](只渲染正面)。
</p>
<p>
[page:Materials TwoPassDoubleSide] will renderer double-sided transparent materials in two passes in back-front order to mitigate transparency artifacts.
</p>

<h2>混合模式</h2>
<code>
Expand Down
2 changes: 1 addition & 1 deletion docs/api/zh/materials/Material.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ <h3>[property:Integer shadowSide]</h3>

<h3>[property:Integer side]</h3>
<p> 定义将要渲染哪一面 - 正面,背面或两者。
默认为[page:Materials THREE.FrontSide]。其他选项有[page:Materials THREE.BackSide], [page:Materials THREE.DoubleSide] 和 [page:Materials THREE.TwoPassDoubleSide]。
默认为[page:Materials THREE.FrontSide]。其他选项有[page:Materials THREE.BackSide] 和 [page:Materials THREE.DoubleSide]。
</p>

<h3>[property:Boolean toneMapped]</h3>
Expand Down
8 changes: 6 additions & 2 deletions editor/js/Sidebar.Material.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,7 @@ function SidebarMaterial( editor ) {
const materialSideOptions = {
0: 'Front',
1: 'Back',
2: 'Double',
3: 'TwoPassDouble'
2: 'Double'
};

const materialSide = new SidebarMaterialConstantProperty( editor, 'side', strings.getKey( 'sidebar/material/side' ), materialSideOptions );
Expand Down Expand Up @@ -352,6 +351,11 @@ function SidebarMaterial( editor ) {
const materialTransparent = new SidebarMaterialBooleanProperty( editor, 'transparent', strings.getKey( 'sidebar/material/transparent' ) );
container.add( materialTransparent );

// forceSinglePass

const materialForceSinglePass = new SidebarMaterialBooleanProperty( editor, 'forceSinglePass', strings.getKey( 'sidebar/material/forcesinglepass' ) );
container.add( materialForceSinglePass );

// alpha test

const materialAlphaTest = new SidebarMaterialNumberProperty( editor, 'alphaTest', strings.getKey( 'sidebar/material/alphatest' ), [ 0, 1 ] );
Expand Down
3 changes: 3 additions & 0 deletions editor/js/Strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ function Strings( config ) {
'sidebar/material/blending': 'Blending',
'sidebar/material/opacity': 'Opacity',
'sidebar/material/transparent': 'Transparent',
'sidebar/material/forcesinglepass': 'Force Single Pass',
'sidebar/material/alphatest': 'Alpha Test',
'sidebar/material/depthtest': 'Depth Test',
'sidebar/material/depthwrite': 'Depth Write',
Expand Down Expand Up @@ -649,6 +650,7 @@ function Strings( config ) {
'sidebar/material/blending': 'Mélange',
'sidebar/material/opacity': 'Opacité',
'sidebar/material/transparent': 'Transparence',
'sidebar/material/forcesinglepass': 'Force Single Pass',
'sidebar/material/alphatest': 'Test de transparence',
'sidebar/material/depthtest': 'Depth Test',
'sidebar/material/depthwrite': 'Depth Write',
Expand Down Expand Up @@ -1000,6 +1002,7 @@ function Strings( config ) {
'sidebar/material/blending': '混合',
'sidebar/material/opacity': '透明度',
'sidebar/material/transparent': '透明性',
'sidebar/material/forcesinglepass': 'Force Single Pass',
'sidebar/material/alphatest': 'α测试',
'sidebar/material/depthtest': '深度测试',
'sidebar/material/depthwrite': '深度缓冲',
Expand Down
Binary file modified examples/screenshots/webgl_postprocessing_dof2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/webgl_buffergeometry_instancing.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
vertexShader: document.getElementById( 'vertexShader' ).textContent,
fragmentShader: document.getElementById( 'fragmentShader' ).textContent,
side: THREE.DoubleSide,
forceSinglePass: true,
transparent: true

} );
Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_geometry_convex.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
const meshMaterial = new THREE.MeshLambertMaterial( {
color: 0xffffff,
opacity: 0.5,
side: THREE.TwoPassDoubleSide,
side: THREE.DoubleSide,
transparent: true
} );

Expand Down
3 changes: 2 additions & 1 deletion examples/webgl_postprocessing_dof2.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@
shininess: 0.5,
specular: 0xffffff,
envMap: textureCube,
side: THREE.DoubleSide
side: THREE.DoubleSide,
forceSinglePass: true
} );

const rand = Math.random;
Expand Down
2 changes: 1 addition & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const VSMShadowMap = 3;
export const FrontSide = 0;
export const BackSide = 1;
export const DoubleSide = 2;
export const TwoPassDoubleSide = 3;
mrdoob marked this conversation as resolved.
Show resolved Hide resolved
export const TwoPassDoubleSide = 2; // r149
export const NoBlending = 0;
export const NormalBlending = 1;
export const AdditiveBlending = 2;
Expand Down
1 change: 1 addition & 0 deletions src/loaders/MaterialLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class MaterialLoader extends Loader {

if ( json.alphaToCoverage !== undefined ) material.alphaToCoverage = json.alphaToCoverage;
if ( json.premultipliedAlpha !== undefined ) material.premultipliedAlpha = json.premultipliedAlpha;
if ( json.forceSinglePass !== undefined ) material.forceSinglePass = json.forceSinglePass;

if ( json.visible !== undefined ) material.visible = json.visible;

Expand Down
3 changes: 3 additions & 0 deletions src/materials/Material.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class Material extends EventDispatcher {

this.alphaToCoverage = false;
this.premultipliedAlpha = false;
this.forceSinglePass = false;

this.visible = true;

Expand Down Expand Up @@ -345,6 +346,7 @@ class Material extends EventDispatcher {
if ( this.alphaTest > 0 ) data.alphaTest = this.alphaTest;
if ( this.alphaToCoverage === true ) data.alphaToCoverage = this.alphaToCoverage;
if ( this.premultipliedAlpha === true ) data.premultipliedAlpha = this.premultipliedAlpha;
if ( this.forceSinglePass === true ) data.forceSinglePass = this.forceSinglePass;

if ( this.wireframe === true ) data.wireframe = this.wireframe;
if ( this.wireframeLinewidth > 1 ) data.wireframeLinewidth = this.wireframeLinewidth;
Expand Down Expand Up @@ -465,6 +467,7 @@ class Material extends EventDispatcher {
this.alphaTest = source.alphaTest;
this.alphaToCoverage = source.alphaToCoverage;
this.premultipliedAlpha = source.premultipliedAlpha;
this.forceSinglePass = source.forceSinglePass;

this.visible = source.visible;

Expand Down
10 changes: 5 additions & 5 deletions src/renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
REVISION,
BackSide,
TwoPassDoubleSide,
FrontSide,
DoubleSide,
RGBAFormat,
HalfFloatType,
FloatType,
Expand Down Expand Up @@ -828,7 +828,7 @@ function WebGLRenderer( parameters = {} ) {

function prepare( material, scene, object ) {

if ( material.transparent === true && material.side === TwoPassDoubleSide ) {
if ( material.transparent === true && material.side === DoubleSide && material.forceSinglePass === false ) {

material.side = BackSide;
material.needsUpdate = true;
Expand All @@ -838,7 +838,7 @@ function WebGLRenderer( parameters = {} ) {
material.needsUpdate = true;
getProgram( material, scene, object );

material.side = TwoPassDoubleSide;
material.side = DoubleSide;

} else {

Expand Down Expand Up @@ -1310,7 +1310,7 @@ function WebGLRenderer( parameters = {} ) {

material.onBeforeRender( _this, scene, camera, geometry, object, group );

if ( material.transparent === true && material.side === TwoPassDoubleSide ) {
if ( material.transparent === true && material.side === DoubleSide && material.forceSinglePass === false ) {

material.side = BackSide;
material.needsUpdate = true;
Expand All @@ -1320,7 +1320,7 @@ function WebGLRenderer( parameters = {} ) {
material.needsUpdate = true;
_this.renderBufferDirect( camera, scene, geometry, material, object, group );

material.side = TwoPassDoubleSide;
material.side = DoubleSide;

} else {

Expand Down
4 changes: 2 additions & 2 deletions src/renderers/webgl/WebGLShadowMap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FrontSide, BackSide, DoubleSide, TwoPassDoubleSide, NearestFilter, PCFShadowMap, VSMShadowMap, RGBADepthPacking, NoBlending } from '../../constants.js';
import { FrontSide, BackSide, DoubleSide, NearestFilter, PCFShadowMap, VSMShadowMap, RGBADepthPacking, NoBlending } from '../../constants.js';
import { WebGLRenderTarget } from '../WebGLRenderTarget.js';
import { MeshDepthMaterial } from '../../materials/MeshDepthMaterial.js';
import { MeshDistanceMaterial } from '../../materials/MeshDistanceMaterial.js';
Expand Down Expand Up @@ -28,7 +28,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {

_maxTextureSize = _capabilities.maxTextureSize;

const shadowSide = { [ FrontSide ]: BackSide, [ BackSide ]: FrontSide, [ DoubleSide ]: DoubleSide, [ TwoPassDoubleSide ]: DoubleSide };
const shadowSide = { [ FrontSide ]: BackSide, [ BackSide ]: FrontSide, [ DoubleSide ]: DoubleSide };

const shadowMaterialVertical = new ShaderMaterial( {
defines: {
Expand Down