ArenAK的博客

3D图形、虚拟现实 / 3D Computer Graphics,Virtual Reality
posts - 24, comments - 75, trackbacks - 3, articles - 0
   :: 首页 ::  :: 联系 :: 订阅 订阅 :: 管理
    这是2004年的一个海水实现,速度虽然不算快,但很漂亮,是用D3D写的,原网址:http://graphics.cs.lth.se/theses/projects/projgrid/

    自己用Ogre实现了一下,可以同时跑在OpenGL和D3D下了,但似乎D3D的效果要略好一点,精度更细致,天空盒的采样也没有裂缝,搞不懂为什么:) 在最后的效果上减少了一点,因为我基本不需要折射,只采用了反射,另外还没加太阳光的反射。

    这个实现中作者采用了"projected grid"的方法,此方法的好处是能使海面总能充满整个视野,也就是说海面的网格总是跟着视点在实时扩展的,永远走不到海的边界(这不正是有时候我们需要的吗?)它利用摄像机和海平面的位置来反算出当前为了让海面充满视野所需要的网格顶点位置,这些网格顶点在投影计算后在视口(viewport)内是均匀分布的点。我在程序中使用了128*256的网格,也就是128*256*2个三角形。

    这里是实现步骤的要点:
    1. Use projected grid concept to caculate the 4 corners' positions of the ocean base plane. Through interpolation get all the mesh  vertices's XZ coordinates.
    2. Use 8 octaves of Perlin Noise, sum them up, and sample the noise to generate height field(Y coordinate).
       Render the height to a RTT(Render to Texture).
    3. Sample the heightmap to get the neighbor's height. Generate the normal vector by cross product of neighbors' coordinates.
       Render the normal to a RTT.
    4. Make use of normalmap to get per-pixel normal vec and thus determin the reflection vector,which is used to sample the sky cube.
    It's done!

    实现效果:


    到我做的这一步,肯定有许多可以优化的地方,只是对我自己来说暂时还没有必要,所以先搁下。另外Ogre自带的Ocean_Demo的计算速度很快,用的是GPU Gems中的方法,或许可以将Projected Grid方法和它结合一下。不知可否有人实现,或者大家现在都在用什么方法?

ps:很重要的,感谢滨姐帮忙调程序:)
--ArenAK--

Feedback

#1楼    回复  引用  查看    

2007-11-07 10:20 by Enzo      
很漂亮哦

#2楼    回复  引用    

2007-11-26 15:18 by 零件 [未注册用户]
我也用这个东东做了一个Demo!
但是是GPU计算的躁点!
http://bbs.gameres.com/showthread.asp?threadid=98448
欢迎评价!

#3楼    回复  引用    

2007-12-09 00:33 by lo [未注册用户]
i've got many problem when i create the grid and compute heightmap. i wanna communicate with u. please send me an E-mail to give me ur mail address. Thank u!

#4楼 [楼主]   回复  引用  查看    

2007-12-09 12:54 by ArenAK      
@lo:
Thanks for your interest. Please check your email.

#5楼    回复  引用    

2008-02-24 00:01 by seraph0504 [未注册用户]
这种方法的缺点正如其作者本人所说,不是很容易在世界空间进行约束,渲染海水之类得很不错,可是湖泊河流就麻烦了。

#6楼 [楼主]   回复  引用  查看    

2008-02-27 12:59 by ArenAK      
@seraph0504
是的,如题目所说这是“海水”的实现,因为其算法是将水面网格铺于整个视野(从近剪切面直到远剪切面)。

#7楼    回复  引用    

2008-03-13 16:21 by jtacm [未注册用户]
果然很强悍,我也使用的OGRE也想作出这个效果,就是“永远走不到海的边界”。
作者能否把实现这个功能的代码EMAIL我一份,就是实现“永远走不到海的边界”的这个,最好发个源码的工程给我。
我发现国内搞OGRE的人好少,交流太少了,希望作者能帮这个忙。
谢了先。

#8楼    回复  引用    

2008-03-13 20:00 by Hey [未注册用户]
这篇硕士论文中提到的水也是通过Perlin noise+FFT方法来模拟水波的运动,
也是通过高度场来做的. 速度的确很快.
但是projected grid来做交互好像还是比较麻烦的,
令外, 这也实现不了breaking wave的效果,这是高度图的通病.

朋友加我QQ: 1496724

#9楼 [楼主]   回复  引用  查看    

2008-03-13 21:26 by ArenAK      
@jtacm

我已经在和Xavier Verguin合作将这个实现融合到Ogre的一个海水实现工程Hydrax中,相信不久就会公开整个源代码了。
但目前由于我的一个项目原因,暂时还不会完全公开这个Ogre实现的代码。请稍稍等一段时间,或者我们进行交流:)

#10楼 [楼主]   回复  引用  查看    

2008-03-13 21:56 by ArenAK      
@Hey
多谢你的指点。我很喜欢与水面有关的实时仿真,但其实我并没有在这方面做过多少研究(只读过这篇论文和GpuGems中Effecitve water simulaiton from physical models),本文的这个是出于项目的需要所以实现的。
希望能在图形学方面跟你多多交流。

#11楼    回复  引用    

2008-09-01 01:38 by leowo [未注册用户]
hi, ArenAK,

your ocean water demo is reali nice!
may i ask u a ques about noise for water?
i also read the paper many times, but i got a problem.
as i use opengl in mac and fedora, im not familer with windows and dxd.
it's quite tough for me to read the code from that projgrid article.
anyway, it would be a great help if you cloud give me some tips. thanks in advance. :)

this is what i've being doing:

first i use the noise function from orange book to create a 3dtexture to store the noise value;
then, in vertex shader, i interpolate vertex position to range(0..to 1) as tex coordinate to lookup the noise texture, so i got the height for each vertex;
and when i modify the s,t,r coordinates each frame, water is animated.
but the problem comes. it dosent look like water waving at all, but likes moving camera in a planet(like, image that, you drive ur helicopter forward... terrain moves backward..)

i have read that article many times(dxd makes me so confused, hahah), sadly i still dont get how they use noise.

seems like, they use 8 octaves (i use 4), and sum values up as the height value for each vertex
and they use 2d texture instead of 3d texture. i dont know how they get the water animated.
im also wondering wheather they calculate 2d noise texture every frame or not.
unlucky, the article focus on contents other than noise.

could you suggest me something, and tell me why my water waving effect is so @#@$%$#....?
really thanks, i've being doing it for 2 whole days.. really tired.. :)
maybe i described not clearly, sorry.

looking forward for ur reply :)

thanks alot
cheers
leo wong

#12楼 [楼主]   回复  引用  查看    

2008-09-01 19:54 by ArenAK      
hi,leo wong,

You should've used 2d texture and noise rather than those of 3d. I suppose the wrong effect of "moving camera in a planet..." is because of that too.

The projected grid concept is to make sure the water grid will always be in front of your camera, and thus it generates the X,Z coordinate of the vertices of the water plane; 2d Perlin noise is to generate the Y coordinate(height field). I guess in your method the 3d noise generate the X,Z,Y coordiantes simultaneously. Perhaps that's the cause of your wrong effect.

Don't hesitate to contact me if there's any more problem.

best,

ArenAK

#13楼    回复  引用  查看    

2008-09-01 20:36 by Justin      
水面很逼真

#14楼    回复  引用    

2008-11-13 08:49 by wangxl [未注册用户]
楼主你好,你做的效果相当的好,我想请教一下,你如何实现了,噪声海浪的随时间连续运动的。之前我曾经使用插值动画的方式但是效果很不理想,后来查阅相关资料发现用三维噪声纹理才能实现随时间变化的高度场,目前我最疑惑的是如何实现连续变化的高度场,换句话说就是在时间轴上高度值的变化是连续的。
请楼主不吝赐教。谢谢

#15楼 [楼主]   回复  引用  查看    

2008-11-13 23:24 by ArenAK      
噪声基本上还是用的Perlin二维噪声,我记得当时是用两个4阶的噪声(一个粗疏一个细密)去合成一个噪声,当时实现时基本是从http://graphics.cs.lth.se/theses/projects/projgrid/的代码拷贝修改的,所以对于噪声实现的细节并不是很清楚,也有些忘记,我曾经试图去跟写那个代码的人联系,但是没有结果,我建议你可以看看其代码,看是否能看明白(还是比较费解的)。另外http://www.ogre3d.org/phpBB2/viewtopic.php?t=38148有另一种实现连续变化高度场的方法供参考。
抱歉未能回答你的问题。

#16楼    回复  引用    

2008-11-15 17:18 by wangxl [未注册用户]
谢谢楼主,呵呵,我看过代码,比较乱很难懂,基于图形处理器的海浪仿真研究这篇文章讲到一些楼主可以参考

标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2008-01-24 22:49 编辑过
Google站内搜索

China-pub 计算机图书网上专卖店!6.5万品种 2-8折!
近千种 9-95 新二手计算图书火热销售中!
开发者征途系统新作:《设计模式——基于C#的工程化实现及扩展》



相关文章:


相关搜索:
实时海水 projected grid Ogre ArenAK

相关链接: