Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
9ca2dc96
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,发现更多精彩内容 >>
提交
9ca2dc96
编写于
9月 02, 2015
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7075 from gero3/webglcapabilities
add WebglCapabilities
上级
00a5a989
d4f5a1f4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
87 addition
and
73 deletion
+87
-73
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+19
-43
src/renderers/webgl/WebGLCapabilities.js
src/renderers/webgl/WebGLCapabilities.js
+67
-0
src/renderers/webgl/WebGLState.js
src/renderers/webgl/WebGLState.js
+0
-30
utils/build/includes/common.json
utils/build/includes/common.json
+1
-0
未找到文件。
src/renderers/WebGLRenderer.js
浏览文件 @
9ca2dc96
...
...
@@ -19,15 +19,12 @@ THREE.WebGLRenderer = function ( parameters ) {
pixelRatio
=
1
,
_precision
=
parameters
.
precision
!==
undefined
?
parameters
.
precision
:
'
highp
'
,
_alpha
=
parameters
.
alpha
!==
undefined
?
parameters
.
alpha
:
false
,
_depth
=
parameters
.
depth
!==
undefined
?
parameters
.
depth
:
true
,
_stencil
=
parameters
.
stencil
!==
undefined
?
parameters
.
stencil
:
true
,
_antialias
=
parameters
.
antialias
!==
undefined
?
parameters
.
antialias
:
false
,
_premultipliedAlpha
=
parameters
.
premultipliedAlpha
!==
undefined
?
parameters
.
premultipliedAlpha
:
true
,
_preserveDrawingBuffer
=
parameters
.
preserveDrawingBuffer
!==
undefined
?
parameters
.
preserveDrawingBuffer
:
false
,
_logarithmicDepthBuffer
=
parameters
.
logarithmicDepthBuffer
!==
undefined
?
parameters
.
logarithmicDepthBuffer
:
false
,
_clearColor
=
new
THREE
.
Color
(
0x000000
),
_clearAlpha
=
0
;
...
...
@@ -197,7 +194,10 @@ THREE.WebGLRenderer = function ( parameters ) {
}
var
extensions
=
new
THREE
.
WebGLExtensions
(
_gl
);
var
capabilities
=
new
THREE
.
WebGLCapabilities
(
_gl
,
extensions
,
parameters
)
this
.
capabilities
=
capabilities
;
extensions
.
get
(
'
OES_texture_float
'
);
extensions
.
get
(
'
OES_texture_float_linear
'
);
extensions
.
get
(
'
OES_texture_half_float
'
);
...
...
@@ -210,13 +210,7 @@ THREE.WebGLRenderer = function ( parameters ) {
THREE
.
BufferGeometry
.
MaxIndex
=
4294967296
;
}
if
(
_logarithmicDepthBuffer
)
{
extensions
.
get
(
'
EXT_frag_depth
'
);
}
var
state
=
new
THREE
.
WebGLState
(
_gl
,
extensions
,
paramThreeToGL
);
var
properties
=
new
THREE
.
WebGLProperties
();
var
objects
=
new
THREE
.
WebGLObjects
(
_gl
,
properties
,
this
.
info
);
...
...
@@ -274,24 +268,6 @@ THREE.WebGLRenderer = function ( parameters ) {
this
.
shadowMap
=
shadowMap
;
// GPU capabilities
var
_maxTextures
=
_gl
.
getParameter
(
_gl
.
MAX_TEXTURE_IMAGE_UNITS
);
var
_maxVertexTextures
=
_gl
.
getParameter
(
_gl
.
MAX_VERTEX_TEXTURE_IMAGE_UNITS
);
var
_maxTextureSize
=
_gl
.
getParameter
(
_gl
.
MAX_TEXTURE_SIZE
);
var
_maxCubemapSize
=
_gl
.
getParameter
(
_gl
.
MAX_CUBE_MAP_TEXTURE_SIZE
);
var
_supportsVertexTextures
=
_maxVertexTextures
>
0
;
var
_supportsBoneTextures
=
_supportsVertexTextures
&&
extensions
.
get
(
'
OES_texture_float
'
);
var
_maxPrecision
=
state
.
getMaxPrecision
(
_precision
);
if
(
_maxPrecision
!==
_precision
)
{
console
.
warn
(
'
THREE.WebGLRenderer:
'
,
_precision
,
'
not supported, using
'
,
_maxPrecision
,
'
instead.
'
);
_precision
=
_maxPrecision
;
}
// Plugins
...
...
@@ -346,7 +322,7 @@ THREE.WebGLRenderer = function ( parameters ) {
this
.
getPrecision
=
function
()
{
return
_
precision
;
return
capabilities
.
precision
;
};
...
...
@@ -1485,11 +1461,11 @@ THREE.WebGLRenderer = function ( parameters ) {
var
maxLightCount
=
allocateLights
(
lights
);
var
maxShadows
=
allocateShadows
(
lights
);
var
maxBones
=
allocateBones
(
object
);
var
precision
=
_
precision
;
var
precision
=
capabilities
.
precision
;
if
(
material
.
precision
!==
null
)
{
precision
=
state
.
getMaxPrecision
(
material
.
precision
);
precision
=
capabilities
.
getMaxPrecision
(
material
.
precision
);
if
(
precision
!==
material
.
precision
)
{
...
...
@@ -1502,7 +1478,7 @@ THREE.WebGLRenderer = function ( parameters ) {
var
parameters
=
{
precision
:
precision
,
supportsVertexTextures
:
_supportsV
ertexTextures
,
supportsVertexTextures
:
capabilities
.
v
ertexTextures
,
map
:
!!
material
.
map
,
envMap
:
!!
material
.
envMap
,
...
...
@@ -1526,11 +1502,11 @@ THREE.WebGLRenderer = function ( parameters ) {
flatShading
:
material
.
shading
===
THREE
.
FlatShading
,
sizeAttenuation
:
material
.
sizeAttenuation
,
logarithmicDepthBuffer
:
_
logarithmicDepthBuffer
,
logarithmicDepthBuffer
:
capabilities
.
logarithmicDepthBuffer
,
skinning
:
material
.
skinning
,
maxBones
:
maxBones
,
useVertexTexture
:
_supportsBone
Textures
&&
object
&&
object
.
skeleton
&&
object
.
skeleton
.
useVertexTexture
,
useVertexTexture
:
capabilities
.
floatVertex
Textures
&&
object
&&
object
.
skeleton
&&
object
.
skeleton
.
useVertexTexture
,
morphTargets
:
material
.
morphTargets
,
morphNormals
:
material
.
morphNormals
,
...
...
@@ -1797,7 +1773,7 @@ THREE.WebGLRenderer = function ( parameters ) {
_gl
.
uniformMatrix4fv
(
p_uniforms
.
projectionMatrix
,
false
,
camera
.
projectionMatrix
.
elements
);
if
(
_
logarithmicDepthBuffer
)
{
if
(
capabilities
.
logarithmicDepthBuffer
)
{
_gl
.
uniform1f
(
p_uniforms
.
logDepthBufFC
,
2.0
/
(
Math
.
log
(
camera
.
far
+
1.0
)
/
Math
.
LN2
)
);
...
...
@@ -1856,7 +1832,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
if
(
_supportsBone
Textures
&&
object
.
skeleton
&&
object
.
skeleton
.
useVertexTexture
)
{
if
(
capabilities
.
floatVertex
Textures
&&
object
.
skeleton
&&
object
.
skeleton
.
useVertexTexture
)
{
if
(
p_uniforms
.
boneTexture
!==
undefined
)
{
...
...
@@ -2262,9 +2238,9 @@ THREE.WebGLRenderer = function ( parameters ) {
var
textureUnit
=
_usedTextureUnits
;
if
(
textureUnit
>=
_
maxTextures
)
{
if
(
textureUnit
>=
capabilities
.
maxTextures
)
{
console
.
warn
(
'
WebGLRenderer: trying to use
'
+
textureUnit
+
'
texture units while this GPU supports only
'
+
_
maxTextures
);
console
.
warn
(
'
WebGLRenderer: trying to use
'
+
textureUnit
+
'
texture units while this GPU supports only
'
+
capabilities
.
maxTextures
);
}
...
...
@@ -2919,7 +2895,7 @@ THREE.WebGLRenderer = function ( parameters ) {
_gl
.
pixelStorei
(
_gl
.
UNPACK_PREMULTIPLY_ALPHA_WEBGL
,
texture
.
premultiplyAlpha
);
_gl
.
pixelStorei
(
_gl
.
UNPACK_ALIGNMENT
,
texture
.
unpackAlignment
);
texture
.
image
=
clampToMaxSize
(
texture
.
image
,
_
maxTextureSize
);
texture
.
image
=
clampToMaxSize
(
texture
.
image
,
capabilities
.
maxTextureSize
);
var
image
=
texture
.
image
,
isImagePowerOfTwo
=
THREE
.
Math
.
isPowerOfTwo
(
image
.
width
)
&&
THREE
.
Math
.
isPowerOfTwo
(
image
.
height
),
...
...
@@ -3104,7 +3080,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if
(
_this
.
autoScaleCubemaps
&&
!
isCompressed
&&
!
isDataTexture
)
{
cubeImage
[
i
]
=
clampToMaxSize
(
texture
.
image
[
i
],
_
maxCubemapSize
);
cubeImage
[
i
]
=
clampToMaxSize
(
texture
.
image
[
i
],
capabilities
.
maxCubemapSize
);
}
else
{
...
...
@@ -3567,7 +3543,7 @@ THREE.WebGLRenderer = function ( parameters ) {
function
allocateBones
(
object
)
{
if
(
_supportsBone
Textures
&&
object
&&
object
.
skeleton
&&
object
.
skeleton
.
useVertexTexture
)
{
if
(
capabilities
.
floatVertex
Textures
&&
object
&&
object
.
skeleton
&&
object
.
skeleton
.
useVertexTexture
)
{
return
1024
;
...
...
@@ -3692,7 +3668,7 @@ THREE.WebGLRenderer = function ( parameters ) {
this
.
supportsVertexTextures
=
function
()
{
return
_supportsV
ertexTextures
;
return
capabilities
.
v
ertexTextures
;
};
...
...
src/renderers/webgl/WebGLCapabilities.js
0 → 100644
浏览文件 @
9ca2dc96
THREE
.
WebGLCapabilities
=
function
(
gl
,
extensions
,
parameters
)
{
this
.
getMaxPrecision
=
function
(
precision
)
{
if
(
precision
===
'
highp
'
)
{
if
(
gl
.
getShaderPrecisionFormat
(
gl
.
VERTEX_SHADER
,
gl
.
HIGH_FLOAT
).
precision
>
0
&&
gl
.
getShaderPrecisionFormat
(
gl
.
FRAGMENT_SHADER
,
gl
.
HIGH_FLOAT
).
precision
>
0
)
{
return
'
highp
'
;
}
precision
=
'
mediump
'
;
}
if
(
precision
===
'
mediump
'
)
{
if
(
gl
.
getShaderPrecisionFormat
(
gl
.
VERTEX_SHADER
,
gl
.
MEDIUM_FLOAT
).
precision
>
0
&&
gl
.
getShaderPrecisionFormat
(
gl
.
FRAGMENT_SHADER
,
gl
.
MEDIUM_FLOAT
).
precision
>
0
)
{
return
'
mediump
'
;
}
}
return
'
lowp
'
;
};
// GPU capabilities
this
.
precision
=
parameters
.
precision
!==
undefined
?
parameters
.
precision
:
'
highp
'
,
this
.
logarithmicDepthBuffer
=
parameters
.
logarithmicDepthBuffer
!==
undefined
?
parameters
.
logarithmicDepthBuffer
:
false
;
this
.
maxTextures
=
gl
.
getParameter
(
gl
.
MAX_TEXTURE_IMAGE_UNITS
);
this
.
maxVertexTextures
=
gl
.
getParameter
(
gl
.
MAX_VERTEX_TEXTURE_IMAGE_UNITS
);
this
.
maxTextureSize
=
gl
.
getParameter
(
gl
.
MAX_TEXTURE_SIZE
);
this
.
maxCubemapSize
=
gl
.
getParameter
(
gl
.
MAX_CUBE_MAP_TEXTURE_SIZE
);
this
.
maxAttributes
=
gl
.
getParameter
(
gl
.
MAX_VERTEX_ATTRIBS
);
this
.
maxVertexUniforms
=
gl
.
getParameter
(
gl
.
MAX_VERTEX_UNIFORM_VECTORS
);
this
.
maxVaryings
=
gl
.
getParameter
(
gl
.
MAX_VARYING_VECTORS
);
this
.
maxFragmentUniforms
=
gl
.
getParameter
(
gl
.
MAX_FRAGMENT_UNIFORM_VECTORS
);
this
.
vertexTextures
=
this
.
maxVertexTextures
>
0
;
this
.
floatFragmentTextures
=
!!
extensions
.
get
(
'
OES_texture_float
'
);
this
.
floatVertexTextures
=
this
.
vertexTextures
&&
this
.
floatFragmentTextures
;
var
_maxPrecision
=
this
.
getMaxPrecision
(
this
.
precision
);
if
(
_maxPrecision
!==
this
.
precision
)
{
console
.
warn
(
'
THREE.WebGLRenderer:
'
,
this
.
precision
,
'
not supported, using
'
,
_maxPrecision
,
'
instead.
'
);
this
.
precision
=
_maxPrecision
;
}
if
(
this
.
logarithmicDepthBuffer
)
{
this
.
logarithmicDepthBuffer
=
!!
extensions
.
get
(
'
EXT_frag_depth
'
);
}
};
src/renderers/webgl/WebGLState.js
浏览文件 @
9ca2dc96
...
...
@@ -142,36 +142,6 @@ THREE.WebGLState = function ( gl, extensions, paramThreeToGL ) {
};
this
.
getMaxPrecision
=
function
(
precision
)
{
if
(
precision
===
'
highp
'
)
{
if
(
gl
.
getShaderPrecisionFormat
(
gl
.
VERTEX_SHADER
,
gl
.
HIGH_FLOAT
).
precision
>
0
&&
gl
.
getShaderPrecisionFormat
(
gl
.
FRAGMENT_SHADER
,
gl
.
HIGH_FLOAT
).
precision
>
0
)
{
return
'
highp
'
;
}
precision
=
'
mediump
'
;
}
if
(
precision
===
'
mediump
'
)
{
if
(
gl
.
getShaderPrecisionFormat
(
gl
.
VERTEX_SHADER
,
gl
.
MEDIUM_FLOAT
).
precision
>
0
&&
gl
.
getShaderPrecisionFormat
(
gl
.
FRAGMENT_SHADER
,
gl
.
MEDIUM_FLOAT
).
precision
>
0
)
{
return
'
mediump
'
;
}
}
return
'
lowp
'
;
};
this
.
setBlending
=
function
(
blending
,
blendEquation
,
blendSrc
,
blendDst
,
blendEquationAlpha
,
blendSrcAlpha
,
blendDstAlpha
)
{
if
(
blending
!==
currentBlending
)
{
...
...
utils/build/includes/common.json
浏览文件 @
9ca2dc96
...
...
@@ -159,6 +159,7 @@
"src/renderers/webgl/WebGLBufferRenderer.js"
,
"src/renderers/webgl/WebGLIndexedBufferRenderer.js"
,
"src/renderers/webgl/WebGLExtensions.js"
,
"src/renderers/webgl/WebGLCapabilities.js"
,
"src/renderers/webgl/WebGLGeometries.js"
,
"src/renderers/webgl/WebGLObjects.js"
,
"src/renderers/webgl/WebGLProgram.js"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录