MotoGP: road reflections

本文详细介绍了如何通过简单的几何翻转技术,在摩托车比赛中实现实时水面反射,提升湿滑赛道的视觉表现。通过调整相机位置、高度及倾斜角度,以及在特定条件下淡出反射,实现了既不降低帧率又不重复绘制环境的效果。同时,通过增加水面纹理的不均匀性,模拟真实的水坑和水流,使整个赛道表面不再均匀光亮,进一步增强了真实感。

MotorGP路面反射采用的也是屏幕空间的反射,对原始的屏幕空间反射做了一些修改,对于摩托车还是按照真实物体的低精度模型进行渲染,树和远处的物体都是直接flip了一下,简单粗暴,效果也很不错。过几天下个MotorGP研究一下,应该和wow的方法很接近。

My final task on the quest for wet weather was figuring out what to do with the road surface. When roads get wet, they become reflective. It was particularly important to reflect the bikes, because we disabled shadows during wet races. Without either shadows or reflections, there would be nothing to tie the bikes to the ground, which can create a disturbing illusion where things appear to be floating in the air. But we also wanted to reflect the sky and surrounding scenery such as trees, buildings, and bridges.

Reflections are easy to implement. Mirror your geometry through the ground plane, then draw everything a second time, upside down.

Hang on a moment...

"Draw everything a second time"?  You're kidding, right?  :-) 

No way could I afford to draw the environment twice, even using simplified lower detail models. I had enough GPU juice to reflect the bikes and riders, but not enough for other scenery.

I was on the verge of giving up when I took a final look through our wet road reference photos, and had a crazy idea. I saw a tree, plus an upside down reflection of that same tree. If I had to recreate this in Photoshop, I'd just duplicate the tree image onto a second layer, then vertically flip it.

Surely not... That's way too simple and fundamentally mathematically wrong to have any chance of working in a 3D game...

I tested my theory in Photoshop by taking a photo of a sunny race, selecting the trees and buildings, and mirroring them onto a second layer.

Wow, that works surprisingly well! Not perfect, but promising. Let's see if I can cover up the flaws well enough to make this technique usable in practice...

Creating reflections by mirroring in 2D is only correct if the perspective vanishing point is the same as the ground plane:

  1. The ground must be flat
  2. The camera must be sitting on the ground
  3. The camera must be facing parallel to the ground

These things were not true in MotoGP, but they were close to being true:

  1. The ground was roughly flat, at least most of the time
  2. Cameras were rarely more than head height above the ground
  3. Cameras tended to face roughly forward

For the rare cases where this approximation went badly wrong, I wrote code to detect and fix the situation:

  1. If you were anywhere near a hill, I faded out the reflections (I told myself this was a feature, not a bug, because water flows downhill, so hills would naturally be less wet and therefore less shiny :-)
  2. If the camera was too high above the ground, I faded out the reflections
  3. If the camera was not parallel to the ground, I faded out the reflections (again not a bug! one could argue this was a crude approximation of Fresnel reflection)

Yee haw! Things are starting to look pretty darn good. But still not good enough...

Reflections of distant objects looked great, but the closer something was to the road surface, the more obvious the errors became. If an object was touching the road, it would look terrible if its reflection was even slightly wrong (for instance if the reflection of a bike wheel did not exactly join up with the original wheel).

Solution? Draw proper upside down bike reflections, to make sure they are in exactly the right place. Use the 2D vertical flip approximation for distant trees and buildings. Ask the artists to mark any pieces of scenery that are too close for this approximation to look good, and just leave those objects out of the reflection. For instance these trees are reflected in the road, but the blue and white crash barrier is not:

 image

Final algorithm:

  • Draw sky
  • Draw reflectable parts of the scenery
  • Copy backbuffer to reflection rendertarget, flipping it vertically
  • Fade rendertarget to grey if camera is near a hill, too high, or at too much of an angle
  • Draw bike and rider reflections to the rendertarget, using low detail models
  • Draw road surface to the main backbuffer, using a projective texturing shader that blends the road texture with the reflection image from the rendertarget
  • Draw non-reflectable scenery, bikes, riders, etc.

By stubbornly ignoring the fact that this technique was fundamentally bogus and incorrect, we achieved detailed reflections of sky and scenery, without having to sacrifice framerate and render everything twice:

image

Final problem: it looked too smooth and glassy, more like a mirror than a racetrack. So the artists drew a mottled pattern in the alpha channel of the road texture, and I changed the pixel shader to make this alpha data vary the amount of reflection for each pixel. This created the illusion of puddles, rivulets, etc, so the entire road surface was no longer equally shiny. By varying the alpha pattern, we could add variety and make the reflections look different from one track to another.

And that's all I have to say about wet weather effects. Putting it all together, here is the combined result of fogspray+wakesraindrops, and reflections:

image

Of course, technology has moved on since 2002. I highly recommend this paper by Natalya Tatarchuk, which applies 2006 era hardware to a similar set of problems.

内容概要:本文档是一份关于交换路由配置的学习笔记,系统地介绍了网络设备的远程管理、交换机与路由器的核心配置技术。内容涵盖Telnet、SSH、Console三种远程控制方式的配置方法;详细讲解了VLAN划分原理及Access、Trunk、Hybrid端口的工作机制,以及端口镜像、端口汇聚、端口隔离等交换技术;深入解析了STP、MSTP、RSTP生成树协议的作用与配置步骤;在路由部分,涵盖了IP地址配置、DHCP服务部署(接口池与全局池)、NAT转换(静态与动态)、静态路由、RIP与OSPF动态路由协议的配置,并介绍了策略路由和ACL访问控制列表的应用;最后简要说明了华为防火墙的安全区域划分与基本安全策略配置。; 适合人群:具备一定网络基础知识,从事网络工程、运维或相关技术岗位1-3年的技术人员,以及准备参加HCIA/CCNA等认证考试的学习者。; 使用场景及目标:①掌握企业网络中常见的交换与路由配置技能,提升实际操作能力;②理解VLAN、STP、OSPF、NAT、ACL等核心技术原理并能独立完成中小型网络搭建与调试;③通过命令示例熟悉华为设备CLI配置逻辑,为项目实施和故障排查提供参考。; 阅读建议:此笔记以实用配置为主,建议结合模拟器(如eNSP或Packet Tracer)动手实践每一条命令,对照拓扑理解数据流向,重点关注VLAN间通信、路由选择机制、安全策略控制等关键环节,并注意不同设备型号间的命令差异。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值