Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
fyge_for_tb
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王剑峰
fyge_for_tb
Commits
736eac75
Commit
736eac75
authored
May 06, 2023
by
邱旭
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复鸿蒙3.0问题,只是临时修复,不确定是否会有其他的影响
parent
b74d8660
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
31 deletions
+41
-31
BatchRenderer.ts
src/2d/renderers/plugins/BatchRenderer.ts
+18
-13
D3Renderer.ts
src/3d/D3Renderer.ts
+20
-16
getCusShader.ts
src/3d/shaders/getCusShader.ts
+1
-1
compileProgram.ts
src/glCore/shader/compileProgram.ts
+2
-1
No files found.
src/2d/renderers/plugins/BatchRenderer.ts
View file @
736eac75
...
@@ -361,7 +361,8 @@ export class BatchRenderer extends ObjectRenderer {
...
@@ -361,7 +361,8 @@ export class BatchRenderer extends ObjectRenderer {
// this.indexBuffer.update();
// this.indexBuffer.update();
//暂时出现了bug,ios不做特殊处理先,以后有时间排查,暂时应该影响不大
//暂时出现了bug,ios不做特殊处理先,以后有时间排查,暂时应该影响不大
//貌似没问题了(20210601),但是感觉性能差别不大,先不加了,到时要加的话,也要打开start方法里的注释
//貌似没问题了(20210601),但是感觉性能差别不大,先不加了,到时要加的话,也要打开start方法里的注释
if
(
osType
==
"ios"
&&
false
)
{
// TODO 华为鸿蒙3.0问题
// if (getOsType() == "ios" && false) {
//可能有一帧,在多个地方执行flush
//可能有一帧,在多个地方执行flush
// this is still needed for IOS performance..
// this is still needed for IOS performance..
// it really does not like uploading to the same buffer in a single frame!
// it really does not like uploading to the same buffer in a single frame!
...
@@ -380,7 +381,10 @@ export class BatchRenderer extends ObjectRenderer {
...
@@ -380,7 +381,10 @@ export class BatchRenderer extends ObjectRenderer {
.
addAttribute
(
vertexBuffer
,
attrs
.
aVertexPosition
,
gl
.
FLOAT
,
false
,
this
.
vertByteSize
,
0
)
.
addAttribute
(
vertexBuffer
,
attrs
.
aVertexPosition
,
gl
.
FLOAT
,
false
,
this
.
vertByteSize
,
0
)
.
addAttribute
(
vertexBuffer
,
attrs
.
aTextureCoord
,
gl
.
FLOAT
,
true
,
this
.
vertByteSize
,
2
*
4
)
.
addAttribute
(
vertexBuffer
,
attrs
.
aTextureCoord
,
gl
.
FLOAT
,
true
,
this
.
vertByteSize
,
2
*
4
)
.
addAttribute
(
vertexBuffer
,
attrs
.
aColor
,
gl
.
UNSIGNED_BYTE
,
true
,
this
.
vertByteSize
,
4
*
4
)
.
addAttribute
(
vertexBuffer
,
attrs
.
aColor
,
gl
.
UNSIGNED_BYTE
,
true
,
this
.
vertByteSize
,
4
*
4
)
.
addAttribute
(
vertexBuffer
,
attrs
.
aTextureId
,
gl
.
FLOAT
,
false
,
this
.
vertByteSize
,
5
*
4
);
// .addAttribute(vertexBuffer, attrs.aTextureId, gl.FLOAT, false, this.vertByteSize, 5 * 4);//理由同上
if
(
attrs
.
aTextureId
)
{
vao
.
addAttribute
(
vertexBuffer
,
attrs
.
aTextureId
,
gl
.
FLOAT
,
false
,
this
.
vertByteSize
,
5
*
4
);
}
this
.
vaos
[
this
.
vertexCount
]
=
vao
;
this
.
vaos
[
this
.
vertexCount
]
=
vao
;
// console.log(this.vertexCount)
// console.log(this.vertexCount)
...
@@ -393,13 +397,13 @@ export class BatchRenderer extends ObjectRenderer {
...
@@ -393,13 +397,13 @@ export class BatchRenderer extends ObjectRenderer {
this
.
vertexCount
++
;
this
.
vertexCount
++
;
}
//
}
else
{
//
else {
//
// lets use the faster option, always use buffer number 0
//
// lets use the faster option, always use buffer number 0
this
.
vertexBuffers
[
this
.
vertexCount
].
upload
(
buffer
.
vertices
,
0
,
true
);
//
this.vertexBuffers[this.vertexCount].upload(buffer.vertices, 0, true);
this
.
indexBuffers
[
this
.
vertexCount
].
upload
(
indexBuffer
,
0
,
true
);
//
this.indexBuffers[this.vertexCount].upload(indexBuffer, 0, true);
}
//
}
// this.renderer.state.set(this.state);
// this.renderer.state.set(this.state);
...
@@ -476,10 +480,11 @@ export class BatchRenderer extends ObjectRenderer {
...
@@ -476,10 +480,11 @@ export class BatchRenderer extends ObjectRenderer {
this
.
renderer
.
bindShader
(
this
.
shader
);
this
.
renderer
.
bindShader
(
this
.
shader
);
// if (osType != "ios") {//暂时出现了bug,ios不做特殊处理先
// if (getOsType() != "ios") {//暂时出现了bug,ios不做特殊处理先
this
.
renderer
.
bindVao
(
this
.
vaos
[
this
.
vertexCount
]);
// TODO 鸿蒙3.0问题
this
.
vertexBuffers
[
this
.
vertexCount
].
bind
();
// this.renderer.bindVao(this.vaos[this.vertexCount]);
this
.
indexBuffers
[
this
.
vertexCount
].
bind
();
// this.vertexBuffers[this.vertexCount].bind();
// this.indexBuffers[this.vertexCount].bind();
// }
// }
}
}
...
...
src/3d/D3Renderer.ts
View file @
736eac75
...
@@ -50,6 +50,8 @@ export class D3Renderer extends ObjectRenderer {
...
@@ -50,6 +50,8 @@ export class D3Renderer extends ObjectRenderer {
maxVertexUniforms
:
number
maxVertexUniforms
:
number
floatVertexTextures
:
boolean
;
floatVertexTextures
:
boolean
;
private
curLightkey
:
string
;
private
curLightkey
:
string
;
constructor
(
renderer
:
WebglRenderer
)
{
constructor
(
renderer
:
WebglRenderer
)
{
super
(
renderer
);
super
(
renderer
);
}
}
...
@@ -60,7 +62,6 @@ export class D3Renderer extends ObjectRenderer {
...
@@ -60,7 +62,6 @@ export class D3Renderer extends ObjectRenderer {
var
vertexTextures
=
maxVertexTextures
>
0
;
var
vertexTextures
=
maxVertexTextures
>
0
;
var
floatFragmentTextures
=
!!
gl
.
getExtension
(
"OES_texture_float"
);
var
floatFragmentTextures
=
!!
gl
.
getExtension
(
"OES_texture_float"
);
//传入的数据纹理暂时有问题,是UNPACK_ALIGNMENT还是UNPACK_FLIP_Y_WEBGL的问题未知,所以不管先
//传入的数据纹理暂时有问题,是UNPACK_ALIGNMENT还是UNPACK_FLIP_Y_WEBGL的问题未知,所以不管先
// this.floatVertexTextures = false//vertexTextures && floatFragmentTextures;
this
.
floatVertexTextures
=
vertexTextures
&&
floatFragmentTextures
;
this
.
floatVertexTextures
=
vertexTextures
&&
floatFragmentTextures
;
}
}
start
()
{
start
()
{
...
@@ -76,6 +77,7 @@ export class D3Renderer extends ObjectRenderer {
...
@@ -76,6 +77,7 @@ export class D3Renderer extends ObjectRenderer {
//设置剔除,下面根据材质自行设置
//设置剔除,下面根据材质自行设置
//this.setCullFace(1);
//this.setCullFace(1);
}
}
stop
()
{
stop
()
{
this
.
flush
();
this
.
flush
();
//原先的视窗需要重新//讲道理应该渲染器自己搞,算了
//原先的视窗需要重新//讲道理应该渲染器自己搞,算了
...
@@ -89,25 +91,27 @@ export class D3Renderer extends ObjectRenderer {
...
@@ -89,25 +91,27 @@ export class D3Renderer extends ObjectRenderer {
//继续需要的数据
//继续需要的数据
render
(
obj
:
Mesh3D
)
{
render
(
obj
:
Mesh3D
)
{
if
(
!
obj
.
geometry
||
!
obj
.
material
)
return
;
if
(
!
obj
.
geometry
||
!
obj
.
material
)
return
;
var
mat
=
obj
.
material
;
const
mat
=
obj
.
material
;
var
geo
=
obj
.
geometry
;
const
meshes
=
this
.
meshes
;
//提取渲染对象及材质,分组渲染,怎么考虑同一个geometry只需要处理一次attr,
//提取渲染对象及材质,分组渲染,怎么考虑同一个geometry只需要处理一次attr,
//分组按
//分组按
// if (!this.meshes.length) {
// if (!this.meshes.length) {
// this.meshes.push(obj);
// this.meshes.push(obj);
// } else {
// } else {
for
(
var
i
=
0
;
i
<
this
.
meshes
.
length
;
i
++
)
{
const
len
=
meshes
.
length
;
if
(
this
.
meshes
[
i
].
material
==
mat
)
{
//没啥软用
for
(
let
i
=
0
;
i
<
len
;
i
++
)
{
this
.
meshes
.
splice
(
i
,
0
,
obj
)
if
(
meshes
[
i
].
material
==
mat
)
{
//没啥软用
return
meshes
.
splice
(
i
,
0
,
obj
)
return
;
}
}
}
}
// }
// }
this
.
meshes
.
push
(
obj
);
meshes
.
push
(
obj
);
}
}
flush
()
{
flush
()
{
//生成一张阴影的深度贴图
//生成一张阴影的深度贴图
var
shadow
=
getShadowMap
(
this
.
lightsConfig
,
this
.
meshes
,
this
.
renderer
);
const
shadow
=
getShadowMap
(
this
.
lightsConfig
,
this
.
meshes
,
this
.
renderer
);
if
(
shadow
)
{
if
(
shadow
)
{
//绑定过帧缓存,viewport肯定被改了,该回去
//绑定过帧缓存,viewport肯定被改了,该回去
this
.
renderer
.
gl
.
viewport
(
this
.
renderer
.
gl
.
viewport
(
...
@@ -121,12 +125,12 @@ export class D3Renderer extends ObjectRenderer {
...
@@ -121,12 +125,12 @@ export class D3Renderer extends ObjectRenderer {
}
}
//同一材质的模型一起处理,同一个着色器,webglRenderer里会判断,不会重复绑定
//同一材质的模型一起处理,同一个着色器,webglRenderer里会判断,不会重复绑定
var
curShader
:
GLShader
=
null
;
let
curShader
:
GLShader
=
null
;
var
pointLightNum
=
this
.
lightsConfig
.
pointLights
.
length
;
const
pointLightNum
=
this
.
lightsConfig
.
pointLights
.
length
;
var
dirLightNum
=
this
.
lightsConfig
.
directionalLights
.
length
;
const
dirLightNum
=
this
.
lightsConfig
.
directionalLights
.
length
;
var
gl
:
WebGLRenderingContext
=
this
.
renderer
.
gl
;
const
gl
:
WebGLRenderingContext
=
this
.
renderer
.
gl
;
var
textureManager
=
this
.
renderer
.
textureManager
;
const
textureManager
=
this
.
renderer
.
textureManager
;
for
(
var
i
=
0
;
i
<
this
.
meshes
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
meshes
.
length
;
i
++
)
{
let
mesh
=
this
.
meshes
[
i
];
//怎么判断是否要重新绑定
let
mesh
=
this
.
meshes
[
i
];
//怎么判断是否要重新绑定
let
mat
:
BaseMaterial
=
mesh
.
material
;
let
mat
:
BaseMaterial
=
mesh
.
material
;
let
geo
=
mesh
.
geometry
;
let
geo
=
mesh
.
geometry
;
...
@@ -226,7 +230,7 @@ export class D3Renderer extends ObjectRenderer {
...
@@ -226,7 +230,7 @@ export class D3Renderer extends ObjectRenderer {
//是否带环境贴图
//是否带环境贴图
if
(
mat
.
envMap
&&
mat
.
envMap
.
valid
)
{
//环境贴图先不考虑图集的情况,一般一张大jpg
if
(
mat
.
envMap
&&
mat
.
envMap
.
valid
)
{
//环境贴图先不考虑图集的情况,一般一张大jpg
//找纹理,绑定纹理,多个纹理也是一样的方法
//找纹理,绑定纹理,多个纹理也是一样的方法
uniforms
[
"uEnvMap"
]
=
textureManager
.
bindTexture
(
mat
.
envMap
,
undefined
,
false
);
;
uniforms
[
"uEnvMap"
]
=
textureManager
.
bindTexture
(
mat
.
envMap
,
undefined
,
false
);
//反射率
//反射率
uniforms
[
"uReflectivity"
]
=
mat
.
reflectivity
;
uniforms
[
"uReflectivity"
]
=
mat
.
reflectivity
;
//传相机位置
//传相机位置
...
...
src/3d/shaders/getCusShader.ts
View file @
736eac75
...
@@ -311,7 +311,7 @@ const VERT = [
...
@@ -311,7 +311,7 @@ const VERT = [
" uniform mat4 uBindMatrix;"
,
" uniform mat4 uBindMatrix;"
,
" uniform mat4 uBindMatrixInverse;"
,
" uniform mat4 uBindMatrixInverse;"
,
" #ifdef BONE_TEXTURE"
,
" #ifdef BONE_TEXTURE"
,
" uniform sampler2D uBoneTexture;"
,
" uniform
highp
sampler2D uBoneTexture;"
,
" uniform int uBoneTextureSize;"
,
" uniform int uBoneTextureSize;"
,
" mat4 getBoneMatrix( const in float i ) {"
,
" mat4 getBoneMatrix( const in float i ) {"
,
" float j = i * 4.0;"
,
" float j = i * 4.0;"
,
...
...
src/glCore/shader/compileProgram.ts
View file @
736eac75
...
@@ -63,7 +63,8 @@ var compileShader = function (gl:WebGLRenderingContext, type:number, src:string)
...
@@ -63,7 +63,8 @@ var compileShader = function (gl:WebGLRenderingContext, type:number, src:string)
gl
.
compileShader
(
shader
);
gl
.
compileShader
(
shader
);
if
(
!
gl
.
getShaderParameter
(
shader
,
gl
.
COMPILE_STATUS
))
{
if
(
!
gl
.
getShaderParameter
(
shader
,
gl
.
COMPILE_STATUS
))
{
console
.
log
(
gl
.
getShaderInfoLog
(
shader
));
console
.
error
(
src
);
console
.
error
(
gl
.
getShaderInfoLog
(
shader
));
return
null
;
return
null
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment