GLSL for simple water surface effects

北慕城南 提交于 2019-11-29 02:49:50

问题


I'm looking for some pointers on how to implement simple water surface effects in OpenGL ES 2.0. Nothing fancy like reflection or refraction, just a basic ripple/wave effect that modulates over time. Performance is critical. I'm assuming this will be best done in a shader.

Any pointers on how to best handle this?


回答1:


There is an old trick to simulate water waves & ripples using minimum effort in terms of equations. It's used in many places, and I can't find the original, but you can grab it, for example, from here.

You'll need 2 textures, each containing just height. Simulation is done by ping-ponging between them (using one as a source and second as destination each time).

When rendering, you might need to derive surface normal from the neighbour heights.




回答2:


Adrian Boeing's blog has example GL code, accompanied by clear explanations, for a number of effects including ripple.



来源:https://stackoverflow.com/questions/5012905/glsl-for-simple-water-surface-effects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!