Hard Light Productions Forums
Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Vidmaster on September 24, 2012, 10:30:27 am
-
How exactly does the engine actually do that? Is every single shot really a light source? I cannot believe that :)
To me, it looks like it is only every third or forth one when firing something fast. And how could it be? I mean, when hundreds of shots and missile are flying around it would be overkill for the rendering loop. And, aiming to avoid loops in shaders, one would have to swap out the shaders constantly, depending on the number of light sources.
I know the OpenSource concept but really, I have never looked into the FS2 code before and thus I think it is probably faster if I just ask this question here.
How does the SCP engine handle the dynamic light source thing?
-
This is all something that will be solved by deferred lighting actually.
-
If you are not using Valathil's deferred lighting builds, the engine is limited to 8 active light sources. Each laser, beam, missile etc is still a potential light source, but the engine only take the 8 most relevant ones.
If you use a deferred lighting build, then indeed they all are actual light sources. For great justice.
-
Clarification: 8 light sources for any one object being illuminated.
I think.
-
Clarification: 8 light sources for any one object being illuminated.
I think.
I was under the impression it was a global limit
-
Clarification: 8 light sources for any one object being illuminated.
I think.
I was under the impression it was a global limit
It is a global limit. What Matt said is exactly how it works, with one amendum, projectiles in particular are grouped by the code so that only a single group is considered a lighting source, not each bolt, this is to cover the (common case in FS) where you have a group of bolts all travelling together.
Also note, that the 8 active lights can change every frame, so the engine is always rescoring the lights to find the most relevant and "best" place to light them (say when they are just passing another ship).
Of course this all goes out the window with Valithil's deferred lighting test builds.
-
GL_Light has may be more than 8 depending on the Graphics Card, but 8 is the minimum. So yeah, that makes sense.
Each laser, beam, missile etc is still a potential light source, but the engine only take the 8 most relevant ones.
That's exactly my question, HOW does it do that? Closest too the player?
-
Magic, really.
In pseudocode, what it does is I think something like this:
For every object
Add all directional (i.e. sun) lights to render queue
For all lights within object radius
add light to render queue
But yes, all of this bs is going away once deferred lighting is on the table.
-
ah, so it is per object. Makes more sense!
-
If you want a little history about the lighting system and the crazy things that went on in there before I patched a lot of little things in there you should swing by IRC. I can tell you stories man.
-
on the same topic, lighting from missiles flag doesn't seem to do anything, it might just mean that the models will receive light.
deferred lighting and shadows are going to upgrade this engine considerably :yes:
-
If you are not using Valathil's deferred lighting builds, the engine is limited to 8 active light sources. Each laser, beam, missile etc is still a potential light source, but the engine only take the 8 most relevant ones.
If you use a deferred lighting build, then indeed they all are actual light sources. For great justice.
There is a deferred lighting build?!? :eek2:
Link please! :o
Nevermind.
Valanthil, you're a true wizard.