Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Simulator Enhancements (03/13/24)

Pages: 1 [2] 3 4 ... 27

Author Topic: [0.7.2a] ShaderLib Beta 1.2.1b (Legacy)  (Read 238435 times)

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: [Graphics] Dynamic Lights for Starsector! (ShaderLib Alpha v1.02)
« Reply #15 on: May 06, 2014, 05:25:16 PM »

Sure, lemme get the patch done / out.  Soon :)
Logged
Please check out my SS projects :)
Xeno's Mod Pack

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: [Graphics] Dynamic Lights for Starsector! (ShaderLib Alpha v1.02)
« Reply #16 on: May 06, 2014, 06:03:53 PM »

OK, tried another run, NPS is here.

1.  Re-tested, and confirmed that I'm seeing big CPU hits here.  It's not quite as bad as I feared (but wait); usage is just right around the same as the entirety of Advance otherwise (i.e., all the AIs and special systems and weapons code and Alex's code combined).

2.  Whatever is going on, it's causing huge surges in CPU at odd times.  

I'm seeing huge drops (like 30 FPS in a Sim fight between a Venture w/ drones vs. a Conquest) when certain weapons are firing, but not others.  Machinegun projectiles and rockets cause some big FPS hits, but the Glaug Thermal Gun, which obviously wouldn't be listed, doesn't, even though it was spitting out similar numbers of projectiles.  Beams appear to be moderately laggy inherently; just 4 HILs is a 10 FPS hit in a 1 vs. 1.

See the profile?  Yeah.  That wasn't what I was expecting to be the chokepoint, either :)

[attachment deleted by admin]
« Last Edit: May 06, 2014, 06:05:45 PM by xenoargh »
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2806
    • View Profile
    • Sc2Mafia
Re: [Graphics] Dynamic Lights for Starsector! (ShaderLib Alpha v1.02)
« Reply #17 on: May 06, 2014, 06:40:55 PM »

Your profiler output shows that the entire lighting engine is, in sum total, about 25% slower than LazyWizard's Combat Radar.  The lights comprise roughly 23% of the Starsector advance() pipeline's sum CPU cost.

In fact, your performance reports suggest that you are severely GPU-bottlenecked.  Beams, for example, are *easier* on the CPU than projectiles, but use a more complicated shader due to being line sources instead of point sources.  I ask again: what is your graphics card?  I need to determine what kind of graphics settings to include in later versions, since you seem to have found yourself beyond the point where the GPU bottlenecks the CPU.  Making beams lower-priority on the sorting list of death for which lights to draw and which to not draw seems like a logical first step, but is there anything you can recommend in terms of user settings?
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: [Graphics] Dynamic Lights for Starsector! (ShaderLib Alpha v1.02)
« Reply #18 on: May 06, 2014, 07:04:20 PM »

I'm using a Radeon 5700; most modern games are at acceptable framerates, although I can't push settings up to max on the very latest things.  I'm having a lot of trouble with the idea that it's the GPU, but I haven't read the GLSL so I have no idea how much filtering, etc. is going on there.

Anyhow, I guess I'll take a look at the lights setting and see where the limits are.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: [Graphics] Dynamic Lights for Starsector! (ShaderLib Alpha v1.02)
« Reply #19 on: May 06, 2014, 07:29:47 PM »

It's not the GPU, the CPU is definitely the bottleneck.

45 FPS, and there is only one live ShipAPI in this entire scene, and four beams.  The minute the beams are off, we're back to 60.  See the idle there?  It was 45%+ before the beams came on.

Logged
Please check out my SS projects :)
Xeno's Mod Pack

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2806
    • View Profile
    • Sc2Mafia
Re: [Graphics] Dynamic Lights for Starsector! (ShaderLib Alpha v1.02)
« Reply #20 on: May 06, 2014, 07:33:08 PM »

It can't possibly be a CPU bottleneck under those conditions.  It's the GPU.  It seems to be yet another issue with AMD cards, but it's hard for me to figure out why; I've tried GPU ShaderAnalyzer (AMD tool) and it just tells me the shader is within the bounds I expected it to be.

By the way, the idle % counter is inaccurate.  Check CPU usage via a monitoring tool or even just the clt-alt-del screen.  And I seriously suggest you look at your GPU load % via monitoring tool.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: [Graphics] Dynamic Lights for Starsector! (ShaderLib Alpha v1.02)
« Reply #21 on: May 06, 2014, 07:57:33 PM »

By the way, the idle % counter is inaccurate.  Check CPU usage via a monitoring tool or even just the clt-alt-del screen.  And I seriously suggest you look at your GPU load % via monitoring tool.

(The "% idle" is not CPU idle time and isn't intended to be. It shows the percentage of time the game spends sleeping. It doesn't differentiate between time spent on the GPU vs the CPU. So yeah, if you want to know what the CPU usage is, use an external monitoring tool.)
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: [Graphics] Dynamic Lights for Starsector! (ShaderLib Alpha v1.02)
« Reply #22 on: May 06, 2014, 08:19:38 PM »

If the GPU is the bottleneck here, then something is fundamentally borked, yeah.

This is why I bought ATi; if I have to rework stuff at home, I want to do it on the hardware most likely to have serious problems, lol.

Tested with an 8-light limit; same results.  15 FPS lost, and all I have is 4 lasers running.  

I still have nagging doubts, though, based on the specific function call in the profile; most of the time is spend on glCopyTexImage2D; that sets off some alarm bells; if you're just doing ping-pong, that's just one copy of the main frame buffer to the FBO...
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2806
    • View Profile
    • Sc2Mafia
Re: [Graphics] Dynamic Lights for Starsector! (ShaderLib Alpha v1.03)
« Reply #23 on: May 06, 2014, 08:27:28 PM »

I am a *** failure.

Yeah, it was glCopyTexImage2D; according to LazyWizard, there's a warning in the nVidia documentation (wut) that glCopyTexImage2D should always be substituted with glCopyTexSubImage2D on subsequent frames.  Apparently this is Graphics Coding 101 and I'm a phony.

Anyway, updated; see the OP.

Alpha v1.03 (May 6, 2014)
- Added method to LightData: void readLightDataCSVNoOverwrite(String localPath)
- Added method to ShaderLib: int getScreenTexture()
- Added "maximumLineLights" option to settings.json (default 50)
- Serious AMD performance issue resolved; will be slightly faster for nVidia users as well
« Last Edit: May 06, 2014, 08:35:36 PM by Dark.Revenant »
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: [Graphics] Dynamic Lights for Starsector! (ShaderLib Alpha v1.03)
« Reply #24 on: May 06, 2014, 08:30:52 PM »

Dude, it's cool; if this stuff was easy, everybody would do it.  Let's see if it's happy now.

<tests>
Logged
Please check out my SS projects :)
Xeno's Mod Pack

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: [Graphics] Dynamic Lights for Starsector! (ShaderLib Alpha v1.03)
« Reply #25 on: May 06, 2014, 08:35:38 PM »

Solid.  No lag, practically no performance hit. 

Haven't done a gargantuan profiling run yet, let alone trying for something like full implementation with Vacuum's weapons, to see just how laggy it gets... but it was like night and day with the simple test.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

FasterThanSleepyfish

  • Admiral
  • *****
  • Posts: 727
  • Blub
    • View Profile
Re: [Graphics] Dynamic Lights for Starsector! (ShaderLib Alpha v1.03)
« Reply #26 on: May 06, 2014, 09:03:53 PM »

I'm happy to report I have no more FPS issues with the latest dev. A solid 60 even with multiple ships!
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: [Graphics] Dynamic Lights for Starsector! (ShaderLib Alpha v1.03)
« Reply #27 on: May 06, 2014, 09:17:12 PM »

Did big profiling run (no full integration yet, that's going to take a few days, most likely), and it was an infinitesimal fraction of the entire load.  Great!  Now, that isn't full integration with all of the Vacuum weapons and all that, but baby steps...

So...

1.  Is there a generic way to call it from an EveryFrameCombatScript and create a light arbitrarily?  I'm thinking engines and other special FX stuff, like having a blinky light that's actually a light and doing lights procedurally (for example, ship deaths) and all that kind of thing where normally I've been using particles.

2.  Really would like an example of how to hook up the shader stuff to EveryFrameCombatScript or suchlike via the hook; this engine needs a fast particle system for ultra-lulz explosions.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2806
    • View Profile
    • Sc2Mafia
Re: [Graphics] Dynamic Lights for Starsector! (ShaderLib Alpha v1.03)
« Reply #28 on: May 06, 2014, 10:08:02 PM »

1. yourLight = new StandardLight();
LightShader.addLight(yourLight);

You can also make other LightAPI objects to add for any kind of custom behavior you want.

2. Just use the examples I show.  ShaderHook is an internal thing. Use ShaderLib.addShaderAPI(new yourShader());

yourShader implements ShaderAPI and does everything you want it to, which can include a particle system if you want.
Logged

billi999

  • Commander
  • ***
  • Posts: 149
    • View Profile
Re: [Graphics] Dynamic Lights for Starsector! (ShaderLib Alpha v1.03)
« Reply #29 on: May 07, 2014, 04:18:51 AM »

Is it possible to use additional sprites with the pixel/fragment shader with this? I can't stop imagining ships with RGB->XYZ normal maps to simulate 3D-like diffuse lighting.
Logged
Pages: 1 [2] 3 4 ... 27