Live Wallpaper Water Ripple Effect

后端 未结 3 1589
别跟我提以往
别跟我提以往 2020-12-23 12:57

I\'m working on a live wallpaper that incorporates some water ripple effects on touching the screen but I\'m a little stuck.

Would it be better to create multiple im

3条回答
  •  忘掉有多难
    2020-12-23 13:18

    I'm no expert in this, but I believe the typical way to do water effects in OpenGL is with a fragment shader. With a static image as a texture, your shader can vary the texture coordinates used for sampling that image, to distort it in arbitrary ways.

    Calculate the pixel's direction and distance from the center of the circle, and adjust the texture coordinate toward or away from the circle's center based on a sinusoidal function of the distance, and you should get a nice ripple effect.

    Judging by the description of that YouTube video you linked, it sounds like that's done by using a grid of triangles and adjusting the texture coordinates only at the vertices. That should work too, but it won't look as good unless you use a rather fine grid. Doing it per-pixel with a fragment shader is the ideal, but I don't know whether that would cause performance problems on a phone's GPU.

提交回复
热议问题