path tracer 3D 模型图渲染开源项目

我要开发同款
匿名用户2015年03月05日
58阅读
所属分类Google Go、程序开发、3D图形处理库
授权协议MIT

作品详情

pt是用Go语言实现的pathtracer用于渲染各种3D模型图。

特征

支持OBJ和STL支持纹理,凹凸贴图和法线贴图支持有符号距离场的光线行进支持从图像切片进行体积渲染支持各种材料特性支持可配置的景深支持迭代渲染支持自适应采样和萤火虫减少使用KD树加速射线相交测试并行使用所有CPU内核100%纯净的Go,除了标准库外没有依赖项

示例代码:

package mainimport (    "log"    "github.com/fogleman/pt/pt")func main() {    scene := pt.Scene{}    wall := pt.SpecularMaterial(pt.HexColor(0xFCFAE1), 2)    scene.Add(pt.NewSphere(pt.Vector{4, 7, 3}, 2, pt.LightMaterial(pt.Color{1, 1, 1}, 1, pt.NoAttenuation)))    scene.Add(pt.NewCube(pt.Vector{-30, -1, -30}, pt.Vector{-8, 10, 30}, wall))    scene.Add(pt.NewCube(pt.Vector{-30, -1, -30}, pt.Vector{30, 0.376662, 30}, wall))    material := pt.GlossyMaterial(pt.Color{}, 1.5, pt.Radians(30))    mesh, err := pt.LoadOBJ("examples/gopher.obj", material)    if err != nil {        log.Fatalln("LoadOBJ error:", err)    }    mesh.SmoothNormals()    scene.Add(mesh)    camera := pt.LookAt(pt.Vector{8, 3, 0.5}, pt.Vector{-1, 2.5, 0.5}, pt.Vector{0, 1, 0}, 45)    pt.IterativeRender("out%03d.png", 10, &scene, &camera, 2560/4, 1440/4, -1, 16, 4)}

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论