fxSunLight
by Melv May · 09/02/2002 (12:14 pm) · 35 comments
Download Code File
If you've not already used it then I recommend you download and look at my fxLight which enables you to create a dynamic light with simply loads of animation options.
Originally I gave it the ability to also act like a sunlight e.g. permantly fixed in the sky with azimuth/elevation settings. This versatility was causing problems so I decided to seperate them into two objects.
This object is designed specifically to create an animated sunlight effect for your scenes. With a couple of these objects in your scene with various animations you can create quite spectacular effects quickly and easily.
Note that this object will only create a flare effect and does not actually light the scene.
Here are a few examples of it in action that you may have seen before...
Sunlight#1
Sunlight#2
If you need to get the code from my site then you can find it @ fxsunlight.zip.
I hope you enjoy using it.
EDIT: 8/09/02 - Added the ability to render local/remote flares to give the effect of the lens flare plus the object itself at a remote distance.
EDIT: 8/09/02 - Added the ability to animate the sun size plus the cool ability to animate the azimuth/elevation.
EDIT: 8/09/02 - Added code to ignore changes to animation times <= zero (which caused Torque to hang).
[EDIT] 01/02/03
Changed hosting web-site.
- Melv.
If you've not already used it then I recommend you download and look at my fxLight which enables you to create a dynamic light with simply loads of animation options.
Originally I gave it the ability to also act like a sunlight e.g. permantly fixed in the sky with azimuth/elevation settings. This versatility was causing problems so I decided to seperate them into two objects.
This object is designed specifically to create an animated sunlight effect for your scenes. With a couple of these objects in your scene with various animations you can create quite spectacular effects quickly and easily.
Note that this object will only create a flare effect and does not actually light the scene.
Here are a few examples of it in action that you may have seen before...
Sunlight#1
Sunlight#2
If you need to get the code from my site then you can find it @ fxsunlight.zip.
I hope you enjoy using it.
EDIT: 8/09/02 - Added the ability to render local/remote flares to give the effect of the lens flare plus the object itself at a remote distance.
EDIT: 8/09/02 - Added the ability to animate the sun size plus the cool ability to animate the azimuth/elevation.
EDIT: 8/09/02 - Added code to ignore changes to animation times <= zero (which caused Torque to hang).
[EDIT] 01/02/03
Changed hosting web-site.
- Melv.
About the author
#2
and out of curiousity: Is fxsunlight a step closer to shaders?
Edit: I don't know if this helps w/ the grass question, but I think that lightning is actually just a particle emitter of a different type--like rain and snow are also.
09/02/2002 (3:11 pm)
Nice job again, Melv. Was this previously a part of your fxlights? and out of curiousity: Is fxsunlight a step closer to shaders?
Edit: I don't know if this helps w/ the grass question, but I think that lightning is actually just a particle emitter of a different type--like rain and snow are also.
#3
@Eric: Yes, this code is not new or anything special, it's just been seperated from the fxLights (as I describe above) as the dual-functionality was causing problems.
As to your query regarding shaders, this really hasn't anything to do with shaders, it's just a bog-standard lens-flare setup to act like the sun. The only special feature is that the object you place in the world has nothing to do with the position of the sun, therefore the sun is always out of reach at the specified elevation/azimuth.
- Melv.
09/03/2002 (2:31 am)
@Luc: Glad you like it. Not sure about using particles for grass. There is a discussion going on in the forums regarding a new or reworked particle system though.@Eric: Yes, this code is not new or anything special, it's just been seperated from the fxLights (as I describe above) as the dual-functionality was causing problems.
As to your query regarding shaders, this really hasn't anything to do with shaders, it's just a bog-standard lens-flare setup to act like the sun. The only special feature is that the object you place in the world has nothing to do with the position of the sun, therefore the sun is always out of reach at the specified elevation/azimuth.
- Melv.
#4
alright... one little teensy complaint... (GASP! a complaint about melvs work!). Your light shows through the terrain. (I'm sure you noticed this.. but if you haven't, fire up the FPS sim and look at a big sun render)
I know this is occuring because it just does a LOS test to the point at which the sun azimuth/elevation actually IS... but would it be too much trouble to add a masking effect with the terrain that the terrain would block it out?
Tell you what... you do that and I'll see what I can do about getting some stuff back to the community as a thank-you =] (heck, I'm going to release it anyway, but I've gotta offer SOMETHING)
~ Sang
09/03/2002 (7:26 am)
Nice work melv! AWESOME!alright... one little teensy complaint... (GASP! a complaint about melvs work!). Your light shows through the terrain. (I'm sure you noticed this.. but if you haven't, fire up the FPS sim and look at a big sun render)
I know this is occuring because it just does a LOS test to the point at which the sun azimuth/elevation actually IS... but would it be too much trouble to add a masking effect with the terrain that the terrain would block it out?
Tell you what... you do that and I'll see what I can do about getting some stuff back to the community as a thank-you =] (heck, I'm going to release it anyway, but I've gotta offer SOMETHING)
~ Sang
#5
I think you've got this a little wrong. Flares are a camera local effect. It is not a distance effect at all. It is due to internal reflections/refractions in the camera lens itself and is not related to the size of the projected object but it's luminosity.
All lens flares are rendered post scene-rendering so that they appear over the scene.
The LOS test has to happen at a point otherwise you would get the flare winking out too early.
I know there are masking effects that can be used to diminish the flare effect as more of the distant object is occluded upto a threshold value but these can be expensive.
Or is this not what you mean? ;)
- Melv.
09/03/2002 (8:28 am)
Jeff,I think you've got this a little wrong. Flares are a camera local effect. It is not a distance effect at all. It is due to internal reflections/refractions in the camera lens itself and is not related to the size of the projected object but it's luminosity.
All lens flares are rendered post scene-rendering so that they appear over the scene.
The LOS test has to happen at a point otherwise you would get the flare winking out too early.
I know there are masking effects that can be used to diminish the flare effect as more of the distant object is occluded upto a threshold value but these can be expensive.
Or is this not what you mean? ;)
- Melv.
#6
you were the one that made me working with Torque again.
I stopped working with Torque ago, because it looked a little bit old to me.
And then I found your fx-series which looks sooooo lovely, giving Torque a fresh new look.
Thx man
09/03/2002 (8:36 am)
Melv,you were the one that made me working with Torque again.
I stopped working with Torque ago, because it looked a little bit old to me.
And then I found your fx-series which looks sooooo lovely, giving Torque a fresh new look.
Thx man
#7
@Andreas: Thanks! The only thing to remember though is that although I've put some icing on the cake, it's still the same powerful engine capable of creating fantastic games in fairly short periods of time. ;)
Don't want folks to think that all I care about is fancy graphics because it's not, I enjoy the whole enchilada. 8)
- Melv.
09/03/2002 (8:44 am)
@Jeff: Don't want that to sound like a slam in your face. If there is a minor change you want for your project then I wouldn't mind doing it for you (as long as it was minor). ;)@Andreas: Thanks! The only thing to remember though is that although I've put some icing on the cake, it's still the same powerful engine capable of creating fantastic games in fairly short periods of time. ;)
Don't want folks to think that all I care about is fancy graphics because it's not, I enjoy the whole enchilada. 8)
- Melv.
#8
I'll try to hack together a picture showing what I'm interested in acheiving... =]
~ Jeff
09/03/2002 (11:16 am)
@Melv: No problem, it's still a gorgeous effect. I get that it's a camera local effect and not a distance effect (I know how they work). What I'm trying to say is, your fxSunlight doesn't look a whole lot like a lenseflare to me, it looks more like an actual sunlight =] What I'm saying is, if you look at it from a point where the sun is just barely showing above the hill, it renders the whole flare, even occluding the hill. I was wondering if it was possible to have the hill occlude the flare, instead of the other way around. I figure it's probably difficult to have the effect I'm interested in, because it is rendered simply based on an LOS effect.I'll try to hack together a picture showing what I'm interested in acheiving... =]
~ Jeff
#9
The effect I have tried to achieve is a lens flare effect. The particular emphasis on the Sun is that it is a point at a finite distance but your are never able to approach it.
I think what you are describing is a component of looking at the sun. I think you are describing god-rays plus the corona?
I guess with the correct flare you get what look like god-rays, particularly when you place the sun against clouds but these are obviously a side-effect of the flare itself and not intentional. As for the corona, obviously this would be occluded by world geometry.
Now I think about it, it would be possible to have to two textures for the sun and used like this ...
Render the first texture without a depth-check, just after the sky but before any other geometry and include fog/haze. Don't do a LOS check on this as all other geometry would simply paint-over it. Render the second texture after the scene has completed using the existing LOS check.
This system would give you a portion of the sun which would be occluded and a portion that wouldn't. In effect a remote and local lighting system.
Sound good? It does to me so I'll look at this tommorrow. ;)
- Melv.
09/03/2002 (11:28 am)
Jeff,The effect I have tried to achieve is a lens flare effect. The particular emphasis on the Sun is that it is a point at a finite distance but your are never able to approach it.
I think what you are describing is a component of looking at the sun. I think you are describing god-rays plus the corona?
I guess with the correct flare you get what look like god-rays, particularly when you place the sun against clouds but these are obviously a side-effect of the flare itself and not intentional. As for the corona, obviously this would be occluded by world geometry.
Now I think about it, it would be possible to have to two textures for the sun and used like this ...
Render the first texture without a depth-check, just after the sky but before any other geometry and include fog/haze. Don't do a LOS check on this as all other geometry would simply paint-over it. Render the second texture after the scene has completed using the existing LOS check.
This system would give you a portion of the sun which would be occluded and a portion that wouldn't. In effect a remote and local lighting system.
Sound good? It does to me so I'll look at this tommorrow. ;)
- Melv.
#10
If you are REALLY in the mood to get fancy, make the lensflare/sun effect get occluded by the clouds as they pass infront of the sun =D!
~ Jeff
(PS I think your work rocks melv, I'm just offering constructive criticism.. dont' hate me!)
09/03/2002 (1:54 pm)
Sounds good to me melv. I am speaking of the corona and god-rays. Lensflares tend to (at least in my experience) appear and dissapear as you look towards and away from the sun, whereas your lensflare stays constant from the moment the LOS is met (not a problem, don't take this hard, not trying to start something!). I still think this effect is the bomb =] (looks a helluva lot better than the skyboxes, since it's rendered real-time)If you are REALLY in the mood to get fancy, make the lensflare/sun effect get occluded by the clouds as they pass infront of the sun =D!
~ Jeff
(PS I think your work rocks melv, I'm just offering constructive criticism.. dont' hate me!)
#11
09/03/2002 (2:01 pm)
Sorry, Melv... I missed the part where you mention FXLIGHT! LOL... I swear... some days I'm half-blind--the rest I'm completely. ;-)
#12
@Jeff: Naw, you misunderstand my tone, I enjoy little dev-spars like these. Sometimes great ideas can come out of them. I almost never get nasty. 8)
- Melv.
09/03/2002 (2:05 pm)
@Eric: ;)@Jeff: Naw, you misunderstand my tone, I enjoy little dev-spars like these. Sometimes great ideas can come out of them. I almost never get nasty. 8)
- Melv.
#13
09/05/2002 (5:06 pm)
.
#14
09/06/2002 (9:24 pm)
your all talking about the terrain etc... but I noticed that you see the corna still showing though the hands and firearm in the first person view
#15
Based upon the discussion above with Jeff I have now amended the object to include the ability to render *two* flares. The first is the remote sun flare and will be occluded by the scene geometry e.g. it is behind everything apart from the sky.
The second is the usual local flare. If you plonk this object into the scorched earth level and goto the building with the slats in. If you setup a fxSunlight and look at it through the slats as you move then you will get the idea.
Here's an example (with crappy textures)...
New fxSunLight
Basically the flare completely disappearing as an object got in the way didn't look that realistic but this should get around that.
Hope you enjoy.
- Melv.
09/07/2002 (4:05 pm)
Okay,Based upon the discussion above with Jeff I have now amended the object to include the ability to render *two* flares. The first is the remote sun flare and will be occluded by the scene geometry e.g. it is behind everything apart from the sky.
The second is the usual local flare. If you plonk this object into the scorched earth level and goto the building with the slats in. If you setup a fxSunlight and look at it through the slats as you move then you will get the idea.
Here's an example (with crappy textures)...
New fxSunLight
Basically the flare completely disappearing as an object got in the way didn't look that realistic but this should get around that.
Hope you enjoy.
- Melv.
#16
New update today.
I have added new abilities that you should find useful:-
- Can now animate the size of the sun flares.
- Can now animate the azimuth.
- Can now animate the elevation.
The azimuth/elevation animations should be particularly important to those who want to create the effect of the sun orbiting the planet.
Note that you don't have to use this object as a sunlight. You can use it for rainbows, moons and anything that needs to be at a distance. If you don't have a local texture then you can do distance objects without the local flare effect.
Next up is adding fog support to the distant flare and also get the object clipped at the true horizon.
Have fun.
- Melv.
09/08/2002 (11:32 am)
Okay,New update today.
I have added new abilities that you should find useful:-
- Can now animate the size of the sun flares.
- Can now animate the azimuth.
- Can now animate the elevation.
The azimuth/elevation animations should be particularly important to those who want to create the effect of the sun orbiting the planet.
Note that you don't have to use this object as a sunlight. You can use it for rainbows, moons and anything that needs to be at a distance. If you don't have a local texture then you can do distance objects without the local flare effect.
Next up is adding fog support to the distant flare and also get the object clipped at the true horizon.
Have fun.
- Melv.
#17
So, heres some ideas:
1)Fix the thing mentioned above if you can
2)Make it so that if you are looking at the image and half of it is intersected by the edge of terrain, like a mountain or something, make it cut that much off of the image so that it does go through the whole mountain ><
3)The image seems to dissapear sometimes at certain angles and distances .. dunno why or anything myself
4)Sometimes it kinda blinks really fast if you zoom on it
09/11/2002 (8:26 pm)
also mev, a couple more ideas .. first off, the flare or png file goes straight through trees en stuff which is a bit odd ;) .. same with your foliage replicator.So, heres some ideas:
1)Fix the thing mentioned above if you can
2)Make it so that if you are looking at the image and half of it is intersected by the edge of terrain, like a mountain or something, make it cut that much off of the image so that it does go through the whole mountain ><
3)The image seems to dissapear sometimes at certain angles and distances .. dunno why or anything myself
4)Sometimes it kinda blinks really fast if you zoom on it
#18
Trees should block the LOS, the standard Torque ones don't because they don't have collision boxes hence you being able to walk through them. Don't forget that my LOS test simply uses the in-built collision detection routines used via CastRay.
The foliage replicator does not use a LOS test so I don't see the comparison here. Do you mean that if you are looking along the ground through a particularly dense cluster of foliage that has a large alpha halo then you will see straight through it and will possibly allow you to see through objects?
Well this is because I use a special technique for transparent objects that allows me to bypass the sorting stage for transparent polygons. You should try playing with the AlphaCutoff field which allows you to remove the offending alpha that halos around your objects when interpolating. Raising this value strips it away.
The alternative is that I sort the polygons which ain't gonna be fast no matter how you think about it.
I could add the ability to switch between the two techniques and let you decide, that would be a trivial amendment. The faster PC may want to use the sorting technique or in-fact you may not have that many polygons. That's the problem with creating these objects without a knowledge of the usage so I just do the worst case senario which is a million billboards for now and therefore I wanted to avoid a sort. ;)
I'm a little lost on your point 2.
Your points 3/4 disturb me a little. When was the last time you downloaded this object? It's just that I thought those problems had been resolved quite a while ago.
- Melv.
09/12/2002 (12:13 am)
Trevor,Trees should block the LOS, the standard Torque ones don't because they don't have collision boxes hence you being able to walk through them. Don't forget that my LOS test simply uses the in-built collision detection routines used via CastRay.
The foliage replicator does not use a LOS test so I don't see the comparison here. Do you mean that if you are looking along the ground through a particularly dense cluster of foliage that has a large alpha halo then you will see straight through it and will possibly allow you to see through objects?
Well this is because I use a special technique for transparent objects that allows me to bypass the sorting stage for transparent polygons. You should try playing with the AlphaCutoff field which allows you to remove the offending alpha that halos around your objects when interpolating. Raising this value strips it away.
The alternative is that I sort the polygons which ain't gonna be fast no matter how you think about it.
I could add the ability to switch between the two techniques and let you decide, that would be a trivial amendment. The faster PC may want to use the sorting technique or in-fact you may not have that many polygons. That's the problem with creating these objects without a knowledge of the usage so I just do the worst case senario which is a million billboards for now and therefore I wanted to avoid a sort. ;)
I'm a little lost on your point 2.
Your points 3/4 disturb me a little. When was the last time you downloaded this object? It's just that I thought those problems had been resolved quite a while ago.
- Melv.
#19
Well, you should make it so that it cuts that much of the image off that wouldnt usually be shown in real life.
I think I downloaded this pretty recent but i'll try re-dling it and see if anything comes from that.
09/12/2002 (2:23 pm)
well on two, I mean that ... well .. ok lets say I've got a big moon image that I want to use. And I have a mountain right in front of me. If I back up a bit, the bottom of the moon image goes through the terrain. But if I go forward and the mountain goes to at least half of the image, the image does it's "dissapear" deal you made it do.Well, you should make it so that it cuts that much of the image off that wouldnt usually be shown in real life.
I think I downloaded this pretty recent but i'll try re-dling it and see if anything comes from that.
#20
09/12/2002 (5:38 pm)
ok ya, I re-dled it and it works a lot better now, must have clicked the wrong link. Anyways, my ideas still stand however.
Torque Owner Luc Jordan
See, it's stuff like this that make Torque *really* shine. I mean, when you look at the underlying terrain engine, it's a frickin' incredible job. But all of the screen shots of various 'in-the-works' projects keep looking the same . . .
And it's largely because of lack of stuff like this. I mean, wow Melv. The sun + the vegetation give people just this HUGE flexibility in the kind of look and feel that their projects will have. They can go for that huge, super-bright super-saturated sun, which would work great for, say, a Zelda or Mario-esque environment, but might get in the way for, say, a flight sim or a tactical shooter . . . they can have fields of green swaying grass dotted with clusters of trees or a barren, broken landscape puntuated by upthrusts of volcanic rock.
Way to go, Melv.
Btw, I was playing around with the Serious Engine recently and I noticed that their grass is created with their base particle system. The particle system is very flexible; it can handle animated textures, can fade out with a certain distance from player, can be applied to the ground or to the surface of water or to the surface of all geometry within a certain radius or box . . . so that got me thinking, how applicable might that approach be? Could things like grass and so forth be set up as specific instances of the base particle class? Because that method is very versatile; Croteam used the same powerful particle system to create steam rising from water or smoke from lava, to create the fire that remains from burning stuff with the flamethrower, and to create ALL of the other particle effects in the game.
I really don't know much about what methods you're using or anything, I was just musing on Croteam's method and wondered how applicable it might be. I would note that some things Croteam didn't do very well are that all of the grass intersects VERY noticeably with the ground, since it uses a fixed x-y billboard that doesn't fade before entering the ground.
I swear man, I am going to get Torque. I just have all of this other stuff I need to do first . . . like right now I need to purchase Adobe Photoshop, which will eat up all of my cash, and then I need to get a nice shiny new gfx card, since all I have now is an ATI XPERT2000 with 16mb of video ram . . . :P Then Torque.