GLSL提供简单的水表面效果 [英] GLSL for simple water surface effects
问题描述
我正在寻找一些有关如何在OpenGL ES 2.0中实现简单水面效果的指导.没有什么像反射或折射那样花哨的,只是随时间调制的基本纹波/波效应.性能至关重要.我假设这将是最好在着色器中完成.
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?
推荐答案
有一个古老的技巧可以模拟水浪&在方程式上使用最小的力就能产生涟漪.它在许多地方都使用过,我找不到原始文件,但是您可以从例如这里.
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.
您将需要2个纹理,每个纹理仅包含高度.通过在它们之间进行ping操作来进行仿真(每次都使用一个作为源,第二个作为目的地).
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.
这篇关于GLSL提供简单的水表面效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!