未验证 提交 14bf5775 编写于 作者: M Michael Herzog 提交者: GitHub

WebGLRenderer: Refactor creation of transmission render target. (#23450)

* WebGLRenderer: Refactor creation of transmission render target.

* Docs: Improve MeshPhysicalMaterial page.
上级 e6e322df
......@@ -188,7 +188,9 @@
The transmission property can be used to model these materials.<br />
When transmission is non-zero, [page:Material.opacity opacity] should be set to *1*.
When transmission is non-zero, [page:Material.opacity opacity] should be set to *1*.<br />
This feature can only be used with a WebGL 2 rendering context.
</p>
<h3>[property:Texture transmissionMap]</h3>
......
......@@ -184,7 +184,9 @@
The transmission property can be used to model these materials.<br />
When transmission is non-zero, [page:Material.opacity opacity] should be set to *1*.
When transmission is non-zero, [page:Material.opacity opacity] should be set to *1*.<br />
This feature can only be used with a WebGL 2 rendering context.
</p>
<h3>[property:Texture transmissionMap]</h3>
......
......@@ -9,12 +9,11 @@ import {
UnsignedByteType,
LinearEncoding,
NoToneMapping,
LinearMipmapLinearFilter,
NearestFilter,
ClampToEdgeWrapping
LinearMipmapLinearFilter
} from '../constants.js';
import { Frustum } from '../math/Frustum.js';
import { Matrix4 } from '../math/Matrix4.js';
import { Vector2 } from '../math/Vector2.js';
import { Vector3 } from '../math/Vector3.js';
import { Vector4 } from '../math/Vector4.js';
import { WebGLAnimation } from './webgl/WebGLAnimation.js';
......@@ -170,6 +169,7 @@ function WebGLRenderer( parameters = {} ) {
const _projScreenMatrix = new Matrix4();
const _vector2 = new Vector2();
const _vector3 = new Vector3();
const _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true };
......@@ -1184,23 +1184,33 @@ function WebGLRenderer( parameters = {} ) {
function renderTransmissionPass( opaqueObjects, scene, camera ) {
if ( capabilities.isWebGL2 === false ) {
console.error( 'THREE.WebGLRenderer: Transmission can only be used with WebGL 2.' );
return;
}
if ( _transmissionRenderTarget === null ) {
const needsAntialias = _antialias === true && capabilities.isWebGL2 === true;
const renderTargetType = needsAntialias ? WebGLMultisampleRenderTarget : WebGLRenderTarget;
const renderTargetType = ( _antialias === true ) ? WebGLMultisampleRenderTarget : WebGLRenderTarget;
_transmissionRenderTarget = new renderTargetType( 1024, 1024, {
_transmissionRenderTarget = new renderTargetType( 1, 1, {
generateMipmaps: true,
type: utils.convert( HalfFloatType ) !== null ? HalfFloatType : UnsignedByteType,
type: HalfFloatType,
minFilter: LinearMipmapLinearFilter,
magFilter: NearestFilter,
wrapS: ClampToEdgeWrapping,
wrapT: ClampToEdgeWrapping,
useRenderToTexture: extensions.has( 'WEBGL_multisampled_render_to_texture' )
} );
}
// set size of transmission render target to half size of drawing buffer
_this.getDrawingBufferSize( _vector2 ).multiplyScalar( 0.5 ).floor();
_transmissionRenderTarget.setSize( _vector2.x, _vector2.y );
//
const currentRenderTarget = _this.getRenderTarget();
_this.setRenderTarget( _transmissionRenderTarget );
_this.clear();
......@@ -1786,7 +1796,7 @@ function WebGLRenderer( parameters = {} ) {
// are midframe flushes and an external depth buffer. Disable use of the extension.
if ( renderTarget.useRenderToTexture ) {
console.warn( 'render-to-texture extension was disabled because an external texture was provided' );
console.warn( 'THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided' );
renderTarget.useRenderToTexture = false;
renderTarget.useRenderbuffer = true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册