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
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.
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).
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.
Maybe I'm missing something but what's wrong with simply using glLight()
and the fixed functionality like everybody else?
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?
来源:https://stackoverflow.com/questions/544097/create-lightning-in-opengl-es-1-1