物理网格材质(MeshPhysicalMaterial)

优质
小牛编辑
109浏览
2023-12-01

MeshStandardMaterial的扩展,提供了更高级的基于物理的渲染属性:

  • Clearcoat: Some materials — like car paints, carbon fiber, and wet surfaces — require a clear, reflective layer on top of another layer that may be irregular or rough. Clearcoat approximates this effect, without the need for a separate transparent surface.
  • Physically-based transparency: One limitation of .opacity is that highly transparent materials are less reflective. Physically-based .transmission provides a more realistic option for thin, transparent surfaces like glass.
  • Advanced reflectivity: More flexible reflectivity for non-metallic materials.

As a result of these complex shading features, MeshPhysicalMaterial has a higher performance cost, per pixel, than other three.js materials. Most effects are disabled by default, and add cost as they are enabled. For best results, always specify an environment map when using this material.

// iOS iframe auto-resize workaround if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) { const scene = document.getElementById( 'scene' ); scene.style.width = getComputedStyle( scene ).width; scene.style.height = getComputedStyle( scene ).height; scene.setAttribute( 'scrolling', 'no' ); }

例子

materials / variations / physical
materials / physical / clearcoat
materials / physical / reflectivity
materials / physical / sheen
materials / physical / transmission

构造函数(Constructor)

MeshPhysicalMaterial( parameters : Object )

parameters - (可选)用于定义材质外观的对象,具有一个或多个属性。 材质的任何属性都可以从此处传入(包括从MaterialMeshStandardMaterial继承的任何属性)

属性color例外,其可以作为十六进制字符串传递,默认情况下为 0xffffff(白色),内部调用Color.set(color)。

属性(Properties)

共有属性请参见其基类MaterialMeshStandardMaterial

.clearcoat : Float

Represents the intensity of the clear coat layer, from 0.0 to 1.0. Use clear coat related properties to enable multilayer materials that have a thin translucent layer over the base layer. Default is 0.0.

.clearcoatMap : Texture

The red channel of this texture is multiplied against .clearcoat, for per-pixel control over a coating's intensity. Default is null.

.clearcoatNormalMap : Texture

Can be used to enable independent normals for the clear coat layer. Default is null.

.clearcoatNormalScale : Vector2

How much .clearcoatNormalMap affects the clear coat layer, from (0,0) to (1,1). Default is (1,1).

.clearcoatRoughness : Float

Roughness of the clear coat layer, from 0.0 to 1.0. Default is 0.0.

.clearcoatRoughnessMap : Texture

The green channel of this texture is multiplied against .clearcoatRoughness, for per-pixel control over a coating's roughness. Default is null.

.defines : Object

如下形式的对象:

{
      'STANDARD': ''
      'PHYSICAL': '',
    };
WebGLRenderer使用它来选择shaders。

.ior : Float

Index-of-refraction for non-metallic materials, from 1.0 to 2.333. Default is 1.5.

.reflectivity : Float

Degree of reflectivity, from 0.0 to 1.0. Default is 0.5, which corresponds to an index-of-refraction of 1.5.
这模拟了非金属材质的反射率。当MeshStandardMaterial1.0时,此属性无效。

.sheen : Color

If a color is assigned to this property, the material will use a special sheen BRDF intended for rendering cloth materials such as velvet. The sheen color provides the ability to create two-tone specular materials. null by default.

.transmission : Float

Degree of transmission (or optical transparency), from 0.0 to 1.0. Default is 0.0.
Thin, transparent or semitransparent, plastic or glass materials remain largely reflective even if they are fully transmissive. The transmission property can be used to model these materials.
When transmission is non-zero, opacity should be set to 1.

.transmissionMap : Texture

The red channel of this texture is multiplied against .transmission, for per-pixel control over optical transparency. Default is null.

方法(Methods)

共有方法请参见其基类MaterialMeshStandardMaterial

源码(Source)

src/materials/MeshPhysicalMaterial.js