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); In-development patch notes for Starsector 0.98a (2/8/25)

Author Topic: Center Projectile Glows at 0,0  (Read 10184 times)

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Center Projectile Glows at 0,0
« on: January 30, 2014, 09:38:40 PM »

Currently, glows are being centered at 0,0 for the projectile + the tail; this frequently looks really bad, as it displaces way behind the "head" of the projectile. 

Centering the glow on the core Sprite after rescaling makes a lot more sense and will fit most use cases better, imo.  Anyhow, just a minor graphics quibble thing but I think you'd be surprised how much difference it makes.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

kazi

  • Admiral
  • *****
  • Posts: 714
    • View Profile
Re: Center Projectile Glows at 0,0
« Reply #1 on: January 31, 2014, 12:40:03 AM »

Yes, please! This would be fantastic.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 25061
    • View Profile
Re: Center Projectile Glows at 0,0
« Reply #2 on: January 31, 2014, 08:34:33 AM »

This has been on my list to add as an option to projectiles; not sure if/when I'll actually get to it.

You'd be surprised how bad it looks if it's the default - any kind of reasonably bright glow washes out the projectile "bullet" graphic completely. There are probably ways to make it look good, and I'm sure it's the better way to go in some cases, but I don't think it's a good default.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Center Projectile Glows at 0,0
« Reply #3 on: January 31, 2014, 11:17:54 AM »

Can't it render behind the bullet?  I get that putting an additive above doesn't work well due to washout, but having the glow be in the center of a 100-pixel projectile doesn't work terribly well, either  ;)

Another option: instead of doing a particle glow point, simply make 5 copies of the projectile and scale them up while reducing translucency and multiplying by color, and then render them behind the projectile, for a cheap faux gaussian blur effect.  Might work.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 25061
    • View Profile
Re: Center Projectile Glows at 0,0
« Reply #4 on: January 31, 2014, 11:37:38 AM »

Can't it render behind the bullet?  I get that putting an additive above doesn't work well due to washout, but having the glow be in the center of a 100-pixel projectile doesn't work terribly well, either  ;)

The projectile is additive too, so it wouldn't matter.

Another option: instead of doing a particle glow point, simply make 5 copies of the projectile and scale them up while reducing translucency and multiplying by color, and then render them behind the projectile, for a cheap faux gaussian blur effect.  Might work.

Well yeah, lots of things *could* work :) In my experience, messing around with something like that until it does can take quite a long time, even if the initial idea is solid and doesn't need to change very much along the way.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Center Projectile Glows at 0,0
« Reply #5 on: January 31, 2014, 11:42:00 AM »

Ah.  Well, it could be a switch; heck, if we could access the SpriteAPI, we could just hack it ourselves.  Well, other than trying out the multiple copies thing, since there isn't a method to arbitrarily call / draw a Sprite, let alone declare its height and all that... er, nevermind, lol.

Anyhow, it's cool; for truly-custom, one-of-a-kind projectiles, we can just skip all that, set the length to 0, and do it all with the sprite graphic itself, of course, it just won't have any animated bits (unless we could do Sprite swaps, in which case we could) :)
Logged
Please check out my SS projects :)
Xeno's Mod Pack

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Center Projectile Glows at 0,0
« Reply #6 on: January 31, 2014, 06:44:34 PM »

Took a further look at this.

I'm pretty sure what the issue is (with it not looking so hot); it's using the "point" glow, instead of a really smooth gaussian glow, and the glow must get rendered first; after testing it appears that layer order matters (slightly).  The main thing though is the texture needs to not end up ramping the additive up a lot at the center.

I tried it out with a 256 texture glow just to see it, and it looks pretty good, using Linear Dodge mode in Photoshop (acts the same as Additive + translucency in OpenGL), then did another test with a more typical-sized bolt and an outsized glow:



In this example, we have three layers that would be the quads, from lowest to highest:  the red glow color, the red long trail (200% length and offset to match center) and the yellow projectile.  The key to getting a reasonable look is that, since it's additive, the secondary color and glow should not be the bright color- inverting the RGB values results in some washed-out yellows and very little red.

A couple of very fast-fading copies of the yellow and the red trails would probably be enough to make it feel nice and wiggly, but it'd probably work better to break up the quads into, say, 16 quads along the length and wiggle them a bit each frame.

I think that that would actually get it done, because then the additive effects and falloff would be a lot smoother.

I've also found out the giving the shots length 0 still has weird effects, although it works while in flight; the secondary color shows up when the shot hits something, which looks really weird.  So no glow, can't use length 0 (and any length > 0 means it's pretty much full length atm) and I tried out making one with inherent glow, but that bug kind of was a show-stopper for now :)

Anyhow, sorry if all of this is kind of lame carping about minor detail stuff; I just wanted to explore the issue a bit and see if there was anything simple that could make it work better :)
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 25061
    • View Profile
Re: Center Projectile Glows at 0,0
« Reply #7 on: February 01, 2014, 03:47:17 PM »

... after testing it appears that layer order matters (slightly).  The main thing though is the texture needs to not end up ramping the additive up a lot at the center.

I tried it out with a 256 texture glow just to see it, and it looks pretty good, using Linear Dodge mode in Photoshop (acts the same as Additive + translucency in OpenGL), then did another test with a more typical-sized bolt and an outsized glow:

Hmm. Not sure what you mean by "additive + translucency", it's one or the other, right? GL_SRC_ALPHA, GL_ONE (additive) or GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA (transparency... well, the most common way of doing it, anyway).

Mathematically, if you do additive, the order doesn't matter - the result is the same, since it's literally just adding to the destination color.

Anyhow, sorry if all of this is kind of lame carping about minor detail stuff; I just wanted to explore the issue a bit and see if there was anything simple that could make it work better :)

No worries, it's fun to mess with - I just don't honestly see devoting any time to it in the foreseeable future. Not with campaign-level stuff to do.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Center Projectile Glows at 0,0
« Reply #8 on: February 01, 2014, 03:59:20 PM »

Oh, IDK whether there's some slight difference between the Linear Dodge algorithm and OpenGL or not; according to what I read online, it's an almost perfect match, though.

I was actually going to do a writeup about this, as I think I've finally found a fix for all of the mini-issues.   For now, here's a sample .proj that doesn't have major problems (but no animations, so it's not quite as cool... but glows work):

Code

{
"id":"neutron_cannon_shot",
"specClass":"projectile",
"onHitEffect":"data.scripts.weapons.NeutronOnHitEffect",
"spawnType":"BALLISTIC",
"collisionClass":"PROJECTILE_NO_FF",
"collisionClassByFighter":"PROJECTILE_FIGHTER",
"hitGlowRadius":75,
"length":75,
"width":32,
"fadeTime":0.25,
"fringeColor":[255,100,0,0],
"coreColor":[175,255,0,255],
#"coreColor":[50,0,255,255],
"glowColor":[175,255,0,255],
#"glowRadius":75,
"bulletSprite":"graphics/missiles/neutron_cannon_bolt.png",
}


Screen of it working (shot is still a little un-polished, but you can see it's working correctly):

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

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 25061
    • View Profile
Re: Center Projectile Glows at 0,0
« Reply #9 on: February 01, 2014, 04:04:21 PM »

Oh, that looks very nice!

Oh, IDK whether there's some slight difference between the Linear Dodge algorithm and OpenGL or not; according to what I read online, it's an almost perfect match, though.

Ah - I'm guessing the difference you're seeing from switching the order is the "almost" part :) I have tried switching the order before, btw - iirc the first time I tried it, my reaction was, "well, this doesn't look any different, wonder what's going on here" which then led me to figure out the details.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Center Projectile Glows at 0,0
« Reply #10 on: February 01, 2014, 04:17:59 PM »

Yeah, I think this got it, finally, which is nice, because this is one of those things that adds a surprising amount of polish.  If I could swap it every frame with something slightly different, it'd even do the shimmering stuff.  Close enough for guvmint work, though :)

On Linear Dodge IIRC it handles translucency a slightly-different way, so the stuff I read said, "it's not quite exactly the same, but usually good enough".  It was really close, though, and whatever it looks like on black at the end is what it will look like in OpenGL.

Anyhow, with a little more polish...



Now I just need to get 'em all done, lol.
« Last Edit: February 01, 2014, 04:29:44 PM by xenoargh »
Logged
Please check out my SS projects :)
Xeno's Mod Pack

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Center Projectile Glows at 0,0
« Reply #11 on: February 01, 2014, 04:47:33 PM »

Star Wars style:

Anyhow, the example above works... only caveat is that you can't really use ridiculous levels of "bloom" around the shots, since it'll effect the total XY size of the bolt and that has some knock-on effects.  But within reason...
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Cycerin

  • Admiral
  • *****
  • Posts: 1665
  • beyond the infinite void
    • View Profile
Re: Center Projectile Glows at 0,0
« Reply #12 on: February 01, 2014, 06:54:24 PM »

Great work. It would be really cool to have a way to add phase teleporter-esque flickering to shot sprites!
Logged

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: Center Projectile Glows at 0,0
« Reply #13 on: February 02, 2014, 02:12:40 PM »

I would really appreciate learning how you did the 'Star Wars' style effect, I'd love to have that unique weapon effect for any faction I may or may not get around to making in the distant future.
Logged

notabot

  • Ensign
  • *
  • Posts: 16
    • View Profile
Re: Center Projectile Glows at 0,0
« Reply #14 on: September 06, 2022, 09:24:22 AM »

Star Wars style:

Anyhow, the example above works... only caveat is that you can't really use ridiculous levels of "bloom" around the shots, since it'll effect the total XY size of the bolt and that has some knock-on effects.  But within reason...

Behold, a necropost. But I as well would love to know how to make the starwars lookin' bolts

Edit: I saw you commented out glowRadius, so its just the bullet sprite? fooled me  :)
What about your other boolets though. Looked very nice. Did any of it end up in that modpack of yours? the FX bit says it makes no actual changes... would love to learn about this stuff and take a crack at it.
« Last Edit: September 06, 2022, 12:30:04 PM by notabot »
Logged