Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: Advanced Starsector graphics modding  (Read 10413 times)

MesoTroniK

  • Admiral
  • *****
  • Posts: 1731
  • I am going to destroy your ships
    • View Profile
Advanced Starsector graphics modding
« on: January 25, 2014, 03:42:59 PM »

I know Open GL shader calls are being used to add new UI elements (LazyWizards Combat Radar), and I believe its possible to use similar techniques to do other things. I know that the downside to this is that will draw over anything, like UI elements and menus but the possibilities are endless for creating amazing looking graphics effects. The uses that occur to me right now is stuff like distorting the screen for shockwaves for high yield warheads and ship deaths.

Super deluxe explosion™
Spoiler
[close]

But the real prize to me is making ship systems completely over the top as a visual spectacle. For example Exigency Corporation's Repulsor field ship system. Right now it creates this swirling vortex of particles to represent its effective area, this gets the job done but what if so much more is possible? It did occur to me to make an animated sprite sequence, this would be a substantial upgrade certainly. But the real prize would be an insane swirling vortex that actually distorts what is already present on the screen. Somewhat like a gravitational lens but an entirely more chaotic and violent visual spectacle.

Repulsor shenanigans™
Spoiler
Current Repulsor graphics*


Desired graphics*


In case you wondering that .gif is from the game Zigfrak.
[close]

Anyways maybe this is all a pipe dream, if it isn't perhaps someone more knowledgeable on this subject could chime in :)
« Last Edit: January 25, 2014, 04:01:07 PM by MesoTroniK »
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Advanced Starsector graphics modding
« Reply #1 on: January 25, 2014, 05:57:14 PM »

Quote
I know Open GL shader calls are being used to add new UI elements (LazyWizards Combat Radar)
Not shader calls, unless he's done something new since the last time he made a release; using a shader requires access to loading, compiling and invoking GLSL fragment / pixel shaders.  He's just using straight OpenGL, which is not the same thing.

Not sure that the game supports that atm, but maybe GLSL could get read in via JSON or something. 

To do that kind of Fresnel stuff you're talking about, though, is fairly complicated (there are example shaders for that, but it's non-trivial to implement), and in the case of this engine, would need to be done with knowledge of what the engine is doing internally in terms of depth (you need to render this below the UI).

Anyhow, shader support would be cool, no doubt, for a few things at least.  But Alex has said repeatedly that that is not a priority, and I'm not sure if we're able to access that part of LWJGL or not.  LWJGL is certainly capable of dealing with GLSL shaders, so it may be possible; if yeah, then I might be able to do a few things at some later point.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

MesoTroniK

  • Admiral
  • *****
  • Posts: 1731
  • I am going to destroy your ships
    • View Profile
Re: Advanced Starsector graphics modding
« Reply #2 on: January 25, 2014, 06:06:48 PM »

Thank you for the reply Xeno, figures I was using the wrong terminology as I have no idea what I am doing at all regarding this. Well if its ever possible, it would be pretty badass 8)

etherealblade

  • Commander
  • ***
  • Posts: 134
    • View Profile
Re: Advanced Starsector graphics modding
« Reply #3 on: January 26, 2014, 02:35:01 AM »

This technology, if available/discovered, could make lazywizards blackhole weapon even more amazing...
Logged
Spoiler

[close]

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24103
    • View Profile
Re: Advanced Starsector graphics modding
« Reply #4 on: January 26, 2014, 09:07:41 AM »

But Alex has said repeatedly that that is not a priority

Actually, what I've said is that it's 100% not going to happen :) It breaks down like this: the game isn't using shaders, shaders are an all-or-nothing proposition, and there's no way I'm going to spend half a year rewriting everything to use shaders just for the heck of it.
Logged

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: Advanced Starsector graphics modding
« Reply #5 on: January 26, 2014, 09:38:09 AM »

Although it would be super cool, maybe for Star Sector 2? There is going to be a sequel right?

About the only thing I want to add via lazywizards API is a targeting pip, I'm slowly getting through all the API stuff. The rest is 'simple' vector math in theory.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Advanced Starsector graphics modding
« Reply #6 on: January 26, 2014, 11:32:42 AM »

@Alex:  My apologies, I didn't mean to misrepresent your position on this, I know that you've said "no" for good reasons :)

Anyhow, about the only one of us who's dug into doing that kind of stuff with LWJGL thus far is LazyWizard, so we simply don't know whether it's even possible to compile GLSL and compile it on SS yet :)  Past that point a bunch of complexity rears its head, due to how the rest of the engine is doing its thing, so this is definitely in "maybe but probably with a bunch of caveats category".
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24103
    • View Profile
Re: Advanced Starsector graphics modding
« Reply #7 on: January 26, 2014, 11:40:48 AM »

@Alex:  My apologies, I didn't mean to misrepresent your position on this, I know that you've said "no" for good reasons :)

No worries. What I said probably came across a bit more strongly than intended.

Anyhow, about the only one of us who's dug into doing that kind of stuff with LWJGL thus far is LazyWizard, so we simply don't know whether it's even possible to compile GLSL and compile it on SS yet :)  Past that point a bunch of complexity rears its head, due to how the rest of the engine is doing its thing, so this is definitely in "maybe but probably with a bunch of caveats category".

LWJGL supports shaders. But, since Starsector is using the fixed function pipeline, it's impossible to use shaders in Starsector. That would require rewriting the entire game to not use the fixed pipeline. That's what I mean by "all or nothing", either you're using shaders for everything, or you can't use them at all. Can't just use them for a special effect here and there.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Advanced Starsector graphics modding
« Reply #8 on: January 26, 2014, 11:46:38 AM »

Ah.  I was wondering about that; I haven't gotten into LWJGL's documentation far enough to know where that choice has to get made. 

OK, that still leaves a lot of stuff that can be done, though; pretty much anything you can do with a shader can be done on the CPU, it's just less attractive from a performance POV :)
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24103
    • View Profile
Re: Advanced Starsector graphics modding
« Reply #9 on: January 26, 2014, 11:54:28 AM »

To some extent, yeah. But you can't do some of the nice things like warping or distortion effects. I mean, I guess you could, but reading any large number of pixels, adjusting them on the CPU, and then writing them back is so unattractive as to not be a real option. Regardless of how quickly you can do it on the CPU, just the transfer time (and the fact that you're reading data from the video card) pretty much shut that down.

I experimented with some grayscaling effects using that approach, and we're talking seconds per frame even if applied to a relatively small portion of the screen... and it didn't seem like I was doing anything silly, everything I've seen indicated that was the "correct" way to do it given the circumstances, and that's just how long it took.


Although it would be super cool, maybe for Star Sector 2? There is going to be a sequel right?

Cart, horse. Not horse, cart. Unless you're going to the left, in which case definitely "horse, cart".
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Advanced Starsector graphics modding
« Reply #10 on: January 26, 2014, 12:47:35 PM »

Wow, I didn't know that a buffer read like that was so bad.  I've never tried that; last time I was writing GLSL it was part of the standard toolset, I didn't spend a lot of time with fixed-function pipeline stuff. 

So screen-warping is a non-starter, simply because of buffer access and processing time. 

That said, a similar-ish effect could be built, by grabbing the image data for the ships effected, using it on a multi-quad mesh and distorting the points over time with sin or a wave function or whatever, it just wouldn't have the really smooth look you can get with a normal map and fresnel and implementation would be a little more complicated :)
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24103
    • View Profile
Re: Advanced Starsector graphics modding
« Reply #11 on: January 26, 2014, 12:51:10 PM »

That said, a similar-ish effect could be built, by grabbing the image data for the ships effected, using it on a multi-quad mesh and distorting the points over time with sin or a wave function or whatever

Incidentally, that's exactly how the hyperspace background works, and it's surprisingly smooth-looking for how simple it is.
Logged

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2806
    • View Profile
    • Sc2Mafia
Re: Advanced Starsector graphics modding
« Reply #12 on: January 26, 2014, 02:44:10 PM »

Are fullscreen shaders possible?  After the screen is rendered, you can treat the whole thing as a RTT and apply shaders to it.  It would distort the UI, of course, unless you split the UI out of the main rendering pipeline (which would likely take a nontrivial rewrite of some of the rendering code).
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Advanced Starsector graphics modding
« Reply #13 on: January 26, 2014, 04:28:00 PM »

Quote
Are fullscreen shaders possible?
No, that's exactly what we were talking about.  If that stuff was possible, we could do bloom and filters and all that stuff, too.  Not possible; engine uses fixed-function pipeline and it's all-or-nothing, apparently :)
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2806
    • View Profile
    • Sc2Mafia
Re: Advanced Starsector graphics modding
« Reply #14 on: January 26, 2014, 04:39:27 PM »

From what Alex has been saying, it looks like he can't do shader calls within the rendering pipeline.  What I'm talking about would be a post-effects shader applied to the entire window, which according to my graphics coding experience is much easier to accomplish.
Logged