Raydium 3D Game Engine

Official forum for everything about Raydium, ManiaDrive, MeMak, ...
It is currently Thu Mar 28, 2024 12:18 pm

All times are UTC




Post new topic Reply to topic  [ 48 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
PostPosted: Fri Sep 26, 2008 11:12 am 
Offline

Joined: Tue Jul 08, 2008 2:37 am
Posts: 181
It would be nice to have some kind of lens flare effect integrated within the engine.

From the Raydium API reference:
Quote:
In a future, it will draw multiples layers of sky (with and without textures),
stars, satellites... Maybe rain and snow could be included here also.
Regarding to chapter 20 of the Raydium API reference I want to ask if there is a simple kind of lens flare effect planned or perhaps already available somewhere without my knowledge. Such feature could be used together with the sky box and also with the atmosphere environment. For the time being I'm not able to estimate how complex it is, which problems could occur and how much time this new feature will cost, but I propose this feature should be disabled by default and should give the user of the engine possibilities to enable, disable and simply modify this effect.

Any suggestion?

Thank you very much.

Best regards,
st


Last edited by st on Wed Feb 15, 2012 6:46 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Fri Sep 26, 2008 4:34 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
You want lens flare? You'll have lens flare :D
I'll try to do one lens-flare test quite soon, but I can not guarantee you it would be added to raydium as an official feature.


Top
 Profile  
 
PostPosted: Fri Sep 26, 2008 6:23 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Ok, first try ready.
http://www.guadagames.com/versusrx/lensflare.tar.bz2

It's highly improveable(exists this word?) but it's something to start from.

You can use (theorically) even a few lights.
Color set is useless right now.


Top
 Profile  
 
PostPosted: Sat Sep 27, 2008 1:10 pm 
Offline

Joined: Tue Jul 08, 2008 2:37 am
Posts: 181
I love it! :shock:

It looks very impressive, even for a first try, this is really a good point to start from, thank you vicente.
I'm a huge fan of lens flare effects in games. I would be quite agreeable to have such feature integrated within Raydium, so everyone can easily use this effect whenever wanted.


Top
 Profile  
 
PostPosted: Sat Sep 27, 2008 9:23 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Well, in good games lens flare are quite complex.
Most of then are composed of 3-8 layers of effects.
And a few ones are "different". For example the common lensflare has a circular generator (and a system more or less similar to the "thing" I have done in that code), however, for example, in the beta of Killzone 2:
They take the HDR map of the full frame (all with more than a certain bright). Then they reverse the image in X and then in Y (surely just they would change the order of vertex coordinates). And then they apply it a few times changing the scale and color.
Resulting this kind of effect:
Image
Image
The better part of this way of making a lensflare is that you don't need a lensflare system. It's all done in one (maybe two) functions called in the render pipeline and it's always working with the same perfomance, it doesn't matter how much lights, brights or whatever are in the frame.


Top
 Profile  
 
PostPosted: Sun Sep 28, 2008 9:15 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
vicente, you start talking like a 3D engineer, it's quiet frightening ! ;)
I must said that I've tried a few times to write a quick'n dirty lens-flare FX for Raydium: it doesn't work (for me, at least).

I discovered that a full lens-flare FX need quiet a lot of work: occlusions, "screening" lines, dynamic size and color tweaking, ...

Note that I'm not trying to scare you ! :) This FX is a must have for the engine, but we must have a good planning of this feature before starting to write it.

BTW, you demo is very good. With a few more layers, we have a nice start for the visual appearance !


Top
 Profile  
 
PostPosted: Tue Sep 30, 2008 2:03 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Well :)
  • Occlusion test done
  • Blue glow done
  • Red star+glow done
  • Halo done
You can check the new version:
http://www.guadagames.com/versusrx/lensflare2.tar.bz2
ImageImage
But yes, it will take a long to tweak all values,turns,sizes, alphas to good values.
And also I'd like to try the killzone2 way of lensflare.


Top
 Profile  
 
PostPosted: Tue Sep 30, 2008 2:38 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
Very nice, looks pretty !

As usual, may I point a few things ? :) (I know it's a very very pre-alpha, of course)
- Indentation broken :)
- some unused variable
- textures should be 8 bits, not 24 (use less memory, and then you don't need to change raydium_texture_blended[] attribute)
- rendering context broken, see in-game console for instance. Blending function ?
- it seems that there's some sort of modulo on the size of one halo. When you start looking away from the sun, you can see this halo "coming back" (I can post a capture, if you want [because I'm not sure to be understandable here])

But again, it's a very good start. The idea can now be to be able to setup lens-flares with files, like we did for particles. It could be great if we can use this effect for various things, like this sun lens flare, but also for car headlights, or explosions, for example.


Last edited by Xfennec on Tue Sep 30, 2008 2:43 pm, edited 1 time in total.
added a point about unused vars, and added my "alpha" warning, because this post was quiet rude, and that's not what I wanted at all ! :)


Top
 Profile  
 
PostPosted: Tue Sep 30, 2008 3:07 pm 
Offline

Joined: Tue Jul 08, 2008 2:37 am
Posts: 181
As already written on IRC, I must fly through cocorobix the whole day now, watching this effect. :D
I really like the idea to load from files, to be able to use it for multiple choices. Nothing to add to the list yet.

I have not tested it, but what about reflections on e. g. water shaders?
ImageImage


Top
 Profile  
 
PostPosted: Tue Sep 30, 2008 4:18 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
st: IMHO, water reflection is related to the scene, not to the lens-flare effect.
In other words, when building a scene, we just should take care of a few things like skybox's sun (if any), lens-flare position, Raydium light(s) and water shader lighting (and most of the time, shaders use OpenGL light positions).

We can probably render scenes that looks like your picture. Or tries to look like. :) That could be a nice project, in facts !


Top
 Profile  
 
PostPosted: Tue Sep 30, 2008 4:34 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Ok, new version:
http://www.guadagames.com/versusrx/lensflare3.tar.bz2

-Indentation (fixed, but not raydium style yet)
-variables unused (fixed, but pt will be used soon)
-8 bits textures are not working for me in this matter... Maybe i'm doing something bad.
-rendering context broken???
-Yes, please, screenshoot will be nice :)

And:
-New "animated rays" effect added
-I'm preparing an adaptative effect so the lensflare won't be directly shown if it appears suddenly (after exiting a cave or something like that).
-And I'm thinking about the anamorphic lensflare (screening lines)...

ImageImage


Top
 Profile  
 
PostPosted: Tue Sep 30, 2008 4:47 pm 
Offline

Joined: Tue Jul 08, 2008 2:37 am
Posts: 181
WOW - and I really mean WOW! Brilliant work. Looks fantastic.


Top
 Profile  
 
PostPosted: Tue Sep 30, 2008 8:01 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
About the "modulo halo", I tried to make a small animation:
Image
You should probably do the test by yourself to see exactly what I mean.

About rendering context: look at the lens flare while the console is down, you'll see what I mean. I think that your glBlendFunc() call is the origin of the problem, since you don't restore original blending function at the end of your rendering.

Small snippet of code, to show indentation, just to be sure we talk about the same thing ;)
Code:
void function(int a, int b)
{
int c;
for(;b<10;b++)
    {
    c++;
    a++;
    if(a==10)
        {
        // ...
        }
    }
}


I'll have a look quickly about the blended 8 bits textures ... It should work, there's something wrong somewhere :)

PS: rotating halo effect is very good ! It makes things way less "static" than more lens flare implementation I've seen.


Top
 Profile  
 
PostPosted: Tue Sep 30, 2008 9:18 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
Me again (2nd post in a row)

I dived a bit in your code, about 8 bits textures that does not work. The thing is that you use glBlendFunc(GL_ONE, GL_ONE) blending, so every incoming fragment is added to the color buffer, whatever the incoming alpha is. Some sort of non-blending blending ;)

In your case, it seems more suitable to use glBlendFunc(GL_SRC_ALPHA, GL_ONE), so you can use alpha, to do what he is supposed to do: blending.

I've just tested, with this change, it seems to works OK with 1 byte per pixel textures. A small warning about "lensflare-rays.tga": you'll lost the blue color of this texture when switching to greyscale, so you must give this blue color during rendering, I think.

About rendering context, you'll have to restore default blending (glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)) after rendering. You must also avoid using raydium_osd_color_rgba() since it's a some sort of "user space" function. When you call it internally inside Raydium, the user lost he own OSD color. You should probably use glColor4fv() directly, just after texture preparation. (then remove it from raydium_osd_draw_quad() perhaps ? We should think a bit more about this last function, IMHO.)

Do no hesitate to tell me that this post is not really understandable if it's the case ! ;)

edit: there will be some optimizations to do (glBlendFunc can be called once for all, for instance)


Top
 Profile  
 
PostPosted: Tue Sep 30, 2008 9:52 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
ok, all noted.
I'm working in a new version.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 48 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 26 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