sunflare, lights

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
marchanddesable
Gnoblar
Posts: 20
Joined: Mon Mar 14, 2005 11:15 pm

sunflare, lights

Post by marchanddesable »

Hello, i have 2 questions:

First, how can i make a nice sunflare with ogre ?

second, is it possible to make this with ogre:
http://3dfightinggames.free.fr/learning/1.jpg

(the light and also the sunflare)

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

Yes, it is possible.
You have a lot of different options here.
The simplest approach is simply making a material with a flare image (use flare.png from Ogre media) - then you add that to the scene in your material script -> scene blend add. ((Don't quote me on syntax - I know it's wrong - look it up in the Ogre Manual))
Or you can use a shader script - look in the media files of the paginglandscape editor project - I think I saw a sun shader script there.
You can also Google for it.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
alphageek
Gnome
Posts: 365
Joined: Mon Jan 03, 2005 11:56 am

Post by alphageek »

A nice, easy way to do glow on a light is to put a billboard at the same location as the light (attached to the same scene node or whatever). As jacmoe says, the glow material should use scene_blend add and also lighting off, depth_write off.

A disadvantage of this simple approach is that you will notice the billboard intersecting with geometry. You can make this more "correct" by disabling the depth test for your flare material, and then modulating the visibility of the glow billboard by periodically casting rays from the "eye" to the light position.

This will be much more effective if you use your physics engine for ray casting (with closely fitting collision primitives) rather than Ogre's bounding-box ray casting.

The result of the above added complexity is that your glows will no longer interact with geometry and will look much funkier.

Sorry to pimp myself, but compare and contrast the two glows in this shot:

Image

The glow from the thruster can be seen clearly cutting through the ship model, whereas the starlight glow is more correctly rendered "on top" of the entire scene (though it would be faded out if it were occluded by geometry).

User avatar
SuprChikn
Bugbear
Posts: 863
Joined: Tue Apr 19, 2005 6:10 am
Location: Melbourne, Aus
Contact:

Post by SuprChikn »

That answers the question about getting the glow at the light source.
Any ideas on the lens flares?
Thinking about it now, it seems you would have some sort of invisible line with flare images spaced more or less evenly along it, with the line stretching from the light source through the center of the view to it's opposite location on the screen. EG: if the light source was in the top-left corner of the screeen, this line would go from the top-left corner to the bottom right corner. If the light was half-way between the center of the screen and the top of the screen, it would stretch from that point to a point halfway between the center of the screen and the bottom of the screen.
Of course, if the light source is not in the viewing window, then the line with the flares is not drawn at all.
As to how to actually do that in practice... ?

User avatar
alphageek
Gnome
Posts: 365
Joined: Mon Jan 03, 2005 11:56 am

Post by alphageek »

There are tutorials on the internet on doing flares.

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

It can be as easy as having a ray from the light source - and placing billboards at intervals along that line - blending the materials appropriately.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
Kencho
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4011
Joined: Fri Sep 19, 2003 6:28 pm
Location: Burgos, Spain
x 2
Contact:

Post by Kencho »

I would do it this way: Once you've got if the flare is visible or not (the ray casting mentioned above), obtain the screen coordinates corresponding to that light. Once done, add elements (flares) to an overlay, at positions symmetric to the screen centre. For instance, the most basic would have a flare at the 2D light position, and other at (1.0, 1.0) - light2DPosition :)
Image

Post Reply