Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
6ff983f3
T
three.js
项目概览
Ablesons
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
6ff983f3
编写于
10月 09, 2019
作者:
W
WestLangley
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
PointsMaterial: add alphaMap support
上级
b91aebff
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
75 addition
and
8 deletion
+75
-8
docs/api/en/materials/PointsMaterial.html
docs/api/en/materials/PointsMaterial.html
+11
-0
src/materials/PointsMaterial.d.ts
src/materials/PointsMaterial.d.ts
+3
-1
src/materials/PointsMaterial.js
src/materials/PointsMaterial.js
+5
-0
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+31
-5
src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js
...nderers/shaders/ShaderChunk/map_particle_fragment.glsl.js
+12
-1
src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js
...rs/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js
+12
-1
src/renderers/shaders/UniformsLib.js
src/renderers/shaders/UniformsLib.js
+1
-0
未找到文件。
docs/api/en/materials/PointsMaterial.html
浏览文件 @
6ff983f3
...
...
@@ -65,6 +65,17 @@ scene.add( starField );
<h2>
Properties
</h2>
<p>
See the base [page:Material] class for common properties.
</p>
<h3>
[property:Texture alphaMap]
</h3>
<p>
The alpha map is a grayscale texture that controls the opacity across the surface
(black: fully transparent; white: fully opaque). Default is null.
<br
/><br
/>
Only the color of the texture is used, ignoring the alpha channel if one exists.
For RGB and RGBA textures, the [page:WebGLRenderer WebGL] renderer will use the
green channel when sampling this texture due to the extra bit of precision provided
for green in DXT-compressed and uncompressed RGB 565 formats. Luminance-only and
luminance/alpha textures will also still work as expected.
</p>
<h3>
[property:Color color]
</h3>
<p>
[page:Color] of the material, by default set to white (0xffffff).
</p>
...
...
src/materials/PointsMaterial.d.ts
浏览文件 @
6ff983f3
...
...
@@ -25,7 +25,8 @@ export class MultiMaterial extends Material {
export
interface
PointsMaterialParameters
extends
MaterialParameters
{
color
?:
Color
|
string
|
number
;
map
?:
Texture
;
map
?:
Texture
|
null
;
alphaMap
?:
Texture
|
null
;
size
?:
number
;
sizeAttenuation
?:
boolean
;
}
...
...
@@ -36,6 +37,7 @@ export class PointsMaterial extends Material {
color
:
Color
;
map
:
Texture
|
null
;
alphaMap
:
Texture
|
null
;
size
:
number
;
sizeAttenuation
:
boolean
;
...
...
src/materials/PointsMaterial.js
浏览文件 @
6ff983f3
...
...
@@ -9,6 +9,7 @@ import { Color } from '../math/Color.js';
* color: <hex>,
* opacity: <float>,
* map: new THREE.Texture( <Image> ),
* alphaMap: new THREE.Texture( <Image> ),
*
* size: <float>,
* sizeAttenuation: <bool>
...
...
@@ -27,6 +28,8 @@ function PointsMaterial( parameters ) {
this
.
map
=
null
;
this
.
alphaMap
=
null
;
this
.
size
=
1
;
this
.
sizeAttenuation
=
true
;
...
...
@@ -49,6 +52,8 @@ PointsMaterial.prototype.copy = function ( source ) {
this
.
map
=
source
.
map
;
this
.
alphaMap
=
source
.
alphaMap
;
this
.
size
=
source
.
size
;
this
.
sizeAttenuation
=
source
.
sizeAttenuation
;
...
...
src/renderers/WebGLRenderer.js
浏览文件 @
6ff983f3
...
...
@@ -2181,17 +2181,43 @@ function WebGLRenderer( parameters ) {
uniforms
.
size
.
value
=
material
.
size
*
_pixelRatio
;
uniforms
.
scale
.
value
=
_height
*
0.5
;
uniforms
.
map
.
value
=
material
.
map
;
if
(
material
.
map
)
{
uniforms
.
map
.
value
=
material
.
map
;
}
if
(
material
.
alphaMap
)
{
uniforms
.
alphaMap
.
value
=
material
.
alphaMap
;
}
if
(
material
.
map
!==
null
)
{
// uv repeat and offset setting priorities
// 1. color map
// 2. alpha map
if
(
material
.
map
.
matrixAutoUpdate
===
true
)
{
var
uvScaleMap
;
material
.
map
.
updateMatrix
();
if
(
material
.
map
)
{
uvScaleMap
=
material
.
map
;
}
else
if
(
material
.
alphaMap
)
{
uvScaleMap
=
material
.
alphaMap
;
}
if
(
uvScaleMap
!==
undefined
)
{
if
(
uvScaleMap
.
matrixAutoUpdate
===
true
)
{
uvScaleMap
.
updateMatrix
();
}
uniforms
.
uvTransform
.
value
.
copy
(
material
.
m
ap
.
matrix
);
uniforms
.
uvTransform
.
value
.
copy
(
uvScaleM
ap
.
matrix
);
}
...
...
src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js
浏览文件 @
6ff983f3
export
default
/* glsl */
`
#if
def USE_MAP
#if
defined( USE_MAP ) || defined( USE_ALPHAMAP )
vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
#endif
#ifdef USE_MAP
vec4 mapTexel = texture2D( map, uv );
diffuseColor *= mapTexelToLinear( mapTexel );
#endif
#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, uv ).g;
#endif
`
;
src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js
浏览文件 @
6ff983f3
export
default
/* glsl */
`
#if
def USE_MAP
#if
defined( USE_MAP ) || defined( USE_ALPHAMAP )
uniform mat3 uvTransform;
#endif
#ifdef USE_MAP
uniform sampler2D map;
#endif
#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif
`
;
src/renderers/shaders/UniformsLib.js
浏览文件 @
6ff983f3
...
...
@@ -182,6 +182,7 @@ var UniformsLib = {
size
:
{
value
:
1.0
},
scale
:
{
value
:
1.0
},
map
:
{
value
:
null
},
alphaMap
:
{
value
:
null
},
uvTransform
:
{
value
:
new
Matrix3
()
}
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录