Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
n5
URasterizer
提交
3815b57d
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 搜索 >>
提交
3815b57d
编写于
3月 09, 2022
作者:
H
happyfire
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
+ FPS Display
- Optimize for Test in triangle
上级
4b4b101f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
83 addition
and
6 deletion
+83
-6
URasterizer/Assembly-CSharp.csproj
URasterizer/Assembly-CSharp.csproj
+2
-1
URasterizer/Assets/Samples/Scenes/URasterizerScene.unity
URasterizer/Assets/Samples/Scenes/URasterizerScene.unity
+16
-0
URasterizer/Assets/URasterizer/Codes/FPSDisplay.cs
URasterizer/Assets/URasterizer/Codes/FPSDisplay.cs
+46
-0
URasterizer/Assets/URasterizer/Codes/FPSDisplay.cs.meta
URasterizer/Assets/URasterizer/Codes/FPSDisplay.cs.meta
+11
-0
URasterizer/Assets/URasterizer/Codes/Rasterizer.cs
URasterizer/Assets/URasterizer/Codes/Rasterizer.cs
+8
-5
未找到文件。
URasterizer/Assembly-CSharp.csproj
浏览文件 @
3815b57d
...
...
@@ -37,6 +37,7 @@
</PropertyGroup>
<ItemGroup>
<Compile
Include=
"Assets\URasterizer\Codes\HandmakeMesh.cs"
/>
<Compile
Include=
"Assets\URasterizer\Codes\ProfileManager.cs"
/>
<Compile
Include=
"Assets\URasterizer\Codes\FragmentShader.cs"
/>
<Compile
Include=
"Assets\URasterizer\Codes\RenderingObject.cs"
/>
<Compile
Include=
"Assets\URasterizer\Codes\VertexColors.cs"
/>
...
...
@@ -46,7 +47,7 @@
<Compile
Include=
"Assets\URasterizer\Codes\Triangle.cs"
/>
<Compile
Include=
"Assets\URasterizer\Codes\Rasterizer.cs"
/>
<Compile
Include=
"Assets\URasterizer\Codes\TransformTool.cs"
/>
<Compile
Include=
"Assets\URasterizer\Codes\
ProfileManager
.cs"
/>
<Compile
Include=
"Assets\URasterizer\Codes\
FPSDisplay
.cs"
/>
<None
Include=
"Assets\URasterizer\DefaultShader.shader"
/>
<None
Include=
"Assets\URasterizer\URComputeShader.compute"
/>
<Reference
Include=
"UnityEngine"
>
...
...
URasterizer/Assets/Samples/Scenes/URasterizerScene.unity
浏览文件 @
3815b57d
...
...
@@ -324,6 +324,7 @@ GameObject:
-
component
:
{
fileID
:
264331599
}
-
component
:
{
fileID
:
264331601
}
-
component
:
{
fileID
:
264331598
}
-
component
:
{
fileID
:
264331602
}
m_Layer
:
0
m_Name
:
Main Camera
m_TagString
:
MainCamera
...
...
@@ -417,6 +418,21 @@ MonoBehaviour:
rawImg
:
{
fileID
:
129304943
}
_mainLight
:
{
fileID
:
1933767905
}
_config
:
{
fileID
:
11400000
,
guid
:
18e833324d51d904aa0c708c8c56856c
,
type
:
2
}
---
!u!114
&264331602
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
:
64bca05a011e9854ca73cf4ae054dad6
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
SampleTime
:
0.5
FontSize
:
20
TextColor
:
{
r
:
0
,
g
:
1
,
b
:
0.33849406
,
a
:
1
}
---
!u!1
&666679034
GameObject
:
m_ObjectHideFlags
:
0
...
...
URasterizer/Assets/URasterizer/Codes/FPSDisplay.cs
0 → 100644
浏览文件 @
3815b57d
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
UnityEngine.UI
;
public
class
FPSDisplay
:
MonoBehaviour
{
public
float
SampleTime
=
1f
;
public
int
FontSize
=
20
;
public
Color
TextColor
=
Color
.
white
;
GUIStyle
style
;
int
frameCount
;
float
timeTotal
;
string
textDisplay
;
void
Awake
(){
style
=
new
GUIStyle
();
style
.
fontSize
=
FontSize
;
style
.
normal
.
textColor
=
TextColor
;
}
void
Start
()
{
frameCount
=
0
;
timeTotal
=
0
;
textDisplay
=
""
;
}
void
Update
(){
++
frameCount
;
timeTotal
+=
Time
.
unscaledDeltaTime
;
if
(
timeTotal
>=
SampleTime
){
float
fps
=
frameCount
/
timeTotal
;
textDisplay
=
$"FPS:
{
fps
.
ToString
(
"F2"
)}
"
;
frameCount
=
0
;
timeTotal
=
0
;
}
}
void
OnGUI
(){
GUI
.
Label
(
new
Rect
(
10
,
10
,
200
,
100
),
textDisplay
,
style
);
}
}
URasterizer/Assets/URasterizer/Codes/FPSDisplay.cs.meta
0 → 100644
浏览文件 @
3815b57d
fileFormatVersion: 2
guid: 64bca05a011e9854ca73cf4ae054dad6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
URasterizer/Assets/URasterizer/Codes/Rasterizer.cs
浏览文件 @
3815b57d
...
...
@@ -251,9 +251,9 @@ namespace URasterizer
outBuffer
.
GetData
(
vsOutput
);
vertexBuffer
.
Dispo
se
();
normalBuffer
.
Dispo
se
();
outBuffer
.
Dispo
se
();
vertexBuffer
.
Relea
se
();
normalBuffer
.
Relea
se
();
outBuffer
.
Relea
se
();
ProfileManager
.
EndSample
();
}
...
...
@@ -647,13 +647,16 @@ namespace URasterizer
{
for
(
int
x
=
minPX
;
x
<
maxPX
;
++
x
)
{
if
(
IsInsideTriangle
(
x
,
y
,
t
))
//if(IsInsideTriangle(x, y, t)) //-->检测是否在三角形内比使用重心坐标检测要慢,因此先计算重心坐标,再检查3个坐标是否有小于0
{
//计算重心坐标
var
c
=
ComputeBarycentric2D
(
x
,
y
,
t
);
float
alpha
=
c
.
x
;
float
beta
=
c
.
y
;
float
gamma
=
c
.
z
;
if
(
alpha
<
0
||
beta
<
0
||
gamma
<
0
){
continue
;
}
//透视校正插值,z为透视校正插值后的view space z值
float
z
=
1.0f
/
(
alpha
/
v
[
0
].
w
+
beta
/
v
[
1
].
w
+
gamma
/
v
[
2
].
w
);
//zp为透视校正插值后的screen space z值
...
...
@@ -795,7 +798,7 @@ namespace URasterizer
float
c1
=
(
x
*
(
v
[
1
].
y
-
v
[
2
].
y
)
+
(
v
[
2
].
x
-
v
[
1
].
x
)
*
y
+
v
[
1
].
x
*
v
[
2
].
y
-
v
[
2
].
x
*
v
[
1
].
y
)
/
(
v
[
0
].
x
*
(
v
[
1
].
y
-
v
[
2
].
y
)
+
(
v
[
2
].
x
-
v
[
1
].
x
)
*
v
[
0
].
y
+
v
[
1
].
x
*
v
[
2
].
y
-
v
[
2
].
x
*
v
[
1
].
y
);
float
c2
=
(
x
*
(
v
[
2
].
y
-
v
[
0
].
y
)
+
(
v
[
0
].
x
-
v
[
2
].
x
)
*
y
+
v
[
2
].
x
*
v
[
0
].
y
-
v
[
0
].
x
*
v
[
2
].
y
)
/
(
v
[
1
].
x
*
(
v
[
2
].
y
-
v
[
0
].
y
)
+
(
v
[
0
].
x
-
v
[
2
].
x
)
*
v
[
1
].
y
+
v
[
2
].
x
*
v
[
0
].
y
-
v
[
0
].
x
*
v
[
2
].
y
);
float
c3
=
(
x
*
(
v
[
0
].
y
-
v
[
1
].
y
)
+
(
v
[
1
].
x
-
v
[
0
].
x
)
*
y
+
v
[
0
].
x
*
v
[
1
].
y
-
v
[
1
].
x
*
v
[
0
].
y
)
/
(
v
[
2
].
x
*
(
v
[
0
].
y
-
v
[
1
].
y
)
+
(
v
[
1
].
x
-
v
[
0
].
x
)
*
v
[
2
].
y
+
v
[
0
].
x
*
v
[
1
].
y
-
v
[
1
].
x
*
v
[
0
].
y
);
ProfileManager
.
EndSample
();
return
new
Vector3
(
c1
,
c2
,
c3
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录