Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
n5
URasterizer
提交
9890554b
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,发现更多精彩内容 >>
提交
9890554b
编写于
3月 23, 2022
作者:
H
happyfire
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* small fix for viewport transform
上级
65ffb590
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
13 deletion
+14
-13
URasterizer/Assets/URasterizer/Codes/CPURasterizer/CPURasterizer.cs
...r/Assets/URasterizer/Codes/CPURasterizer/CPURasterizer.cs
+4
-4
URasterizer/Assets/URasterizer/Codes/GPURasterizer/Shaders/URComputeShader.compute
...rizer/Codes/GPURasterizer/Shaders/URComputeShader.compute
+2
-2
URasterizer/Assets/URasterizer/Codes/JobRasterizer/TriangleJob.cs
...zer/Assets/URasterizer/Codes/JobRasterizer/TriangleJob.cs
+8
-7
未找到文件。
URasterizer/Assets/URasterizer/Codes/CPURasterizer/CPURasterizer.cs
浏览文件 @
9890554b
...
...
@@ -156,7 +156,7 @@ namespace URasterizer
Mesh
mesh
=
ro
.
mesh
;
_matModel
=
ro
.
GetModelMatrix
();
_matModel
=
ro
.
GetModelMatrix
();
Matrix4x4
mvp
=
_matProjection
*
_matView
*
_matModel
;
if
(
_config
.
FrustumCulling
&&
URUtils
.
FrustumCulling
(
mesh
.
bounds
,
mvp
)){
...
...
@@ -248,8 +248,8 @@ namespace URasterizer
for
(
int
k
=
0
;
k
<
3
;
k
++)
{
var
vec
=
v
[
k
];
vec
.
x
=
0.5f
*
_width
*
(
vec
.
x
+
1.0f
);
vec
.
y
=
0.5f
*
_height
*
(
vec
.
y
+
1.0f
);
vec
.
x
=
0.5f
*
(
_width
-
1
)
*
(
vec
.
x
+
1.0f
);
vec
.
y
=
0.5f
*
(
_height
-
1
)
*
(
vec
.
y
+
1.0f
);
//在硬件渲染中,NDC的z值经过硬件的透视除法之后就直接写入到depth buffer了,如果要调整需要在投影矩阵中调整
//由于我们是软件渲染,所以可以在这里调整z值。
...
...
@@ -262,7 +262,7 @@ namespace URasterizer
//但是这么调整后,正好和Unity在DirectX平台的Reverse z一样,让near plane附近的z值的浮点数精度提高。
vec
.
z
=
vec
.
z
*
0.5f
+
0.5f
;
v
[
k
]
=
vec
;
v
[
k
]
=
vec
;
}
Triangle
t
=
new
Triangle
();
...
...
URasterizer/Assets/URasterizer/Codes/GPURasterizer/Shaders/URComputeShader.compute
浏览文件 @
9890554b
...
...
@@ -61,8 +61,8 @@ void TriangleProcess(uint3 id : SV_DispatchThreadID)
for (k = 0; k < 3; k++)
{
float4 vec = v[k];
vec.x = 0.5f *
frameBufferSize.x
* (vec.x + 1.0f);
vec.y = 0.5f *
frameBufferSize.y
* (vec.y + 1.0f);
vec.x = 0.5f *
(frameBufferSize.x - 1)
* (vec.x + 1.0f);
vec.y = 0.5f *
(frameBufferSize.y - 1)
* (vec.y + 1.0f);
//在硬件渲染中,NDC的z值经过硬件的透视除法之后就直接写入到depth buffer了,如果要调整需要在投影矩阵中调整
//由于我们是软件渲染,所以可以在这里调整z值。
...
...
URasterizer/Assets/URasterizer/Codes/JobRasterizer/TriangleJob.cs
浏览文件 @
9890554b
...
...
@@ -82,17 +82,18 @@ namespace URasterizer
// ------- Viewport Transform ----------
//NDC to screen space
{
v0
.
x
=
0.5f
*
screenWidth
*
(
v0
.
x
+
1.0f
);
v0
.
y
=
0.5f
*
screenHeight
*
(
v0
.
y
+
1.0f
);
int
max_w
=
screenWidth
-
1
;
int
max_h
=
screenHeight
-
1
;
v0
.
x
=
0.5f
*
max_w
*
(
v0
.
x
+
1.0f
);
v0
.
y
=
0.5f
*
max_h
*
(
v0
.
y
+
1.0f
);
v0
.
z
=
v0
.
z
*
0.5f
+
0.5f
;
v1
.
x
=
0.5f
*
screenWidth
*
(
v1
.
x
+
1.0f
);
v1
.
y
=
0.5f
*
screenHeight
*
(
v1
.
y
+
1.0f
);
v1
.
x
=
0.5f
*
max_w
*
(
v1
.
x
+
1.0f
);
v1
.
y
=
0.5f
*
max_h
*
(
v1
.
y
+
1.0f
);
v1
.
z
=
v1
.
z
*
0.5f
+
0.5f
;
v2
.
x
=
0.5f
*
screenWidth
*
(
v2
.
x
+
1.0f
);
v2
.
y
=
0.5f
*
screenHeight
*
(
v2
.
y
+
1.0f
);
v2
.
x
=
0.5f
*
max_w
*
(
v2
.
x
+
1.0f
);
v2
.
y
=
0.5f
*
max_h
*
(
v2
.
y
+
1.0f
);
v2
.
z
=
v2
.
z
*
0.5f
+
0.5f
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录