基于unity自己写光追。

前几天写的博客好像访问量多了不少。

最近听到裁员的消息挺多的。但是貌似搞unity的找工作还行。

毕竟从事这个的相对少一点。前些年互联网大热,大家都一窝蜂的去学java,后台,前端这个那个的。你看现在人才冗余了吧,所以还是搞点冷门的专业比较好,不要凑热闹。

曾国藩说过,众驶之地勿往。

---------------------------------------------------------------------------------

闲聊到此结束。

最近工作关系,需要用unity实现光追效果。

调研了一下,有3种方案。

第一种:参考shadertoy那种raymarching。场景模型通过sdf来描述。一般的mesh模型,需要转换为sdf的方式来描述,就比较麻烦了。还要单独写转换算法。从shadertoy上可以搬运很多酷炫的效果移植到unity里。不过webgl的shader是glsl语法,需要转换为hlsl。有很多注意的地方。最好用宏定义来解决。执行效率好像不太高,尤其是分辨率较高,且sdf函数复杂的模型,会掉帧比较严重。

第二种:通过computeshader来实现光追算法。这个一般也是参数化矢量模型可以用。也就是通过函数描述的比如球体,立方体之类的,可以直接用公式求取解析解,不需要递归搜索。而任意模型的渲染还需要自己编写BVH加速结构,做线碰撞计算。这个方法好处是不一定非得要支持RTX的显卡,通用性比较高,但是得需要computeshader的支持。

第三种:通过DX12的DXR,也就是unity里的HDRP自带的Raytracing shader。硬加速的,执行效率比较高。编写代码也比较简单。BVH加速结构也可以调用api搞定,相当好用。缺点是需要RTX显卡的支持。通用性不够。

所以针对不同场景,你得斟酌考虑用哪种方案。

For those that do not know me: My name is Jacco Bikker, also known as 'Phantom'. I work as '3D tech guy' at Overloaded, a company that develops and distributes games for mobile phones. I specialize at 3D Symbian games, which require highly optimized fixed-point, non-HW-accelerated 3D engines, crammed into 250Kb installers. So basically I'm having fun. As software rendering used to be my spare time activity, I was looking for something else. I tried some AI, which was great fun, and recently I dove into a huge pile of research papers on raytracing and related topics; such as global illumination, image based lighting, photon maps and so on. One document especially grabbed my attention. It's titled: "State-of-the-Art in Interactive Ray Tracing", and was written by Wald & Slusallek. I highly recommend this paper. Basically, it summarizes recent efforts to improve the speed of raytracing, and adds a couple of tricks too. But it starts with a list of benefits of raytracing over rasterization-based algorithms. And one of those benefits is that when you go to extremes, raytracing is actually faster than rasterizing. And they prove it: Imagine a huge scene, consisting of, say, 50 million triangles. Toss it at a recent GeForce with enough memory to store all those triangles, and write down the frame rate. It will be in the vicinity of 2-5. If it isn't, double the triangle count. Now, raytrace the same scene. These guys report 8 frames per second on a dual PIII/800. Make that a quad PIII/800 and the speed doubles. Raytracing scales linearly with processing power, but only logarithmically with scene complexity. Now that I got your attention, I would like to move on to the intended contents of this crash course in raytracing.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值