Game Development Community

[OT] OpenGl realistic lightning _NOT_ lighting

by Ron Yacketta · in General Discussion · 05/30/2002 (1:11 pm) · 12 replies

I have been on a mad hunt the past 2 - 3 days to find some valid resources to aid me in creating realistic environmental lightning in OpenGl.

Why might you ask?
Well I have set out to learn OpenGl :) I have some of the basics down (Thanks to the NeHe tutorials) and want to take a step further.

So, does anyone now of a decent resource/tutorial/example code I can take a look at?

Regards,
Ron

#1
05/30/2002 (2:37 pm)
I think I know what you are talking about (and why) ;) Ive been in a mad hunt myself as well. however I did had good results check the message forum at flipcode. (3d graphics) and specially take a look on this links.

developer.nvidia.com/view.asp?IO=robust_shadow_volumes

www.nvidia.com/dev_content/gdc2002/practical_per_pixel_effects_files/frame.htm

Realistic lighting, comes mostly from well done shadowing.
#2
05/30/2002 (2:40 pm)
He meant LIGHTNING!

Most people do a sort of chain of branches.. kinda like a fractal..

Looked at the lightning code in engine?

Phil.
#3
05/30/2002 (3:06 pm)
Lightning? (sorry damn, memo to self: buy reading glasses) I once read a cool article on how to create a complex particle system to do just that. Yes it must create pseudo fractal branches its not easy to do but its not impossible either and the results can be breath taking.

Check out the article at gamasutra.com is here:

www.gamasutra.com/features/20000623/vanderburg_03.htm (you will need to register I think)

The lighting effect is shown on one of the screenshots
on

Realistic lighting is what everybody seems to be interested in this days, and self shadowing, those links I gave you earlier are excellent on this subject.

oh well. you learn something new everyday
#4
05/30/2002 (7:38 pm)
This old OpenGL Challenge entry has always struck me as some of the best simulated lightning I've seen.
#5
05/31/2002 (4:56 am)
that be the ticket :) now i have something to work from.
I alsop found a decent particle system for opengl that I will hack into a working application and then get this lightning efffect added.

Thanxs everyone!!
#6
05/31/2002 (7:50 am)
Keeping with my [OT] theme (and realy showing my c++ ignorance ;) ) ;)
I have the following error when I am doing some
minor vector math

"warning C4244: '=' : conversion from 'double' to 'float', possible loss of data"

I am doing the following

float j;

j = 0.0+(float)rand()*100+100.0;

On a website about rand() I read the following

Quote:
Note we must convert rand() and/or RAND_MAX+1 to floating point values to avoid integer division

am I missing somehting here? I thought I am accomplishing this by typecasting rand() with (float)

I know this is "only" a warning, but still I would like to have a clean compile ;)

-Ron
#7
05/31/2002 (7:55 am)
The result of 0.0+(float)rand()*100+100.0 is a double, when you assign it to f, which is a float, thus warning: converting double to float
#8
05/31/2002 (10:18 am)
I think you just put an 'f' suffix to all your literals. e.g. 100.0f

Or why don't you just use double instead of float? Will it slow everything down. I thought processors these days handle double's very well. I could be wrong though.
#9
05/31/2002 (11:12 am)
Would I not need the "float" type for vertices? x,y and z
#10
05/31/2002 (11:59 am)
Ron,

I'm not sure what you are doing exactly so I don't want to be specific but using the suffix 'f' e.g. 123.45f, generally should be enough precision unless of course you are using extremely large floating-point numbers.

- Melv.
#11
05/31/2002 (8:38 pm)
@Melv,

Just getting random coords for lightning :)
I could use int/double, but that would look crappy eh?

23.67 vice 23 that .67 just might be enough to knock that one line off and screw the entire effect..

-Ron
#12
06/04/2002 (1:03 am)
Musaul is correct here - the default precision of a constant with a decimal place, such as 1.0 is double (ie a double precision float), and using an 'f' after this will make it into a float, such a 1.0f.

Additionally, you have called (float)Rand()*100, which means cast Rand() to float and multiply by integer 100, although your compiler will 'upcast' the 100 to a float at compile time.

For good lightning you will probably want your random numbers to have a gaussian like distribution, numerical recipes in C is a good place to start for this (available online) though faster solutions are available.

Good luck!