• About
    • Resume
A Game Developer also plays some guitar

Monthly Archives: July 2009

You are browsing the site archives by month.

Unproject

July 30, 2009 11:19 am / 1 Comment / Benny Chen

Unproject即反投影,将一个坐标从投影空间中反投影到视图空间。对于Project操作,很容易,直接用投影矩阵乘以视图空间的坐标即可,即:

posProj = posView * matrixProj

其中设posView = (x, y, z, 1)是视图空间的某一位置点的坐标,posProj = (x’, y’, z’, w’)为投影空间中该点的坐标,matrixProj为投影矩阵。我们知道,因为投影矩阵的特殊性,有w’ = z,即视图空间的深度值存储在投影空间的w值中,这样posPorj的xyz坐标值在除以了w值之后,就有了近大远小的透视效果。注意:只有在除以了w值之后才会有,x’/w’,y’/w’∈[-1,1]且z’/w’∈[0,1],即在那个所谓的半个正方体中了。

那么对于Unproject操作呢,是不是直接posView = posProj * inverse( matrixProj )就可以了呢,如果知道x’y’z’w’值,当然是正确,但关键问题是,大多数情况下,我们所知道的只是x’/w’,y’/w’以及z’/w’的值。

DX提供了一个函数D3DXVec3Unproject,可以做反投影,不过它只能在C++代码里使用(shader里没法使用),而且需要注意的是,这个函数是对屏幕空间的坐标进行的反投影(所以这个函数还需要传入一个viewport参数),务必不要将投影空间的坐标作为参数传递给这个函数。

我需要写一个自己的反投影函数,不妨从上面的这个公式推导:posProj = posView * matrixProj,因为我们现在已知的是x’/w’,y’/w’以及z’/w’的值,不妨设posProj’ = (x’/w’, y’/w’, z’/w’, 1 ),所以这个公式改为:posProj’ * w’ = posView * matrixProj。

因为一般投影矩阵是像这样一种形式:

projmatrix

于是有拆分posProj’ * w’ = posView * matrixProj后,有:

posProj’.x * w’ = posView.x * xScale;
posProj’.y * w’ = posView.y * yScale;
posProj’.z * w’ = posView.z * Q – Q*zn;
w’ = posView.z

上面构成一个方程组,解这个方程组,可得:

posView.z = Q*zn / ( Q – posProj’.z )
posView.x = posView.z * posProj’.x / xScale
posView.y = posView.z * posProj’.y / yScale

至此反投影完毕。

反投影一般比较常见的是在鼠标拾取(picking)的例子中,而那里投影空间的点取的是近屏幕上的点(posProj’.z = 0),因为这样上面的公式就会得到一个比较简化的特例:

posView.z = zn
posView.x = posProj’.x * zn / xScale
posView.y = posProj’.y * zn / yScale

Posted in: Computer Graphics / Tagged: D3DXVec3Unproject, unproject, 投影矩阵, 投影空间, 视图空间

Camp Nou gives Ibrahimovic a hero’s welcome

July 28, 2009 9:01 pm / 1 Comment / Benny Chen

Zlatan Ibrahimovic has been welcomed by a rapturous Camp Nou. The Swedish striker was stunned by such a grand introduction to the club, saying that the only moments of his life to compare with this were the births of his children.

伊布拉希莫维奇在诺坎普受到了如斯疯狂的欢迎。被如此隆重的介绍给俱乐部,这位瑞典前锋也感到受宠若惊,他说,在他的一生中,只有他的孩子出生的时候,才能和此刻相比。

2009-07-27_presentacion_zlatan_ibrahimovic_004No fewer than 60,000 people assembled in the Camp Nou on Monday evening to get their first glimpse of the new Barça centre forward. The Swede was given an enthusiastic welcome by a generally young crowd that enjoyed every second of the presentation.

星期一晚,为了能够尽快目睹这位巴萨新任中锋的风采,至少有6万名球迷涌入了诺坎普体育场。到场的球迷中,大多数都是年轻人,他们享受着当晚的每一秒种,并给予了瑞典人最热烈的欢迎。

Great expectations

Hours before the Camp Nou opened, there were already several fans gathered on the forecourt outside the stadium, all waiting to attend the presentation of the club’s latest acquisition, Ibrahimovic. In fact, the gates had to be opened half an hour before the event commenced in order to avoid a crush as the crowds made their way to the terraces.

The event actually got under way a little later than originally planned, but it was clearly worth the wait when around nine o’clock, the striker finally made his way out onto the pitch for the first time.

巨大的期望

就在体育场还没有开放之前,就已经有一些球迷聚集在场外,他们迫切的等待着参加俱乐部的最新引援伊布的亮相仪式。而事实上,由于大批球迷涌向看台,体育场的大门也不得不在仪式开始前半个小时就开启,以防止拥挤事故的发生。

仪式最终开始的时间比预计晚了一些,但是球迷们的等待绝对是值得的。晚上9点整,瑞典前锋终于首次踏上了诺坎普的球场。

Nine on his back

After an intense day, with two medical revisions and the signing of his contract, Zlatan appeared before the media donning the number nine shirt that is to be his own. With the cameras flashing in the stands and the club anthem playing over the tannoy, the former Inter man impressed onlookers with his juggling skills and returned the applause from the crowd. He also kissed the crest on numerous occasions.

新任9号

这一天的行程对于伊布来说是异常密集的,他首先要接受两个体检,接着需要进行合同的签署,最后才在晚上,身披着即将属于他自己的9号球衣,在诺坎普正式亮相。伴随着看台上此起彼伏的闪光灯拍摄和广播里雄壮的巴萨队歌,伊布用杂耍般的技艺令观众叹为观止,并得到了热烈的掌声。这位瑞典人还数次亲吻了胸前衬衫上的巴萨队徽。

Words of thanks

The Swede then took the mike into his own hands and even said a few words in Catalan: “Gràcies a tots. Visca el Barça!” That worked the crowd up into absolute frenzy, and they immediately responded by chanting his name, with Ibrahimovic responding to such a warm reception by running the whole lap of the pitch, with several fans taking the opportunity to invade the pitch.

感谢之言

接着,伊布接过了麦克风,竟然说上了几句加泰罗尼亚语,这立即引发了球迷的一阵骚动,球场上开始一阵阵的回响起了瑞典人的名字。面对如此这般的热情,伊布也绕场跑动了一周,向场地四周的球迷致以谢意。有几个疯狂的球迷甚至企图冲入场内接近这位国际球星。

I’m the happiest man in the world

After he had left the field, the Swede spoke to Barça TV and www.fcbarcelona.cat in the player’s tunnel to express his thoughts: “There have been two unforgettable moments in my life – the births of my children. Now, this is the third.” Visibly contented and emotional, Ibrahimovic added: “I didn’t expect this. It’s a fantastic feeling. I am the happiest man in the world”.

我是世界上最幸福的人

在离开球场之后,瑞典人在球员通道接受了巴萨TV巴萨官网的采访,他描述了自己的心情:“这一生,只有两个时刻让我难忘,那就是我的孩子出生的时候,但现在,这将是第三个令我终生难忘的时刻。”伊布看上去非常的开心而激动,他继续说道:“这一切太令我意外了,这种感觉太美妙了,此刻我觉得自己是世界上最幸福的人。”

Posted in: Visca Barça / Tagged: barca, Ibrahimovic

Thank you, Samuel

July 27, 2009 10:48 pm / 1 Comment / Benny Chen

The third highest goalscorer in Barça is leaving. But he can walk out the front door after five years at the club, winning almost everything on offer including last year’s memorable treble.

29-05-09_etoo_copas_01他,拥有着巴萨进球数量第3高记录的得分手,不得不和我们说再见了。但是,他绝对可以骄傲的昂首走出巴萨的大门,因为在诺坎普效力的5年里,他几乎为我们赢得了一切,包括上赛季那永恒难忘的三冠王。

It is time to say goodbye and thank you to Samuel. The Cameroonian striker, came to the club from Mallorca and is now headed for Inter Milan. In his five seasons, he has scored 130 official goals, making him the third highest goalscorer the club has ever had. Only César (235) and Kubala (196) top his record.

萨默尔,是时候和说再见了,并送上我们最诚挚的感谢。这位喀麦隆射手,从马洛卡来到了巴萨,而现在,他的下一个目的地将是国际米兰。在巴萨效力的这5个赛季里,他打进了130粒正式入球,这使他成为俱乐部历史上进球数量第3高的球员,仅次于塞萨尔(235)和库巴拉(196)。

Important goals

Eto’o will never be forgotten, not only for his character and dedication, but also his goals, many of which have proven decisive. Whenever called upon, he would respond, as he did in the final in Paris against Arsenal, where he scored the equaliser, or in Rome, where he opened the scoring against Man United (2-0).

重要的入球

埃托奥将被永远载入俱乐部的史册,不仅因为他优秀的个人品质和对俱乐部的孜孜不倦,更因为他所贡献的每一粒宝贵的关键进球。当球队需要他的时候,他总能挺身而出,不管是在巴黎的欧冠决赛赛场(攻入扳平阿森纳的进球),抑或是罗马(打进2:0对曼联的首球)。

Eight titles

Those goals meant two Champions league titles for Barça (2005/06 and 2008/09). But they were not the only wins for Eto’o in his time at the Camp Nou. He was also involved in the conquest of three leagues (2004/05, 2005/06 and 2008/09), a Copa del Rey (2008/09) and two Spanish Super Cups (2005/06 and 2006/07).

On an individual level, he was also top league goalscorer in 2005/06.

八座冠军奖杯

上面的这些关键进球意味着两座冠军联赛的奖杯(05/06和08/09赛季),但还远远不止这些。他还为诺坎普带来了三座联赛冠军(04/05,05/06和08/09赛季),一座国王杯(08/09赛季),以及两座西班牙超级杯(05/06,06/07赛季)。

至于个人荣誉方面,他也获得了05/06赛季的联赛最佳射手。

Setting standards

Samuel Eto’o came to Barça when Frank Rijkaard was manager. He was always a regular starter, playing both midweek and at weekends, and producing a constant flow of goals. He totalled 130 in 200 official outings, and average of 0.65 a match. Whether under Rijkaard or Guardiola, the African was always the main target man for all five years.

树立了旗帜

埃托奥是在里杰卡尔德时期来到了巴萨。不管是在周中还是周末的比赛中,他总是保持着定期的首发出场率,并且保持着持续数量的进球。在200场正式比赛中,他总共打入了130粒入球,场均进球率达到0.65。在这5年里,不管是在里杰卡尔德,还是瓜迪奥拉的执教下,埃托奥都是球队的核心球员。

Exemplary attitude

His goals were the result of his tremendous attitude. He never stop wanting to win more and more. His winning spirit and the huge demands he made of himself drove him though difficult situations, such as serious injuries that affected his seasons in 2006/07 (when he was injured against Bremen) and 2007/08 (when he was injured in the Gamper, against his future club Inter). But on both occasions he marked his return in the best possible way – by scoring goals.

To bid farewell, he also scored for Barça in the Champions League final and in the last game of the league season, at Riazor. Thank you, Samuel.

杰出的态度

他如此之多的进球来源于他对于工作杰出而敬业的态度。他从未停止过追求更多的胜利,他内心对于胜利强烈的渴望驱使着他度过 了一个又一个困境,战胜了困扰他的一个又一个伤病。他曾经先后在06/07赛季对阵不莱梅的比赛中,以及在07/08甘伯杯对阵国际米兰(也是他的未来东家)的比赛中受过重伤。但是,在两次伤愈后,他都用最强力的进球,向世人宣告他的回归。

在即将离开巴萨之际,他也用冠军联赛的入球以及联赛最后一轮在Riazor球场的进球,作了最好的告别。萨默尔,谢谢!

Posted in: Visca Barça / Tagged: barca, eto'o, samuel

Pre-season starts with a draw (1-1)

July 25, 2009 11:31 am / Leave a Comment / Benny Chen

barcelona-tottenham_01Barça drew their first pre-season game of the season against Tottenham Hotspur in the Wembley Cup. Pep Guardiola gave several players a chance to shine and Bojan Krkic scored for the Catalan outfit during the first half of an entertaining encounter.

巴萨在他们新赛季的第一场季前赛——在温布利杯对阵托特纳姆热刺的比赛中,收获了一场平局。在这场有些娱乐性的对抗中,瓜迪奥拉给了好几个球员表现的机会,博扬在上半场为球队取得了进球。

Kicking off the 2009/10 campaign, the Blaugrana produced a positive display in a game that saw them use 22 players as the team that began was completely replaced at half-time. No less than 15 of those players came from the club’s youth system, while Víctor Valdés, Rafa Márquez, Maxwell, Aliaksandr Hleb, Lionel Messi and Thierry Henry watched from the sides as they were not in the squad.

Despite the number of youngsters, Barça showed some great touches and enjoyed their fair share of possession against a Tottenham side that were playing in their fourth first-team friendly of the summer.

在这场拉开2009-10新赛季大幕的比赛中,红蓝军团展现了一种非常积极的面貌。上场比赛的球员一共达到了22人,因为在半场时,所有的 11人都得到了更换。至少有15名球员是来自俱乐部的青训系统,而瓦尔德斯,马奎斯,马克斯维尔,赫莱布,梅西以及亨利这些暂时还没有入队的球员,则直接在看台上观看了这场比赛。

尽管使用了相当多的年轻球员,但在这场与热刺的对抗中,巴萨还是体现了相当强大的触控球能力。这场比赛也是热刺一线队今夏的第四场赛季前热身赛。

Barça style

While the first match of pre-season is usually a casual affair, Barça had little time to settle down as the Wembley Cup ensured that the team faced a stern test and they stood up well. Guardiola’s side maintained their style and system as they played the ball around well in midfield against a side that ensured that their defence was well-manned. Early on there were few chances, but the best came in the 20th minute when Bojan saw his effort tipped wide by Carlo Cudicini in the Tottenham goal.

巴萨风格

虽然季前赛的第一场比赛一般是以一种随意轻松的态度去应战,但对于巴萨来说,时间不允许他们这么做,因为,温布利杯对于球队就是一场严峻的考验。但是他们经受住了考验,比赛中,瓜迪奥拉的球队保持了他们一贯的风格和系统,他们在中场出色的控球很好的遏制了对方,以确保他们防守组织的也很好。开场时,有好几个机会,最好的机会出现在上半场20分钟,博扬的射门被热刺门将库迪奇尼用指尖碰出。

Bojan opens the scoring

The Catalan striker did not allow the keeper to have any chance soon after as the ball fell to him six yards from goal and he stroked home the opening goal. Touré Yaya set up the effort with a super driving run that saw him skip past several Tottenham players before a tackle from Tom Huddlestone took the ball into Bojan’s path. It was the first goal of the pre-season for the Blaugrana and the second could have come soon after but Pedro was offside before beating Cudicini.

Towards the end of the first half, Tottenham raised their game and enjoyed two chances as Luka Modric struck the crossbar and soon after Benoit Assou-Ekotto saw his drive tipped over by Albert Jorquera.

博扬打破僵局

当皮球落到其跟前距离球门只有6码处的时候,加泰罗尼亚前锋这次没有给对方门将任何机会,一个抽射,帮助球队率先取得了进球。而这个进球主要归功于亚亚·图雷,亚亚从中场开始,以一股超强劲的盘带越过了好几名热刺的防守队员,直到哈德斯通的一个铲球使得球落到了博扬的脚下。这也是红蓝军团季前赛取得的第一个进球。他们本可以取得第二个进球,但是佩德罗的进球被吹罚了越位而取消。

在上半场临近结束时,热刺开始发威,并取得了两个进球机会,但是埃克托的射门被巴萨门将霍尔克拉用指尖碰出,而摩德利奇的射门则击中了横梁。

Livermore equalises

At the break Guardiola changed his entire team and part of the eleven that started the second period was Henrique, who made his debut alongside Marc Muniesa at the back for Barcelona. While the Blaugrana maintained their form, Tottenham’s changes ensured that they too altered their game and they were able to raise their game in the closing minutes. That pressure led to an equaliser as Assou-Ekotto’s centre from a short corner was met by Jake Livermore, who beat José Manuel Pinto to head home.

里维摩尔扳平比分

中场休息时,瓜地奥拉完全更换了球队的11人阵容,亨里克在下半场获得了出场机会,这也是他在巴萨的处子秀,他和穆尼艾萨搭档中后卫。巴萨维持了阵型,但热刺进行了一些调整,以确保他们能够更改比赛的局势并在比赛的最后时刻大举反攻。他们的持续施压取得的成效,在一次短角球战术中,埃克托的传中被里维摩尔顶进了平托把守的球门,扳平比分。

Posted in: Visca Barça / Tagged: barca, Pre-season, Tottenham Hotspur, Wembley Cup

顶点法线

July 23, 2009 4:27 pm / 2 Comments / Benny Chen

本来以为前一段时间写的3d max导出插件已经没有什么大的问题了,但有没有问题,完善不完善,真不是凭感觉就OK的,必须有足够广泛的测试用例测试后,才能够证明。

这不,最近开始研究并写一些光线跟踪的例子了,这当然离不开模型的法线,于是在进行当中我就发现,我的导出插件所导出的法线是不完善的。

在原来的插件中,我让顶点的法线就直接等于其所在的三角形面的面法线(多个面共享1个顶点,则会导出多个顶点,这些顶点位置相同法线不同),但对于光照模型,面法线只能支持到Lambert,为了支持Gouraud, Phong等其他模型,则必须使用顶点法线(为什么?稍后解释)。

这里提出了顶点法线和面法线,首先需要清楚的理解并区分这两个概念。

面法线很容易理解,即垂直于三角形面的一条法线。那顶点法线又从何而来呢,严格的从法线的定义上来说,其实顶点是不存在法线的,那为何又有顶点法线这个概念的。让顶点也拥有法线,是为了在光照计算时,能够在多面体的表面获得一种平滑的效果。

更具体的说,如果不使用顶点法线(就像我的3dmax导出插件原来就直接让顶点法线等于其面法线一样),一个三角形面的三个顶点的光照计算按照其所在面的面法线来计算,因为三个顶点的法线相同,则与光照方向求点积之后的结果也相同,这样三个顶点将会获得相同的光照效果,之后,光栅化再怎么插值,整个表面也都只是一种光秃秃的效果。(如图1)

而如果使用顶点法线,同一个面的三个顶点的法线就不一定相同了,这样通过光栅化后,就能在多面体的表面获得一种平滑过渡的光照效果。(如图2)

于是,弄清楚了这个后,我需要再次修改我的3dmax导出插件了,需要计算并生成新的顶点法线。那顶点法线该如何计算呢,对于这个我在这里就不详述,Max Wagner的《Generating Vertex Normals》这篇文章说的很详细清楚,从最简单的到逐步优化的生成算法一一都有介绍,可以去google找一下。

而3dmax的SDK开发文档里对顶点法线的计算也有介绍,3dmax提供了一个smoothing group的概念,这对于像立方体盒子这种表面并不是平滑过渡的模型,计算它们的法线将会带来很大的帮助。Wagner的文章里也说了,对于像立方体这样的模型,顶点法线不能简单的等于(共享该顶点的面的)面法线的平均值,因为这些面之间的过渡并不平滑。按照3dmax的概念,这些面不属于同一个smoothing group。何为smoothing group,这是3dmax根据表面之间的平滑过度情况,进行的分组。比如立方体,因为6个面之间两两都是相互不平滑的,所以一共会有6个smoothing group。每个面所属的平滑组的ID,程序员是可以直接读出的。

下面这两张图,是我在修改前和修改后的光照效果,对比很明显。

lambert 图1:基于面法线的光照

gouraud图2:基于顶点法线的光照

Posted in: Computer Graphics / Tagged: 面法线, 顶点法线

打破进球荒

July 19, 2009 3:57 pm / Leave a Comment / Benny Chen

7月17日我刚刚度过了我23岁的生日,果然给我带来了好运气,18号的踢球我就打破了进球荒,攻入了两球,助我们球队5:2战胜对手。

这场比赛的表现比前两场稳定很多了,确实前一段时间好好总结了一下并且通过加练取得了一定的效果,希望球队和自己都能踢得越来越好,取得更大的进步。

Posted in: FCB BJ / Tagged: 踢球

The First Signing – Maxwell delighted at Barca

July 18, 2009 3:17 pm / Leave a Comment / Benny Chen

2009-07-17_presentacion_maxwell_10In his official presentation to the media, Maxwell, Barca’s new left back has said that “today is a very special and happy day for me … it is a dream come true.”

马克斯维尔,作为巴萨最新引进的左后卫,在他的官方媒体见面发布会中说道:“今天对于我来说,是特殊而开心的一天,因为这是我梦想成真的一天。”

Serious, relaxed and humble, the first new addition to the treble winning squad, Maxwell, was officially presented today in Sala París at the Camp Nou. In his first official statement since signing, he said: “today is a very special and happy day for me. It is a dream come true. This is the strongest team in Europe”.

马克斯维尔作为三冠王巴萨在今夏的第一个增援,以一种认真、放松和谦虚的态度,于今日在诺坎普的Sala París正式亮相。在签约之后的第一次官方发言中,他说道:“今天对于我来说,是特殊而开心的一天,因为这是我梦想成真的一天。巴萨是欧洲最强大的球队。”

Four years, and option for one more

Before the presentation, Maxwell visited the offices to sign his contract, which will be for four seasons, with an option to stay for a fifth, depending on the number of games the Brazilian plays for Barça in his fourth year. The buy-out clause on the contract has been set at 50 million euros.

4+1年的合同

在见面会之前,马克斯维尔签订了一份4+1年的合同,第5年的合约取决于巴西人在前4年总的出场次数,合同的违约金高达5000万欧元。

Praise from Txiki

Barça’s director of football Txiki Begiristain, who attended the press conference along with president Joan Laporta, explained why they had signed Maxwell. “We understood that it was a position that needed improvement. He is a Brazilian player, but has grown up in Europe and where there is a very similar philosophy to our own, at Ajax, and he has also played top level competition at such a team as Inter.”

When asked to describe his new acquisition, Txiki Begiristain had no doubt that “he is top class, has a good physique and plenty of skill”.

来自巴萨技术总监的赞扬

巴萨的技术总监贝基里斯坦,和主席拉波尔塔一起出席了新闻发布会,他解释了为什么巴萨选择了马克斯维尔:“我们清楚我们的左边路需要加强 ,他是一位巴西人,但是他的足球生涯主要是在欧洲成长,他效力过阿贾克斯,他们的足球哲学和我们的非常类似,他还在国际米兰踢了很多顶级的比赛。”

当被问道如何评价他的最新引援时,贝基里斯坦确定的说:“他绝对是世界级的,身体和技术都很出色。”

His role

Maxwell has come to Barça just after Sylvinho’s contract ran out on June 30. “I know I am here to replace a player that has left and I know that competition for places at the club is a positive thing”, he said when asked about his role in the team, where he will be competing with Frenchman Éric Abidal for the left back place.

他的角色

马克斯维尔的到来是为了填补西尔维尼奥走后的空缺,后者的合同在6月30号已经到期。但是马克斯维尔还需要和法国人阿比达尔竞争左后卫的位置,在被问道如何看待自己未来在俱乐部的角色时,马克斯维尔说道:“我知道,我来到这里是为了替代一位已经离开的球员的位置,而且我认为,俱乐部里存在位置的竞争,肯定是一件积极的事情。”

Posted in: Visca Barça / Tagged: barca, Maxwell

诡异的画面

July 16, 2009 5:55 pm / Leave a Comment / Benny Chen

对shader文件做了一些修改,但还只是简单的渲染一个带纹理的盒子。出来的结果居然是这样的诡异,荧光闪闪,还带着雪花满盒子飘……

雪花bug

shader的错误的确很难查找,尤其是在编译通过只剩下逻辑错误的时候。最后错误的原因却又是如此的简单,我把PS的返回值写成了float,而应该是float4,我不小心漏掉了4,于是造成了这样诡异却绚烂的艺术效果,留文以作纪念。

Posted in: Computer Graphics / Tagged: pixel shader

To be improved

July 15, 2009 1:22 pm / Leave a Comment / Benny Chen

I tossed and turned last night, haunted by the sights of last Sunday’s football match. In that match, our team thrashed the opponent, which I am very proud of. Although there is still a tremendous space for our team to improve, we together have witnessed some progress, more or less.

However, to my disappointment, I was in terrible form in that match and missed an awful lot of chances. What a poor effort! These several days, I’ve been obsessed by sort of a strong sense of qualm.

OK, it’s true that this was the first time I’ve ever played a match in such a big pitch. So I was troubled with my stamina( I only played 30 minutes ) and maybe I was still a bit of nervous and lack of self-confidence. But they are all not reasons or excues for my unstable performance.

I still need more practice. And my tactical awareness and teamwork skill are both needed to be reinforced. Here are some advices that I summerized for myself:

  • Do not be too eager to pass the ball out. Stop and control the ball well first, and then find a teammate in good position to pass the ball. I think this is also my strength, so I should take better advantage of it.
  • Do not always try lob pass. It is not effective most of the time, a through pass is much better.
  • Never be scared to receive the ball. Run to a good position and be ready to receive a pass anytime with full confidence.
  • Even if I play as a winger, do not be too close to the sideline. Keep a proper distance from my mifield teammates, neither too far nor too close.
  • Take part in the defense more.

Next time, I hope I can contribute more to my team and gain a much better performance. And when can I break my goal drought? Wish that won’t be long^_*

Posted in: FCB BJ / Tagged: barca, Beijing, team

Some Tests

July 8, 2009 9:30 pm / Leave a Comment / Benny Chen

在最近的项目中,尝试进行了一些小实验,并记录了数据作为比较。实验机器的显卡是NVidia Geforce 8800 GT。

1. Skinning

skinning on CPU

                          skinning on CPU

skinning on GPU

                          skinning on GPU

从图中可以清晰的看出,对于骨骼蒙皮计算,CPU和GPU的差距可见一斑,GPU比CPU要快上10倍之多!这就是GPU并行计算的魅力!

2. Instancing & Stream Output

人物模型延用上面的这个模型(该模型差不多有1300个面),采用instancing技术渲染上千人(所有的Instance的动画在每一帧保持一致),并且实现了SO的版本,对它们的FPS进行比较。

Instancing without SO

   

     1,000 Instances              2,000 Instances             3,000 Instances

Instancing with SO

   

     1,000 Instances              2,000 Instances             3,000 Instances

因为所有的Instance的动画在每一帧都是一致的,所以如果不使用SO技术,则不得不对每个instance都需要进行一次蒙皮动画,这显然是一种浪费。Stream Output技术使得所有的Instance的蒙皮动画只需要执行一次,所以在效率上得到了一定的提高,如下表。

Number of Instances

FPS(Without SO)

FPS(With SO)

1,000

40

56

2,000

19

36

3,000

13

24

 3. Frustum Culling

换了一个低质量的模型(只有不到200个面),基本上万人级别是没有问题了,加上了Frustum Culling,则可以跑得更快!

使用3种方法实现了Frustum Culling,前两个都是基于CPU的,最后一个是基于GPU

  1. 顺序执行(最简单的对所有Instance遍历执行Frustum Culling算法)
  2. 四叉树(四叉树裁剪,我这里用四叉树用得有点牵强,因为人物不能移动且必须保持边长为2的N次方的阵型。这么简单的处理四叉树,只是为了做实验比较而已)
  3. GPU上的Frustum Culling(算法基本上跟1是一致的,只不过是在GPU上执行)

三个方法在同一个视角,使得它们截取和渲染的数量是一致的。总共65536个Instance,当前绘制都是15485个。

   

           顺序执行                              四叉树                             在GPU

效率比较如下表。

Current Rendering / Number of Instances
FPS
(Sequential Frustum Culling)
FPS
(Frustum Culling With Quad-tree)
FPS
(Frustum Culling on the GPU)
4388/16384 61 143 102
15485/65536 16 43 32

发现最快的是使用四叉树,而GPU的算法反而相对比较慢。原因很有可能是后者需要处理GPU和CPU的同步问题,在GPU进行Frustum Culling需要CPU从GPU读取Frustum Culling执行的结果(为了知道有多少个instance需要被渲染),在DX10的SDK文档里可清楚的写着,从GPU向CPU进行Map读取操作,是比较严重影响效率的,因为总有一方要停下来去等待另外一方的数据。

Posted in: Computer Graphics / Tagged: frustum culling, instancing, skinning

Post Navigation

← Older Posts
 

LinkedIn

Milan Petrovic

Categories

  • In My Life (25)
    • A Day in the Life (8)
    • English Learning (2)
    • Learn a Word (7)
    • Something In The Way (8)
  • Music Heaven (8)
    • Guitar (1)
    • In Concert (1)
    • Lyrics (3)
  • OK Computer (54)
    • 3D (3)
    • C++ (10)
    • Computer Graphics (15)
    • Game Programming (23)
    • iOS (6)
    • Linux (1)
    • Lua (9)
    • My Projects (3)
    • Some Experiences (9)
    • Talking in Code (2)
    • Unity (2)
  • Quotations (2)
  • Uncategorized (1)
  • Visca Barça (24)
    • FCB BJ (5)

Recent Posts

  • [译]优化你的手机游戏(没有延迟的,才是健康的)- 一篇给游戏美术设计师读的文章
  • 新浪微博API for MOAI
  • 稍后继续
  • Unity Developer ++
  • Another Thread @ Moai Forum
  • 1st Day of Golden Week
  • 为SyntaxHighlighter添加新语言
  • 基于Lua的State Pattern
  • Class Diagram of Pacman
  • 基于Moai的Pacman

Recent Comments

  • 约修亚_RK on 为SyntaxHighlighter添加新语言
  • 爱装的小男孩 on 小心DLL链接静态库时的内存错误
  • happyfire on Game Loop的几种实现方式
  • William on 新浪微博API for MOAI
  • Benny Chen on 新浪微博API for MOAI
  • your man on 新浪微博API for MOAI
  • 你家男人 on 稍后继续
  • 逍遥 on 关于对std::vector的遍历
  • papa on Unity Developer ++
  • T客网 ︱ Techpot » Blog Archive » iOS开发与OpenGL ES相关问题整理(1) on iOS开发与OpenGL ES相关问题整理(1)

Tags

2d 3D 3dsmax 3ds max air Apply architecture Asia tour barca Beijing bilbao binary search blocked bob boost bruce springsteen C++ capo CGContextDrawImage Champions League Change DLL DX10 eval exporter flash framework frustum culling game game engine iniesta ios linux lua Moai opengles pacman plug-in plugin 北京 导出插件 崩溃 巴萨 游戏引擎 踢球
© Copyright 2026 - A Game Developer
Infinity Theme by DesignCoral / WordPress