Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
n5
URasterizer
提交
dc6025c2
URasterizer
项目概览
n5
/
URasterizer
通知
21
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
URasterizer
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
dc6025c2
编写于
1月 29, 2022
作者:
H
happyfire
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
vertex shader
stat
上级
c265fe7b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
163 addition
and
41 deletion
+163
-41
URasterizer/Assets/Samples/Scenes/URasterizerScene.unity
URasterizer/Assets/Samples/Scenes/URasterizerScene.unity
+113
-18
URasterizer/Assets/URasterizer/Codes/CameraRenderer.cs
URasterizer/Assets/URasterizer/Codes/CameraRenderer.cs
+6
-1
URasterizer/Assets/URasterizer/Codes/Rasterizer.cs
URasterizer/Assets/URasterizer/Codes/Rasterizer.cs
+38
-14
URasterizer/Assets/URasterizer/Codes/StatsPanel.cs
URasterizer/Assets/URasterizer/Codes/StatsPanel.cs
+6
-8
未找到文件。
URasterizer/Assets/Samples/Scenes/URasterizerScene.unity
浏览文件 @
dc6025c2
...
@@ -316,6 +316,7 @@ GameObject:
...
@@ -316,6 +316,7 @@ GameObject:
-
component
:
{
fileID
:
264331600
}
-
component
:
{
fileID
:
264331600
}
-
component
:
{
fileID
:
264331599
}
-
component
:
{
fileID
:
264331599
}
-
component
:
{
fileID
:
264331601
}
-
component
:
{
fileID
:
264331601
}
-
component
:
{
fileID
:
264331598
}
m_Layer
:
0
m_Layer
:
0
m_Name
:
Main Camera
m_Name
:
Main Camera
m_TagString
:
MainCamera
m_TagString
:
MainCamera
...
@@ -323,6 +324,20 @@ GameObject:
...
@@ -323,6 +324,20 @@ GameObject:
m_NavMeshLayer
:
0
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
m_IsActive
:
1
---
!u!114
&264331598
MonoBehaviour
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
264331597
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
6521a9dfaf0764545a74885d9b664e06
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
TrianglesStat
:
{
fileID
:
1899433435
}
VerticesStat
:
{
fileID
:
1292409240
}
---
!u!20
&264331599
---
!u!20
&264331599
Camera
:
Camera
:
m_ObjectHideFlags
:
0
m_ObjectHideFlags
:
0
...
@@ -354,7 +369,7 @@ Camera:
...
@@ -354,7 +369,7 @@ Camera:
m_Depth
:
-1
m_Depth
:
-1
m_CullingMask
:
m_CullingMask
:
serializedVersion
:
2
serializedVersion
:
2
m_Bits
:
4294967295
m_Bits
:
0
m_RenderingPath
:
-1
m_RenderingPath
:
-1
m_TargetTexture
:
{
fileID
:
0
}
m_TargetTexture
:
{
fileID
:
0
}
m_TargetDisplay
:
0
m_TargetDisplay
:
0
...
@@ -667,7 +682,7 @@ Animator:
...
@@ -667,7 +682,7 @@ Animator:
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
963210794
}
m_GameObject
:
{
fileID
:
963210794
}
m_Enabled
:
1
m_Enabled
:
0
m_Avatar
:
{
fileID
:
0
}
m_Avatar
:
{
fileID
:
0
}
m_Controller
:
{
fileID
:
9100000
,
guid
:
a5d59b3801cddbb458d4c0acecdf77ed
,
type
:
2
}
m_Controller
:
{
fileID
:
9100000
,
guid
:
a5d59b3801cddbb458d4c0acecdf77ed
,
type
:
2
}
m_CullingMode
:
0
m_CullingMode
:
0
...
@@ -678,6 +693,85 @@ Animator:
...
@@ -678,6 +693,85 @@ Animator:
m_HasTransformHierarchy
:
1
m_HasTransformHierarchy
:
1
m_AllowConstantClipSamplingOptimization
:
1
m_AllowConstantClipSamplingOptimization
:
1
m_KeepAnimatorControllerStateOnDisable
:
0
m_KeepAnimatorControllerStateOnDisable
:
0
---
!u!1
&1145256121
GameObject
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
serializedVersion
:
6
m_Component
:
-
component
:
{
fileID
:
1145256122
}
-
component
:
{
fileID
:
1145256124
}
-
component
:
{
fileID
:
1145256123
}
m_Layer
:
5
m_Name
:
Text
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!224
&1145256122
RectTransform
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1145256121
}
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0
,
w
:
1
}
m_LocalPosition
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
[]
m_Father
:
{
fileID
:
1958761793
}
m_RootOrder
:
0
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_AnchorMin
:
{
x
:
0
,
y
:
0
}
m_AnchorMax
:
{
x
:
0
,
y
:
0
}
m_AnchoredPosition
:
{
x
:
0
,
y
:
0
}
m_SizeDelta
:
{
x
:
0
,
y
:
30
}
m_Pivot
:
{
x
:
0.5
,
y
:
0.5
}
---
!u!114
&1145256123
MonoBehaviour
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1145256121
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
5f7201a12d95ffc409449d95f23cf332
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
m_Material
:
{
fileID
:
0
}
m_Color
:
{
r
:
0
,
g
:
0.9811321
,
b
:
0.030918626
,
a
:
1
}
m_RaycastTarget
:
1
m_RaycastPadding
:
{
x
:
0
,
y
:
0
,
z
:
0
,
w
:
0
}
m_Maskable
:
1
m_OnCullStateChanged
:
m_PersistentCalls
:
m_Calls
:
[]
m_FontData
:
m_Font
:
{
fileID
:
10102
,
guid
:
0000000000000000e000000000000000
,
type
:
0
}
m_FontSize
:
22
m_FontStyle
:
0
m_BestFit
:
0
m_MinSize
:
2
m_MaxSize
:
40
m_Alignment
:
4
m_AlignByGeometry
:
0
m_RichText
:
1
m_HorizontalOverflow
:
0
m_VerticalOverflow
:
0
m_LineSpacing
:
1
m_Text
:
URasterizer
---
!u!222
&1145256124
CanvasRenderer
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1145256121
}
m_CullTransparentMesh
:
1
---
!u!1
&1292409238
---
!u!1
&1292409238
GameObject
:
GameObject
:
m_ObjectHideFlags
:
0
m_ObjectHideFlags
:
0
...
@@ -708,12 +802,12 @@ RectTransform:
...
@@ -708,12 +802,12 @@ RectTransform:
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
[]
m_Children
:
[]
m_Father
:
{
fileID
:
1958761793
}
m_Father
:
{
fileID
:
1958761793
}
m_RootOrder
:
1
m_RootOrder
:
2
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_AnchorMin
:
{
x
:
0
,
y
:
0
}
m_AnchorMin
:
{
x
:
0
,
y
:
0
}
m_AnchorMax
:
{
x
:
0
,
y
:
0
}
m_AnchorMax
:
{
x
:
0
,
y
:
0
}
m_AnchoredPosition
:
{
x
:
0
,
y
:
0
}
m_AnchoredPosition
:
{
x
:
0
,
y
:
0
}
m_SizeDelta
:
{
x
:
16
0
,
y
:
26.1044
}
m_SizeDelta
:
{
x
:
0
,
y
:
26.1044
}
m_Pivot
:
{
x
:
0.5
,
y
:
0.5
}
m_Pivot
:
{
x
:
0.5
,
y
:
0.5
}
---
!u!114
&1292409240
---
!u!114
&1292409240
MonoBehaviour
:
MonoBehaviour
:
...
@@ -739,10 +833,10 @@ MonoBehaviour:
...
@@ -739,10 +833,10 @@ MonoBehaviour:
m_Font
:
{
fileID
:
10102
,
guid
:
0000000000000000e000000000000000
,
type
:
0
}
m_Font
:
{
fileID
:
10102
,
guid
:
0000000000000000e000000000000000
,
type
:
0
}
m_FontSize
:
20
m_FontSize
:
20
m_FontStyle
:
0
m_FontStyle
:
0
m_BestFit
:
0
m_BestFit
:
1
m_MinSize
:
2
m_MinSize
:
10
m_MaxSize
:
4
0
m_MaxSize
:
2
0
m_Alignment
:
0
m_Alignment
:
3
m_AlignByGeometry
:
0
m_AlignByGeometry
:
0
m_RichText
:
1
m_RichText
:
1
m_HorizontalOverflow
:
0
m_HorizontalOverflow
:
0
...
@@ -964,7 +1058,7 @@ Transform:
...
@@ -964,7 +1058,7 @@ Transform:
m_PrefabAsset
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1825649040
}
m_GameObject
:
{
fileID
:
1825649040
}
m_LocalRotation
:
{
x
:
-0
,
y
:
-0
,
z
:
-0
,
w
:
1
}
m_LocalRotation
:
{
x
:
-0
,
y
:
-0
,
z
:
-0
,
w
:
1
}
m_LocalPosition
:
{
x
:
2
,
y
:
0
,
z
:
0
}
m_LocalPosition
:
{
x
:
-2.43
,
y
:
0
,
z
:
0
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
[]
m_Children
:
[]
m_Father
:
{
fileID
:
963210798
}
m_Father
:
{
fileID
:
963210798
}
...
@@ -1014,12 +1108,12 @@ RectTransform:
...
@@ -1014,12 +1108,12 @@ RectTransform:
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
[]
m_Children
:
[]
m_Father
:
{
fileID
:
1958761793
}
m_Father
:
{
fileID
:
1958761793
}
m_RootOrder
:
0
m_RootOrder
:
1
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_AnchorMin
:
{
x
:
0
,
y
:
0
}
m_AnchorMin
:
{
x
:
0
,
y
:
0
}
m_AnchorMax
:
{
x
:
0
,
y
:
0
}
m_AnchorMax
:
{
x
:
0
,
y
:
0
}
m_AnchoredPosition
:
{
x
:
0
,
y
:
0
}
m_AnchoredPosition
:
{
x
:
0
,
y
:
0
}
m_SizeDelta
:
{
x
:
16
0
,
y
:
30
}
m_SizeDelta
:
{
x
:
0
,
y
:
30
}
m_Pivot
:
{
x
:
0.5
,
y
:
0.5
}
m_Pivot
:
{
x
:
0.5
,
y
:
0.5
}
---
!u!114
&1899433435
---
!u!114
&1899433435
MonoBehaviour
:
MonoBehaviour
:
...
@@ -1045,10 +1139,10 @@ MonoBehaviour:
...
@@ -1045,10 +1139,10 @@ MonoBehaviour:
m_Font
:
{
fileID
:
10102
,
guid
:
0000000000000000e000000000000000
,
type
:
0
}
m_Font
:
{
fileID
:
10102
,
guid
:
0000000000000000e000000000000000
,
type
:
0
}
m_FontSize
:
20
m_FontSize
:
20
m_FontStyle
:
0
m_FontStyle
:
0
m_BestFit
:
0
m_BestFit
:
1
m_MinSize
:
2
m_MinSize
:
10
m_MaxSize
:
4
0
m_MaxSize
:
2
0
m_Alignment
:
0
m_Alignment
:
3
m_AlignByGeometry
:
0
m_AlignByGeometry
:
0
m_RichText
:
1
m_RichText
:
1
m_HorizontalOverflow
:
0
m_HorizontalOverflow
:
0
...
@@ -1186,6 +1280,7 @@ RectTransform:
...
@@ -1186,6 +1280,7 @@ RectTransform:
m_LocalPosition
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_LocalPosition
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Children
:
m_Children
:
-
{
fileID
:
1145256122
}
-
{
fileID
:
1899433434
}
-
{
fileID
:
1899433434
}
-
{
fileID
:
1292409239
}
-
{
fileID
:
1292409239
}
m_Father
:
{
fileID
:
900208196
}
m_Father
:
{
fileID
:
900208196
}
...
@@ -1193,8 +1288,8 @@ RectTransform:
...
@@ -1193,8 +1288,8 @@ RectTransform:
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_AnchorMin
:
{
x
:
1
,
y
:
1
}
m_AnchorMin
:
{
x
:
1
,
y
:
1
}
m_AnchorMax
:
{
x
:
1
,
y
:
1
}
m_AnchorMax
:
{
x
:
1
,
y
:
1
}
m_AnchoredPosition
:
{
x
:
-1
19.32251
,
y
:
-73.23816
}
m_AnchoredPosition
:
{
x
:
-1
29.33313
,
y
:
-69.1431
}
m_SizeDelta
:
{
x
:
2
03.4912
,
y
:
115.5237
}
m_SizeDelta
:
{
x
:
2
23.5125
,
y
:
107.3335
}
m_Pivot
:
{
x
:
0.5
,
y
:
0.5
}
m_Pivot
:
{
x
:
0.5
,
y
:
0.5
}
---
!u!114
&1958761794
---
!u!114
&1958761794
MonoBehaviour
:
MonoBehaviour
:
...
@@ -1217,7 +1312,7 @@ MonoBehaviour:
...
@@ -1217,7 +1312,7 @@ MonoBehaviour:
m_Spacing
:
5
m_Spacing
:
5
m_ChildForceExpandWidth
:
1
m_ChildForceExpandWidth
:
1
m_ChildForceExpandHeight
:
0
m_ChildForceExpandHeight
:
0
m_ChildControlWidth
:
0
m_ChildControlWidth
:
1
m_ChildControlHeight
:
0
m_ChildControlHeight
:
0
m_ChildScaleWidth
:
0
m_ChildScaleWidth
:
0
m_ChildScaleHeight
:
0
m_ChildScaleHeight
:
0
...
...
URasterizer/Assets/URasterizer/Codes/CameraRenderer.cs
浏览文件 @
dc6025c2
...
@@ -65,7 +65,12 @@ namespace URasterizer
...
@@ -65,7 +65,12 @@ namespace URasterizer
Debug
.
Log
(
$"screen size:
{
w
}
x
{
h
}
"
);
Debug
.
Log
(
$"screen size:
{
w
}
x
{
h
}
"
);
_rasterizer
=
new
Rasterizer
(
w
,
h
,
_config
);
_rasterizer
=
new
Rasterizer
(
w
,
h
,
_config
);
rawImg
.
texture
=
_rasterizer
.
texture
;
rawImg
.
texture
=
_rasterizer
.
texture
;
var
statPanel
=
this
.
GetComponent
<
StatsPanel
>();
if
(
statPanel
!=
null
)
{
_rasterizer
.
StatDelegate
+=
statPanel
.
StatDelegate
;
}
}
}
...
...
URasterizer/Assets/URasterizer/Codes/Rasterizer.cs
浏览文件 @
dc6025c2
...
@@ -10,6 +10,8 @@ namespace URasterizer
...
@@ -10,6 +10,8 @@ namespace URasterizer
Depth
=
2
Depth
=
2
}
}
public
delegate
void
OnRasterizerStatUpdate
(
int
verticesAll
,
int
trianglesAll
,
int
trianglesRendered
);
public
class
Rasterizer
public
class
Rasterizer
{
{
int
_width
;
int
_width
;
...
@@ -45,8 +47,11 @@ namespace URasterizer
...
@@ -45,8 +47,11 @@ namespace URasterizer
public
Texture2D
texture
;
public
Texture2D
texture
;
//Stats
//Stats
public
int
Stats_Triangles
;
int
_trianglesAll
,
_trianglesRendered
;
public
int
Stats_Vertices
;
int
_verticesAll
;
public
OnRasterizerStatUpdate
StatDelegate
;
public
Rasterizer
(
int
w
,
int
h
,
RenderingConfig
config
)
public
Rasterizer
(
int
w
,
int
h
,
RenderingConfig
config
)
{
{
...
@@ -104,6 +109,9 @@ namespace URasterizer
...
@@ -104,6 +109,9 @@ namespace URasterizer
{
{
FillArray
(
depth_buf
,
float
.
MaxValue
);
FillArray
(
depth_buf
,
float
.
MaxValue
);
}
}
_trianglesAll
=
_trianglesRendered
=
0
;
_verticesAll
=
0
;
}
}
public
void
SetupViewProjectionMatrix
(
Camera
camera
)
public
void
SetupViewProjectionMatrix
(
Camera
camera
)
...
@@ -135,28 +143,37 @@ namespace URasterizer
...
@@ -135,28 +143,37 @@ namespace URasterizer
Matrix4x4
mvp
=
_matProjection
*
_matView
*
_matModel
;
Matrix4x4
mvp
=
_matProjection
*
_matView
*
_matModel
;
_verticesAll
+=
mesh
.
vertexCount
;
_trianglesAll
+=
mesh
.
triangles
.
Length
/
3
;
//Unity模型本地坐标系也是左手系,需要转成我们使用的右手系
//1. z轴反转
//2. 三角形顶点环绕方向从顺时针改成逆时针
//vertex shader
Vector4
[]
csVertices
=
new
Vector4
[
mesh
.
vertexCount
];
//clip space vertices
for
(
int
i
=
0
;
i
<
mesh
.
vertexCount
;
++
i
)
{
var
vert
=
mesh
.
vertices
[
i
];
csVertices
[
i
]
=
mvp
*
new
Vector4
(
vert
.
x
,
vert
.
y
,
-
vert
.
z
,
1
);
//注意这儿反转了z坐标
}
var
indices
=
mesh
.
triangles
;
var
indices
=
mesh
.
triangles
;
for
(
int
i
=
0
;
i
<
indices
.
Length
;
i
+=
3
)
for
(
int
i
=
0
;
i
<
indices
.
Length
;
i
+=
3
)
{
{
//Unity模型本地坐标系也是左手系,需要转成我们使用的右手系
//1. z轴反转
//2. 三角形顶点环绕方向从顺时针改成逆时针
//注意这儿对调了v0和v1的索引,因为原来的 0,1,2是顺时针的,对调后是 1,0,2是逆时针的
//注意这儿对调了v0和v1的索引,因为原来的 0,1,2是顺时针的,对调后是 1,0,2是逆时针的
//Unity Quard模型的两个三角形索引分别是 0,3,1,3,0,2 转换后为 3,0,1,0,3,2
//Unity Quard模型的两个三角形索引分别是 0,3,1,3,0,2 转换后为 3,0,1,0,3,2
int
idx0
=
indices
[
i
+
1
];
int
idx0
=
indices
[
i
+
1
];
int
idx1
=
indices
[
i
];
int
idx1
=
indices
[
i
];
int
idx2
=
indices
[
i
+
2
];
int
idx2
=
indices
[
i
+
2
];
//vertex shader
//world to clip space
Vector4
[]
v
=
Vector4
[]
v
=
{
{
mvp
*
new
Vector4
(
mesh
.
vertices
[
idx0
].
x
,
mesh
.
vertices
[
idx0
].
y
,
-
mesh
.
vertices
[
idx0
].
z
,
1
),
//注意这儿反转了z坐标
csVertices
[
idx0
],
mvp
*
new
Vector4
(
mesh
.
vertices
[
idx1
].
x
,
mesh
.
vertices
[
idx1
].
y
,
-
mesh
.
vertices
[
idx1
].
z
,
1
)
,
csVertices
[
idx1
]
,
mvp
*
new
Vector4
(
mesh
.
vertices
[
idx2
].
x
,
mesh
.
vertices
[
idx2
].
y
,
-
mesh
.
vertices
[
idx2
].
z
,
1
),
csVertices
[
idx2
]
};
};
...
@@ -189,6 +206,8 @@ namespace URasterizer
...
@@ -189,6 +206,8 @@ namespace URasterizer
}
}
}
}
++
_trianglesRendered
;
//NDC to screen space, viewport transform
//NDC to screen space, viewport transform
for
(
int
k
=
0
;
k
<
3
;
k
++)
for
(
int
k
=
0
;
k
<
3
;
k
++)
...
@@ -517,6 +536,11 @@ namespace URasterizer
...
@@ -517,6 +536,11 @@ namespace URasterizer
{
{
texture
.
SetPixels
(
frame_buf
);
texture
.
SetPixels
(
frame_buf
);
texture
.
Apply
();
texture
.
Apply
();
if
(
StatDelegate
!=
null
)
{
StatDelegate
(
_verticesAll
,
_trianglesAll
,
_trianglesRendered
);
}
}
}
...
...
URasterizer/Assets/URasterizer/Codes/StatsPanel.cs
浏览文件 @
dc6025c2
using
System.Collections
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
UnityEngine
;
using
UnityEngine.UI
;
public
class
StatsPanel
:
MonoBehaviour
public
class
StatsPanel
:
MonoBehaviour
{
{
// Start is called before the first frame update
public
Text
TrianglesStat
;
void
Start
()
public
Text
VerticesStat
;
{
}
// Update is called once per frame
public
void
StatDelegate
(
int
vertices
,
int
triangles
,
int
trianglesRendered
)
void
Update
()
{
{
TrianglesStat
.
text
=
$"Triangles:
{
trianglesRendered
}
/
{
triangles
}
"
;
VerticesStat
.
text
=
$"Vertices:
{
vertices
}
"
;
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录