Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
7fe9a41c
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,发现更多精彩内容 >>
未验证
提交
7fe9a41c
编写于
1月 31, 2019
作者:
M
Mr.doob
提交者:
GitHub
1月 31, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15574 from takahirox/SkipNonPOTFallbackWebGL2
Skip non-POT texture fallback on WebGL2
上级
d1f9e963
533ff0ec
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
19 deletion
+19
-19
src/renderers/webgl/WebGLTextures.js
src/renderers/webgl/WebGLTextures.js
+19
-19
未找到文件。
src/renderers/webgl/WebGLTextures.js
浏览文件 @
7fe9a41c
...
...
@@ -83,9 +83,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
}
function
textureNeedsGenerateMipmaps
(
texture
,
isPowerOfTwo
)
{
function
textureNeedsGenerateMipmaps
(
texture
,
supportsMips
)
{
return
texture
.
generateMipmaps
&&
isPowerOfTwo
&&
return
texture
.
generateMipmaps
&&
supportsMips
&&
texture
.
minFilter
!==
NearestFilter
&&
texture
.
minFilter
!==
LinearFilter
;
}
...
...
@@ -355,12 +355,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
}
var
image
=
cubeImage
[
0
],
isPowerOfTwoImage
=
isPowerOfTwo
(
image
)
,
supportsMips
=
isPowerOfTwo
(
image
)
||
capabilities
.
isWebGL2
,
glFormat
=
utils
.
convert
(
texture
.
format
),
glType
=
utils
.
convert
(
texture
.
type
),
glInternalFormat
=
getInternalFormat
(
glFormat
,
glType
);
setTextureParameters
(
_gl
.
TEXTURE_CUBE_MAP
,
texture
,
isPowerOfTwoImage
);
setTextureParameters
(
_gl
.
TEXTURE_CUBE_MAP
,
texture
,
supportsMips
);
for
(
var
i
=
0
;
i
<
6
;
i
++
)
{
...
...
@@ -418,7 +418,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
}
if
(
textureNeedsGenerateMipmaps
(
texture
,
isPowerOfTwoImage
)
)
{
if
(
textureNeedsGenerateMipmaps
(
texture
,
supportsMips
)
)
{
// We assume images for cube map have the same size.
generateMipmap
(
_gl
.
TEXTURE_CUBE_MAP
,
texture
,
image
.
width
,
image
.
height
);
...
...
@@ -447,11 +447,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
}
function
setTextureParameters
(
textureType
,
texture
,
isPowerOfTwoImage
)
{
function
setTextureParameters
(
textureType
,
texture
,
supportsMips
)
{
var
extension
;
if
(
isPowerOfTwoImage
)
{
if
(
supportsMips
)
{
_gl
.
texParameteri
(
textureType
,
_gl
.
TEXTURE_WRAP_S
,
utils
.
convert
(
texture
.
wrapS
)
);
_gl
.
texParameteri
(
textureType
,
_gl
.
TEXTURE_WRAP_T
,
utils
.
convert
(
texture
.
wrapT
)
);
...
...
@@ -539,12 +539,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
var
needsPowerOfTwo
=
textureNeedsPowerOfTwo
(
texture
)
&&
isPowerOfTwo
(
texture
.
image
)
===
false
;
var
image
=
resizeImage
(
texture
.
image
,
needsPowerOfTwo
,
false
,
capabilities
.
maxTextureSize
);
var
isPowerOfTwoImage
=
isPowerOfTwo
(
image
)
,
var
supportsMips
=
isPowerOfTwo
(
image
)
||
capabilities
.
isWebGL2
,
glFormat
=
utils
.
convert
(
texture
.
format
),
glType
=
utils
.
convert
(
texture
.
type
),
glInternalFormat
=
getInternalFormat
(
glFormat
,
glType
);
setTextureParameters
(
textureType
,
texture
,
isPowerOfTwoImage
);
setTextureParameters
(
textureType
,
texture
,
supportsMips
);
var
mipmap
,
mipmaps
=
texture
.
mipmaps
;
...
...
@@ -610,7 +610,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
// if there are no manual mipmaps
// set 0 level mipmap and then use GL to generate other mipmap levels
if
(
mipmaps
.
length
>
0
&&
isPowerOfTwoImage
)
{
if
(
mipmaps
.
length
>
0
&&
supportsMips
)
{
for
(
var
i
=
0
,
il
=
mipmaps
.
length
;
i
<
il
;
i
++
)
{
...
...
@@ -670,7 +670,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
// if there are no manual mipmaps
// set 0 level mipmap and then use GL to generate other mipmap levels
if
(
mipmaps
.
length
>
0
&&
isPowerOfTwoImage
)
{
if
(
mipmaps
.
length
>
0
&&
supportsMips
)
{
for
(
var
i
=
0
,
il
=
mipmaps
.
length
;
i
<
il
;
i
++
)
{
...
...
@@ -691,7 +691,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
}
if
(
textureNeedsGenerateMipmaps
(
texture
,
isPowerOfTwoImage
)
)
{
if
(
textureNeedsGenerateMipmaps
(
texture
,
supportsMips
)
)
{
generateMipmap
(
_gl
.
TEXTURE_2D
,
texture
,
image
.
width
,
image
.
height
);
...
...
@@ -880,7 +880,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
var
isCube
=
(
renderTarget
.
isWebGLRenderTargetCube
===
true
);
var
isMultisample
=
(
renderTarget
.
isWebGLMultisampleRenderTarget
===
true
);
var
isTargetPowerOfTwo
=
isPowerOfTwo
(
renderTarget
)
;
var
supportsMips
=
isPowerOfTwo
(
renderTarget
)
||
capabilities
.
isWebGL2
;
// Setup framebuffer
...
...
@@ -941,7 +941,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
if
(
isCube
)
{
state
.
bindTexture
(
_gl
.
TEXTURE_CUBE_MAP
,
textureProperties
.
__webglTexture
);
setTextureParameters
(
_gl
.
TEXTURE_CUBE_MAP
,
renderTarget
.
texture
,
isTargetPowerOfTwo
);
setTextureParameters
(
_gl
.
TEXTURE_CUBE_MAP
,
renderTarget
.
texture
,
supportsMips
);
for
(
var
i
=
0
;
i
<
6
;
i
++
)
{
...
...
@@ -949,7 +949,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
}
if
(
textureNeedsGenerateMipmaps
(
renderTarget
.
texture
,
isTargetPowerOfTwo
)
)
{
if
(
textureNeedsGenerateMipmaps
(
renderTarget
.
texture
,
supportsMips
)
)
{
generateMipmap
(
_gl
.
TEXTURE_CUBE_MAP
,
renderTarget
.
texture
,
renderTarget
.
width
,
renderTarget
.
height
);
...
...
@@ -960,10 +960,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
}
else
{
state
.
bindTexture
(
_gl
.
TEXTURE_2D
,
textureProperties
.
__webglTexture
);
setTextureParameters
(
_gl
.
TEXTURE_2D
,
renderTarget
.
texture
,
isTargetPowerOfTwo
);
setTextureParameters
(
_gl
.
TEXTURE_2D
,
renderTarget
.
texture
,
supportsMips
);
setupFrameBufferTexture
(
renderTargetProperties
.
__webglFramebuffer
,
renderTarget
,
_gl
.
COLOR_ATTACHMENT0
,
_gl
.
TEXTURE_2D
);
if
(
textureNeedsGenerateMipmaps
(
renderTarget
.
texture
,
isTargetPowerOfTwo
)
)
{
if
(
textureNeedsGenerateMipmaps
(
renderTarget
.
texture
,
supportsMips
)
)
{
generateMipmap
(
_gl
.
TEXTURE_2D
,
renderTarget
.
texture
,
renderTarget
.
width
,
renderTarget
.
height
);
...
...
@@ -986,9 +986,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
function
updateRenderTargetMipmap
(
renderTarget
)
{
var
texture
=
renderTarget
.
texture
;
var
isTargetPowerOfTwo
=
isPowerOfTwo
(
renderTarget
)
;
var
supportsMips
=
isPowerOfTwo
(
renderTarget
)
||
capabilities
.
isWebGL2
;
if
(
textureNeedsGenerateMipmaps
(
texture
,
isTargetPowerOfTwo
)
)
{
if
(
textureNeedsGenerateMipmaps
(
texture
,
supportsMips
)
)
{
var
target
=
renderTarget
.
isWebGLRenderTargetCube
?
_gl
.
TEXTURE_CUBE_MAP
:
_gl
.
TEXTURE_2D
;
var
webglTexture
=
properties
.
get
(
texture
).
__webglTexture
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录