Author Topic: Light emitters  (Read 7842 times)

0 Members and 1 Guest are viewing this topic.

Offline Nighteyes

  • 211
I think a neat addition that can be implemented is more lights on stuff, like muzzleflashs, missile explosions, and capship engines, how cool would it be to have a blueish hue on fighters when flying close to capships engines? :P
« Last Edit: September 15, 2010, 07:45:33 am by Jeff Vader »

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
There's some engine limitations with the number of available light sources.  We're slowly working towards being able to add a lot more though.
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

 

Offline Nighteyes

  • 211
hmm ok... so how about shadows? :D

  

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Shadows are not possible at the moment without causing a massive performance hit. Get us someone who knows OpenGL very well, and we can talk about it again.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 
Shadows are not possible at the moment without causing a massive performance hit. Get us someone who knows OpenGL very well, and we can talk about it again.
Shadows also need lightsources, so currently only shadows would become from suns at the moment.
What would be possible is using glowmap for GI like effects within ships.
First paint Basic Glowmap, then render GI to texture with rendering probram and add on top of the previous glowmap.

This would mean that lights from portholes and such actually would light the ship.

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Lasers are light sources as well, in case you didn't notice.

And again, unless you are or happen to know an OpenGL programmer with lots of spare time who can make this happen, it's not going to.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline Sushi

  • Art Critic
  • 211
Lasers are light sources as well, in case you didn't notice.

And again, unless you are or happen to know an OpenGL programmer with lots of spare time who can make this happen, it's not going to.

What happens if we just bump the max number of "laser-like" light sources? How many can we add before the engine starts to choke?

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
I thought a light source is a light source, period.
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
What happens if we just bump the max number of "laser-like" light sources? How many can we add before the engine starts to choke?

It's not so much the engine as the Shaders. OpenGL 2, IIRC, allows for a max of 8 lights per scene, which the current mvp shaders are using fully. More lights are possible (the data just has to be passed to the shaders properly) in OGL 3/GLSL 1.3+. Now, I have no idea what the performance implications are, but what I do know is that it's already hard enough to make the shaders work. (And since I am personally comitted to trying to make shaders work on OpenGL 2 and GLSL 1.2, I have not much incentive to work on higher-end shaders).
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
OpenGL can render 8 lights in hardware per pass.  More render passes mean more lights on an object, but at a performance cost.  Without shaders the code can handle up to 5 render passes pretty well.  With shaders it can do just one relatively well.

FSO itself still processes something like 256 lights per pass though.  That is done per the older software rendering, and the HTL graphics code doesn't use all of that lighting info.  It is possible to change the code to use it however, rendering 8 (or less) lights in hardware and using vertex coloring for the remaining lights all in a single pass.  The lights over the first 8 wouldn't look as good of course, but they would work and would allow for all 256 in a scene that the game processes to be used.  The performance hit should be minimal using this method but I haven't tested it myself so I can't say that for sure.

Of course the biggest performance hit with the current shaders is the lighting.  By having 8 lights in there all of the time the instruction count on the vertex shaders is very high and that makes them very slow.  For instance, in the ships lab, if you trim the shaders to only do one light (since the lab only has one light anyway) you can get a 5-10x FPS boost.  The shader code as originally coded was intended to have three sets of each shader, each supporting a different number of lights: 1, 2 & 4.  Using that combination it would then be possible to render using a maximum of 2 passes and still get all of the lights.  The shader complexity would be a lot less which also would provide a noticeable performance boost, particularly if you only needed a single pass.  Unfortunately the renderer is too old and slow to handle multiple passes with shaders without a very large performance hit.  The code was subsequently trimmed down to what eventually got put in SVN.

I did work on that performance hit a little earlier this year, to take one last crack at it.  Although the reworked code did help a bit (7-180+% performance boost depending on the model) it still had some issues with multi pass.  Also, the reworked shaders were still a little too instruction heavy for good SM2.0 level hardware support, with them being about a dozen instructions too big with the 4 light shader.  Cutting it to 3 lights max, with up to 3 passes for all of the lights, does work with SM2.0 level hardware but has a performance hit that makes it a bit slower than the current code/shaders.  The reworked code could do 2 passes at relatively the same performance of the current code, but no more.


So the point I guess is that: the game processes 256 lights at a time, it will only render 8 of them per object each pass, it would be possible to use all 256 lights with shaders but with a slight hit to visual quality, the reason for the 8 light limit is a hardware performance thing, the engine was designed for software rendering of low-poly models and is set up in a way that is rather inefficient for shader use, the way that our shaders handle lighting is stupid.

It is possible to address these issues, to remove some of the brute force from the renderer so that it is better set up for using shaders, but no one has done it.

 

Offline Kolgena

  • 211
Shadows are not possible at the moment without causing a massive performance hit. Get us someone who knows OpenGL very well, and we can talk about it again.
Shadows also need lightsources, so currently only shadows would become from suns at the moment.
What would be possible is using glowmap for GI like effects within ships.
First paint Basic Glowmap, then render GI to texture with rendering probram and add on top of the previous glowmap.

This would mean that lights from portholes and such actually would light the ship.

I think we already simulate this with a couple assets. Look to the engine section of the Iceni, and the original glow maps of the Hatchepsut (the current glow maps of the official models botched the porthole lighting)

 

Offline Sushi

  • Art Critic
  • 211
Very informative post

Very interesting, thanks.

I think it might be interesting to try raising that 256 limit and/or allowing missiles/missile explosions/flak explosions to emit light as well. We'd still be limited to 8 lights per object, but IMO that's probably plenty anyway. I believe that Nighteyes' goal is not to have more lights per object, but to just have more potential light sources... and I agree that it could potentially be very cool. From what you've said, it looks like the performance impact of doing so might even be pretty small.

 

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
I think it might be interesting to try raising that 256 limit and/or allowing missiles/missile explosions/flak explosions to emit light as well. We'd still be limited to 8 lights per object, but IMO that's probably plenty anyway. I believe that Nighteyes' goal is not to have more lights per object, but to just have more potential light sources... and I agree that it could potentially be very cool. From what you've said, it looks like the performance impact of doing so might even be pretty small.
Of those 256 lights we only ever use 8, so that really isn't a limit worth bumping since it wouldn't do anything.  And I believe that explosions from flak and missiles do give off light already.  Might have to check the code to be sure, but I am pretty sure that they are fireballs and fireballs give off light.

Lights are sorted based on type, intensity and size, so we have to keep that in mind when adding additional light sources.  In general you only have 7 lights to work with (since the sun, at least one almost always present, takes a light).  The big stuff has lights already and giving small stuff lighting as well would just be a complete waste of CPU time since they would get processed but never used.  Also, since lights are sorted in priority order you don't want to add little light sources to models since they would flicker on and off in battle and what not.

Somebody just needs to give colored vertex lighting a try, to render the lights past the first 8, and see if it is worth it from a visual/quality standpoint.  I think that DaBrain has previously made a post requesting that as well.  I believe that it should only require code changes, with the vertex color already being passed to the current shaders.

 

Offline BlackDove

  • Star Killer
  • 211
  • Section 3 of the GTVI
    • http://www.shatteredstar.org
One thing that may or may not be related to this, though I've had it in my mind for some time;

You mentioned Shader 2.0 and I think we're up to 5.0 right now though everyone uses 4 because that's what the consoles allow.

I was thinking as time progresses, shouldn't you make bigger demands on the hardware? While I do like that my five year old computer can run the game with all options on at 60 frames per second in 1080 (and I can even force AA on with great results), I do find it somewhat odd that the performance hit on it isn't bigger, and that it still passes muster as far as "demands" are concerned.

Not that it's lost on me that you would have to do all kinds of hard work and coding from scratch for some/all of the stuff, but I was wondering if there's any bar that you guys keep raising as time goes by with regards to how much you push existing hardware?

Using my rusty piece of **** to achieve optimum results is kind of criminal.

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Ideally, I think we'd have a system that detected the optimum shader set for your hardware, but that would requiring having a great many shaders available and a detection mechanism.  Maybe we will have that at some point, but right now we're trying to optimize the current experience for the most hardware we can.
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

 

Offline BlackDove

  • Star Killer
  • 211
  • Section 3 of the GTVI
    • http://www.shatteredstar.org
What about just general settings the user could define, like FS2's Option/Detail config? Just instead of cranking it up to 11 and it working on old hardware, when you crank it up to 11, a hexacore Nehalem rig with a SLI Geforce 480 causes Fermi Fire to burn down the dancefloor house?

Not that I'm complaining or anything, since I don't really understand what it's like to build on old code intended for something completely different and having the first rule be that you're supposed to make it work on a majority of hardware.

However as time obviously goes on, and as far as visual fidelity goes, it's obvious that FSOpen is getting left behind if it's not attempting to max out the newest hardware. I was just wondering if there are steps planned to address that, or is that just unimportant in the grand scheme of things?

I mean taylor mentioned performance hits, but what are we talking about here? Performance hits to what? Five year old hardware? Is that not okay? And if not, why? Shouldn't it be logical to raise the bar?

 

Offline Nighteyes

  • 211
what Sushi says is what I mean, I want flak explosions, missilehits, muzzleflashs and other effects in the same nature to cast light when going off, I tested it and this is not currently working, while on the other hand ship explosions do cast light... they are not all defined as "fireballs" as you say...
and from what I read here, adding this feture will not hurt preformance one bit, as its always the same amount of lights being generated

 

Offline Swifty

  • 210
  • I reject your fantasy & substitute my own
When taylor is talking about performance hits, it's relative to everything. If you have an inefficient algorithm, it's going to be inefficient and slow no matter what machine you're running it on.

Keep in mind that graphics isn't a wholly a GPU thing. The CPU has to tell the GPU what it needs to do which takes up a huge amount of processing on the CPU side. FSO has to go through each object and set up the render states, vertex buffers, materials, and shaders before finally doing a draw call. It's entirely on the CPU side up to that point.

With multipass rendering, you're rendering an object X number of times repeatedly but with different shader programs each time. Switching shader programs is an expensive operation. If you're doing multiple shader switches for each and every single object, that's going to be very expensive and even top of the line machines will likely slow to a crawl. Most modern game engines are smart with their material states and optimally sort all their draw calls based on material, texture, and vertex buffer to minimize the amount of state changes between render calls and subsequently minimize drawing time.

I'm not sure if not having a state sorting system is the core problem of FSO's but I'd like to think that it wouldn't hurt if we someday implemented it. Please correct me if I'm wrong, taylor.

 

Offline Sushi

  • Art Critic
  • 211

Of those 256 lights we only ever use 8, so that really isn't a limit worth bumping since it wouldn't do anything.  And I believe that explosions from flak and missiles do give off light already.  Might have to check the code to be sure, but I am pretty sure that they are fireballs and fireballs give off light.


Actually, missile and flak explosions are implemented as particles, which can't/don't give off light.

 

Offline Nighteyes

  • 211

Of those 256 lights we only ever use 8, so that really isn't a limit worth bumping since it wouldn't do anything.  And I believe that explosions from flak and missiles do give off light already.  Might have to check the code to be sure, but I am pretty sure that they are fireballs and fireballs give off light.


Actually, missile and flak explosions are implemented as particles, which can't/don't give off light.

thats probably also the reason they dissapear just before the whole effect leaves the screen, when the center of the effects is out of the screen(the particle), the whole effect just pops out of view...