Author Topic: Light emitters  (Read 7793 times)

0 Members and 1 Guest are viewing this topic.

Offline Aardwolf

  • 211
  • Posts: 16,384
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.

I'm an OpenGL programmer!

Although I've never (successfully) done shadows. And as far as "spare time"... not so much.

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
So you reminded us of something most of us already know, to be of no help.  :P
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 Aardwolf

  • 211
  • Posts: 16,384
Well, fine then. See if I care that FS2 hasn't got shadows or multilights 5 years from now... :P

 :nervous:

Yeah ok, I would care.  :(

 

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
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.
The git test branch ("go_faster") that I was playing with earlier this year did actually have basic support for that.  It would detect if the hardware was SM2, SM3 or SM4 capable and set a define in the shaders.  You could then add #ifdef'd features requiring better hardware support to the shaders.  It makes the shaders kind of crap, due to so much code in them, but it is something that would work.

One of the main goals of the new shader code (what I had planned for 3.7) was to use a tbl type of thing which could reference different shaders for different detail levels and different hardware.  You could then write clean shaders for each level of hardware support and even different detail settings (such as conditionally enabling per-pixel lighting).  Obviously that isn't going to ever come from me at this point, but it's probably worth mentioning in case somebody else feels like taking a crack at it later on.

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.
I did some state stuff for the current shader code to try and squeak out a little bit of extra performance from it all.  It was pretty basic, and didn't help a ton, but it was better than leaving it the way that it was.  In my previously mentioned test branch I tried to clean things up a little bit more as well.

But the main purpose of that test branch was a proof of concept for improving rendering performance with as little code and time investment as possible.  That was primarily fixing the VBO stuff to work in a remotely efficient manner.  The way it was coded originally was so that each subobject of a model had it's own index buffer and VBO.  That may very well be the worst possible way to implement something like that because changing those buffers is one of the most costly operations you can do.  I rewrote the code a bit to use a single IBO and VBO per model, eliminating the buffer switch when rendering except for the one buffer setup when you call model_render().  On small ships like fighters the performance improvement was easily measurable, but it wasn't that big (avg. 20-40 FPS boost).  On large ships with a lot of subobjects the performance improvement was massive, in some cases giving a 3x boost.  And this was just in the lab, so you can imagine how better it would perform in-game when you have numerous big ships each having the  performance enhancement.

And I worked on that code for about 3-4 days, so it wasn't a big time investment either.  There are lots of little changes like that, and maybe a few slightly larger ones, which can be made to the current code that can really help out performance wise.  Mostly just cleanup, but things like better object sorting and an early-Z pass should provide a sizable performance improvement with shaders (the old render setup is too brute force, far too many things are textured, lit and rendered without ever been seen).  No massive rewrite needed. ;)

Actually, missile and flak explosions are implemented as particles, which can't/don't give off light.
I might have been thinking about my old Xt tree then.  I reworked lighting on quite a few things (like changes for subspace stuff, and various other items) but never got it working 100%.  It was too many code/quality changes for the intended purpose of the code base though (ending up as 3.6.10, when it has it's original release date of June/July 2007) and I ditched the code.

Still, adding such a feature shouldn't be a big deal for someone to do.

 

Offline Swifty

  • 210
  • I reject your fantasy & substitute my own
Quote
But the main purpose of that test branch was a proof of concept for improving rendering performance with as little code and time investment as possible.  That was primarily fixing the VBO stuff to work in a remotely efficient manner.  The way it was coded originally was so that each subobject of a model had it's own index buffer and VBO.  That may very well be the worst possible way to implement something like that because changing those buffers is one of the most costly operations you can do.  I rewrote the code a bit to use a single IBO and VBO per model, eliminating the buffer switch when rendering except for the one buffer setup when you call model_render().  On small ships like fighters the performance improvement was easily measurable, but it wasn't that big (avg. 20-40 FPS boost).  On large ships with a lot of subobjects the performance improvement was massive, in some cases giving a 3x boost.  And this was just in the lab, so you can imagine how better it would perform in-game when you have numerous big ships each having the  performance enhancement.
That's really encouraging to hear because I've coincidentally thought about about changing the VBO arrangement from one per subobject to one per model. Diaspora has some very subobject heavy models which is likely murdering our framerate.

But here's a question that's been nagging at me for a while. Is there a size in which the vertex buffer becomes suboptimal? I've heard some wildly diverging figures on this question. How well do you think would a vertex buffer with 100,000 polys run? Probably better than switching buffers between a 100 or so subobjects? :P

Quote
And I worked on that code for about 3-4 days, so it wasn't a big time investment either.  There are lots of little changes like that, and maybe a few slightly larger ones, which can be made to the current code that can really help out performance wise.  Mostly just cleanup, but things like better object sorting and an early-Z pass should provide a sizable performance improvement with shaders (the old render setup is too brute force, far too many things are textured, lit and rendered without ever been seen).  No massive rewrite needed.
For the early-Z test, would you suggest using ARB_occlusion_query?

Where can I find this go_faster branch? :D I'd like to bring over some of these optimizations and improvements.

 

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
But here's a question that's been nagging at me for a while. Is there a size in which the vertex buffer becomes suboptimal? I've heard some wildly diverging figures on this question. How well do you think would a vertex buffer with 100,000 polys run? Probably better than switching buffers between a 100 or so subobjects? :P
Optimal size is about 2meg, according to OpenGL docs.  And it needs to be properly aligned as well.  The general rule is to have as few VBOs as possible and just use offsets to change the render data.

I didn't set it up in my tests for size, just to lower the count and reduce the number of low poly counts in each buffer.  So even with what I did there is still some room for improvement.

Quote
]For the early-Z test, would you suggest using ARB_occlusion_query?
You really just need to render the scene once with depth writing enabled and pretty much everything else disabled.  Then render normally with depth reading and it should just use the depth buffer to avoid rendering all of the polys that wouldn't otherwise be seen.  A google search should turn up something a bit more detailed, but there really isn't much more to it.  Transparency will be an issue, and that's where better sorting would be needed, but otherwise it's pretty simple.

It's really pretty horrible how the code is now, rendering all of the subobjects with full texturing and lighting, then rendering the hull over them.  You almost never get to see any of that stuff and it completely wastes the GPU cycles.  With the depth culling it should allow the shaders to skip processing all of that useless junk and just discard it.

Quote
Where can I find this go_faster branch? :D I'd like to bring over some of these optimizations and improvements.
It's just a branch in my local git repo.  I'm going to post a diff of it at some point, and detail the changes as well as how others can continue those types of changes, I just haven't gotten around to finishing a few things.  I don't think that it will be good enough for committing to trunk, or even Antipodes, but it should be something that the rest of you can build off of and maybe work towards getting it somewhere in SVN.  Just keep a watch in the internal forum the next few weeks, it should be posted before the month is out (I hope). :)

 

Offline Swifty

  • 210
  • I reject your fantasy & substitute my own
Quote
It's just a branch in my local git repo.  I'm going to post a diff of it at some point, and detail the changes as well as how others can continue those types of changes, I just haven't gotten around to finishing a few things.  I don't think that it will be good enough for committing to trunk, or even Antipodes, but it should be something that the rest of you can build off of and maybe work towards getting it somewhere in SVN.  Just keep a watch in the internal forum the next few weeks, it should be posted before the month is out (I hope).
Sure! In the meantime, I'll try to replicate your VBO enhancements since it doesn't seem like it's too complicated of a change and also Diaspora desparately needs that right now. Unless it's not much trouble to ask for a quick diff for that specifically. ;7


 

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
It's not really all that quick of a change actually, it's more of a rewrite of the feature.   Also it breaks IBX files and starfield rendering, the two things that I haven't finished getting working again.  I don't want to post it publicly but I don't mind e-mailing you the current diff if you want to have a look at it.

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
I would be interested in said diff as well.
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
I should have it posted in the internal forum sometime next week.

 

Offline Nighteyes

  • 211
so back on topic, how hard will it be to add lights to explosions from missiles and such? as in setting these explosions to be "fireballs"(like fighter explosions, those do give off light) instead of particles...

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Given that, under the current renderer, only 8 lights per scene are rendered, chances are these wouldn't be all that notable.
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
so back on topic, how hard will it be to add lights to explosions from missiles and such? as in setting these explosions to be "fireballs"(like fighter explosions, those do give off light) instead of particles...
It wouldn't be hard at all, but as has already been mentioned, the engine currently only renders 8 lights per-pass per-object.  So even if light sources were added to missiles and such the chances of actually seeing it would be next to zero, and pretty much absolute zero in the case of an actual battle where those lights sources would most likely to be generated.  It would essentially be adding code to the game for the sole purpose of slowing things down and without any real graphical benefit what so ever.

 

Offline Sushi

  • Art Critic
  • 211
so back on topic, how hard will it be to add lights to explosions from missiles and such? as in setting these explosions to be "fireballs"(like fighter explosions, those do give off light) instead of particles...
It wouldn't be hard at all, but as has already been mentioned, the engine currently only renders 8 lights per-pass per-object.  So even if light sources were added to missiles and such the chances of actually seeing it would be next to zero, and pretty much absolute zero in the case of an actual battle where those lights sources would most likely to be generated.  It would essentially be adding code to the game for the sole purpose of slowing things down and without any real graphical benefit what so ever.

Still seems to me that given the "priority" system for choosing lights, a missile passing close over the surface of a ship could make a difference. The bigger problem is probably that there is no way to have "small" lights that only light up part of a big ship, and also the fact that lights getting swapped in and out could result in some weird color flashing.

Hard to say for sure until someone tries it though.

 

Offline Nighteyes

  • 211
another big difference that this will make is eliminate the "bug" where these "particle" effects(flak, missile explosions...) dissapear from the screen without being completly out of view...
right now when the center of the particle is out of the screen, the whole particle stops rendering, now, if we have a big explosion you have about half an explosion suddenly stops rendering abruptly, looks very bad...
if it would render as a "fireball", not only will it render lights, but it will also render properly and will only stop rendering once the whole effect is off the screen...

*I've placed this "bug" in mantis a few months ago

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
It's really pretty horrible how the code is now, rendering all of the subobjects with full texturing and lighting, then rendering the hull over them.  You almost never get to see any of that stuff and it completely wastes the GPU cycles.  With the depth culling it should allow the shaders to skip processing all of that useless junk and just discard it.

something i asked for at some point and was shot down by almost everybody was to have subobjects lod levels determined based on its distance from the camera rather than their parent ship's current lod. on a ship thats about 2-3 km long, and looking it from the front or back, some turrets would be incredibly close to the camera, while others would be up to 3 km away at minimum. its no substitute for completely omitting things that shouldnt be rendered, but it would help reduce the rendering overhead associated with subobjects.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
another big difference that this will make is eliminate the "bug" where these "particle" effects(flak, missile explosions...) dissapear from the screen without being completly out of view...
I'm not sure how adding light sources to particle effects would do anything to fix the only real flaw of point sprites.  :confused:


something i asked for at some point and was shot down by almost everybody was to have subobjects lod levels determined based on its distance from the camera rather than their parent ship's current lod. on a ship thats about 2-3 km long, and looking it from the front or back, some turrets would be incredibly close to the camera, while others would be up to 3 km away at minimum. its no substitute for completely omitting things that shouldnt be rendered, but it would help reduce the rendering overhead associated with subobjects.
I don't believe many models are actually designed to allow that to work.  It can't tell that something is a turret for instance, so it would have to apply the lod change logic to every subobject on the model and I don't think that would work out so well visually for most models.  Using render boxes would be the best way to address that particular issue, since then it would be up the modeler how it would work rather than leaving it to the game (which would more often than not get it wrong).

 

Offline Nighteyes

  • 211
I'm not sure how adding light sources to particle effects would do anything to fix the only real flaw of point sprites.  :confused:

well, the idea was not to simple add lights to the particles, the idea was to tell the engine to render these effects as it renders "fireballs"... not as particles, as adding lights to particles will not help us much, as you have tons of them on missile trails, thrusters, damage trails and such...

  

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Fireballs are rendered in a fixed point in space though.  Particles move, so the lighting setup will have to be through the particle system in order for the light to move with the particle.  It wouldn't be for everything either of course, we would just set a flag when the particle is created that it should emit light and that would be easy enough to do just for flak explosions and missiles or whatever.