views:

1390

answers:

5

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 (http://stackoverflow.com/questions/543948/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

A: 

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

shoosh
Lighting is generally associated as much was the streak across the screen as the brightning of things.
Andrew Grant
Oh, I misread lightning for Lighting. It's still however unclear what effect you're after and why you think it can't be reproduced by normal means. maybe a visual explanation is due?
shoosh
A: 

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?

Chapel
+2  A: 

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.

codelogic
I looked at these examples and have achieved a better effect than the first one. The second looks promising from the screen shot, but when I execute their code it comes out very bad.
EToreo
+2  A: 

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).

geofftnz
+1  A: 

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.

karx11erx