Raydium 3D Game Engine

Official forum for everything about Raydium, ManiaDrive, MeMak, ...
It is currently Fri Apr 19, 2024 12:58 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: lens flares
PostPosted: Sun Jul 30, 2006 4:56 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
I'm trying an approach to lens flares.
Image
Currently i see 3 possible ways to face this feature.
  • Option 1: Draw every lensflares even if they are not in the screen. Slowest, but simplest.
  • Option 2: Draw only visible lensflares using hardcoding volume detection. Slow but whe can make detections of a circle of pixels around the light.
  • Option 3: Draw only visible lensflares using GL_NV_occlusion_query extension. Fastest but limited to detect one pixel per light.

I wait your comments.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 30, 2006 5:52 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
Interesting subject !
I may be wrong, but I think that it's better to make 2 sorts of flares :
- "sun" lens flare
- "light flares" (there's probably a better name for this) : http://ftp.cqfd-corp.org/11342.jpg

It requires different handlings, I think.
- For sun lens flar, we need a vector, from the sun (if visible) to the screen center. Size of the effect depends on sun visibility percentage.
- For light flares, we can draw it almost everytime (is requires only 2 triangles), but size depends only on distance. The effect must be enable only when the light face the camera (180°), I think.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 30, 2006 7:55 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Xfennec wrote:
- For light flares, we can draw it almost everytime (is requires only 2 triangles)...


Well, the lens flares efects usually needs 4 parts:
The haloImage
The glowImage
The focused glowImage
StreaksImage

Also more elements can be added like Rays, pikes and so but they are not usually shown ig realtime games.

So 4*2triangles=8 triangles at least per light per frame.

About detecting lights if they are facing the camera, it only will work fine with directional lighs. Point lights have no direction...


More points:
Should the lens flare effect be rendered at the last?
Should it be part of the HDR texture?
Here there is an interesting tutorial: http://nehe.gamedev.net/data/lessons/le ... ?lesson=44
Also is needed en occlusion test to avoid show the LF if the light is occluded by an object.

Personally i point to use GL_NV_occlusion_query mixed with some "facing" tests. This extension will give us the number of pixels that are visible and so we can use this quantity to set up the size of the glow, ignoring the z factor.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 30, 2006 8:50 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
Look at my screenshot: it shows "light flares", not "sun flare". There's only one texture needed for such effect.

Quote:
About detecting lights if they are facing the camera, it only will work fine with directional lighs. Point lights have no direction...

Let's define this as an option.

Quote:
Should the lens flare effect be rendered at the last?

Yep, right, as all translucent textures.

Quote:
Should it be part of the HDR texture?

No. This texture is heavily stretched and use a very low resolution. And effects should be distincts. And currently, HDR is not working (not production ready).

Quote:
Also is needed en occlusion test to avoid show the LF if the light is occluded by an object.

I don't think so. Most of the time, light flares are small. Viewing a small part of the flare when the light is masked is not a problem. Look at this ugly test : the left headlight of the car behing is not visible, but we see the flare .. and it looks cool, no ? :)

So (for me) GL_NV_occlusion_query isn't needed for such lens flares (but probably for sun flare, but I usually found this effect ugly ... HDR look way better for the same thing, I think).


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 57 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group