Create lightning in OpenGL ES 1.1

2019-05-07 07:30发布

I need to create good looking lightning using OpenGL ES 1.1 (iPhone) and was planning on using shaders. However, when I asked about it in a previous question (OpenGL ES 1.x Shaders) I was informed there that this was probably not an option on the iPhone.

So now I am back at square one, wondering how I might make a lightning animation. It does not need to look ultra-realistic. I have already tried to use things like triangles stripped together. While this method does work, it is not as good as I had hoped it would look.

Does anyone have any ideas on the subject?

Thanks again,
~Eric

5条回答
Fickle 薄情
2楼-- · 2019-05-07 08:07

Try using a triangle strip textured with a gradient from black to a low-saturation blue or purple, to white. Set your blending to additive (GL_SRC_ALPHA, GL_ONE).

查看更多
beautiful°
3楼-- · 2019-05-07 08:10

Maybe I'm missing something but what's wrong with simply using glLight() and the fixed functionality like everybody else?

查看更多
smile是对你的礼貌
4楼-- · 2019-05-07 08:11

The usual approach is to compute the path of the lightning bolt using a Perlin function, rendering it to a glow buffer, creating a nice looking blur using a Gaussian blur shader and then merge it with your scene.

查看更多
迷人小祖宗
5楼-- · 2019-05-07 08:28

Would have to be a very bright light to make it look like lightning and wouldn't you need to shine the light on or through something?

查看更多
走好不送
6楼-- · 2019-05-07 08:31

You could maybe adapt the code from this project. Although it's not ObjC/C, it does use OpenGL.

Here is an article that describes the effect in more detail and provides a VB/DirectX implementation.

查看更多
登录 后发表回答