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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
未来社区的建设背景和需求分析指出,随着智能经济、大数据、人工智能、物联网、区块链、云计算等技术的发展,社区服务正朝着数字化、智能化转型。社区服务渠道由分散向统一融合转变,服务内容由通用庞杂向个性化、服务导向转变。未来社区将构建数字化生态,实现数据在线、组织在线、服务在线、产品智能和决策智能,赋能企业创新,同时注重人才培养和科研平台建设。 规划设计方面,未来社区将基于居民需求,打造以服务为中心的社区管理模式。通过统一的服务平台和应用,实现服务内容的整合和优化,提供灵活多样的服务方式,如推送式、订阅式、热点式等。社区将构建数据与应用的良性循环,提高服务效率,同时注重生态优美、绿色低碳、社会和谐,以实现幸福民生和产业发展。 建设运营上,未来社区强调科学规划、以人为本,创新引领、重点突破,统筹推进、整体提升。通过实施院落+社团自治工程,转变政府职能,深化社区自治法制化、信息化,解决社区治理中的重点问题。目标是培养有活力的社会组织,提高社区居民参与度和满意度,实现社区治理服务的制度机制创新。 未来社区的数字化解决方案包括信息发布系统、服务系统和管理系统。信息发布系统涵盖公共服务类和社会化服务类信息,提供政策宣传、家政服务、健康医疗咨询等功能。服务系统功能需求包括办事指南、公共服务、社区工作参与互动等,旨在提高社区服务能力。管理系统功能需求则涉及院落管理、社团管理、社工队伍管理等,以实现社区治理的现代化。 最后,未来社区建设注重整合政府、社会组织、企业等多方资源,以提高社区服务的效率和质量。通过建立社区管理服务综合信息平台,提供社区公共服务、社区社会组织管理服务和社区便民服务,实现管理精简、高效、透明,服务快速、便捷。同时,通过培育和发展社区协会、社团等组织,激发社会化组织活力,为居民提供综合性的咨询和服务,促进社区的和谐发展。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值