我是VisualGMQ,一个游戏开发新手
- 🔭 目前在中国杭州,从事游戏开发相关工作
- 🌱 会一些Vulkan。沉浸于游戏引擎开发和游戏开发
- 💻 用的最多的语言是,这里是我的一些项目:
- gecs:C++17 ECS框架,源码借鉴EnTT,API设计借鉴Bevy
- mirrow:C++17 模板元编程框架,含有静态/动态反射和自动序列化功能
- rs-cpurenderer:使用rust编写的软渲染
- NickelEngine:C++17,基于ECS的游戏引擎(施工中)
a cpu/gpu soft renderer in rust
我是VisualGMQ,一个游戏开发新手
impl PureElemImage<f32> {
pub fn new(w: u32, h: u32) -> Self {
Self {
data: vec![std::f32::MAX; (w * h) as usize],
w,
h,
}
}
我理解的应该是看向Z的负方向,z值越大离相机越近(renderer.rs
中深度测试也是保留深度大的值)。
if depth_attachment.get(x, y) <= z {
let mut attr = vertex.attributes;
shader::attributes_foreach(&mut attr, |value| value * z);
// call pixel shading function to get shading color
let color = shading(&vertex.attributes, uniforms, texture_storage);
color_attachment.set(x, y, &color);
depth_attachment.set(x, y, z);
}
那么初始值是否应该被设置为浮点最小值?(cpu_renderer.rs
和gpu_renderer.rs
中的clear_depth也是这么做的)。
fn clear_depth(&mut self) {
self.depth_attachment.clear(f32::MIN);
}
// camera.rs
mpl Frustum {
#[rustfmt::skip]
pub fn new(near: f32, far: f32, aspect: f32, fovy: f32) -> Self {
// ...
} else { // when in GPU, [we use opengl matrix](http://www.songho.ca/opengl/gl_projectionmatrix.html)
let half_w = near * fovy.tan();
let half_h = half_w / aspect;
let near = near.abs();
let far = far.abs();
// with far plane, clamp x,y,z in [-1, 1]
math::Mat4::from_row(&[
near / half_w, 0.0, 0.0, 0.0,
0.0, near / half_h, 0.0, 0.0,
0.0, 0.0, far + near / (near - far), 2.0 * far * near / (near - far),
0.0, 0.0, -1.0, 0.0,
])
请问第三行第三列是否应该是(far + near) / (near - far)?
pub fn inverse(&self) -> Quaternion {
self.conjugate() / self.length()
}
是不是应该为self.conjugate() / self.length_square()
?
if outcode & TOP != 0 {
// 这里是不是应该为 p.x = pt1.x + (pt2.x - pt1.x) * (rect_max.y - pt1.y) / (pt2.y - pt1.y);
p.x = p1.x + (pt2.x - pt1.x) * (rect_max.y - pt1.y) / (pt2.y - pt1.y);
p.y = rect_max.y;
} else if outcode & BOTTOM != 0 {
// 这里是不是应该为 p.x = pt1.x + (pt2.x - pt1.x) * (rect_min.y - pt1.y) / (pt2.y - pt1.y);
p.x = p1.x + (pt2.x - pt1.x) * (rect_min.y - pt1.y) / (pt2.y - pt1.y);
p.y = rect_min.y;
} else if outcode & RIGHT != 0 {
p.y = pt1.y + (pt2.y - pt1.y) * (rect_max.x - pt1.x) / (pt2.x - pt1.x);
p.x = rect_max.x;
} else if outcode & LEFT != 0 {
p.y = pt1.y + (pt2.y - pt1.y) * (rect_min.x - pt1.x) / (pt2.x - pt1.x);
p.x = rect_min.x;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.