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 ... 5 6 [7] 8 9 ... 27

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

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2806
    • View Profile
    • Sc2Mafia
Re: [Graphics] ShaderLib Graphics Enhancement Mod (Alpha v1.2) (Bloom!)
« Reply #90 on: May 20, 2014, 02:05:43 PM »

That's because you are calling fadeIn and fadeOut immediately after the other.  Instead, call fadeInIntensity(0.1f) and then setAutoFadeIntensityTime(1.9f) and setLifetime(0), and make sure you're setting the animation to something, perhaps with setFrameRate(30f).
Logged

603bill

  • Lieutenant
  • **
  • Posts: 62
    • View Profile
Re: [Graphics] ShaderLib Graphics Enhancement Mod (Alpha v1.2) (Bloom!)
« Reply #91 on: May 20, 2014, 02:42:18 PM »

I've got an issue where the shaders don't line up with the ships.  I'd post some screenshots but I cant figure out how that business works.
Logged

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2806
    • View Profile
    • Sc2Mafia
Re: [Graphics] ShaderLib Graphics Enhancement Mod (Alpha v1.2) (Bloom!)
« Reply #92 on: May 20, 2014, 03:13:32 PM »

That's a known, and completely unfixable issue.  Unfortunately, you'll just have to deal with it until the render order fixes come in with the next Starsector update.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: [Graphics] ShaderLib Graphics Enhancement Mod (Alpha v1.2) (Bloom!)
« Reply #93 on: May 20, 2014, 04:49:20 PM »

@D.R. Cool, I'll try that.

<tries>

Success, at last! 

Code sample for the curious; this produces a nice fat distortion ripple over a 2-second period.
Code: java
        RippleDistortion distortion = new RippleDistortion();  
        distortion.setIntensity(45f); 
        distortion.setLocation(point); 
        distortion.fadeInIntensity(0.1f); 
        distortion.setAutoFadeIntensityTime(1.9f);
        distortion.setLifetime(0f);
        distortion.setFrameRate(30f);
        distortion.setSize(MathUtils.getRandomNumberInRange(500f,750f)); 
        distortion.fadeInSize(2f); 
        DistortionShader.addDistortion(distortion);
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2806
    • View Profile
    • Sc2Mafia
Re: [Graphics] ShaderLib Graphics Enhancement Mod (Alpha v1.2) (Bloom!)
« Reply #94 on: May 20, 2014, 05:16:25 PM »

I just remembered that it won't actually consider the lifetime is over until *all* fades are done, so these lines are actually doing nothing:

        distortion.setAutoFadeIntensityTime(1.9f); 
        distortion.setLifetime(0f);

Since it is producing an acceptable effect without fading intensity out, you can safely delete those lines.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: [Graphics] ShaderLib Graphics Enhancement Mod (Alpha v1.2) (Bloom!)
« Reply #95 on: May 20, 2014, 05:17:44 PM »

KK.  Will test as soon as I'm done with the other bit of the thing I'm working on :)
Logged
Please check out my SS projects :)
Xeno's Mod Pack

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: [Graphics] ShaderLib Graphics Enhancement Mod (Alpha v1.2) (Bloom!)
« Reply #96 on: May 20, 2014, 07:14:12 PM »

This looks really good with a couple of ripples as part of the whole thing :)
Spoiler
[close]
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: [Graphics] ShaderLib Graphics Enhancement Mod (Alpha v1.2) (Bloom!)
« Reply #97 on: May 20, 2014, 08:46:04 PM »

That's one gorgeous looking explosion.
Logged

Cycerin

  • Admiral
  • *****
  • Posts: 1665
  • beyond the infinite void
    • View Profile
Re: [Graphics] ShaderLib Graphics Enhancement Mod (Alpha v1.2) (Bloom!)
« Reply #98 on: May 21, 2014, 03:02:16 AM »

Nice bloom, too.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: [Graphics] ShaderLib Graphics Enhancement Mod (Alpha v1.2) (Bloom!)
« Reply #99 on: May 21, 2014, 10:36:19 AM »

Actually, I played with the bloom and it's at fairly conservative settings.  Bloom's going to be a little more important if we have per-ship / per-weapon materials.

I may write a custom bloom shader at some point, that's something I've done before and I'd like to play around with the filter taps and the ramps a bit to get it nice and tight.  Still just trying to get lights and stuff integrated atm, though; it's a pretty huge job with all these ships and weapons :)
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2806
    • View Profile
    • Sc2Mafia
Re: [Graphics] ShaderLib Graphics Enhancement Mod (Alpha v1.2) (Bloom!)
« Reply #100 on: May 21, 2014, 03:28:38 PM »

If you are interested in editing the bloom shader, it's in data\shaders\bloom: bloom1-5, bloom1-7, bloom1-9, bloom1-11, bloom1-13, bloom2-5, bloom2-7, bloom2-9, bloom2-11, bloom2-13, and bloom-3

The curves are pre-built constants (otherwise the shader would be far too slow, since it would need multiple exponential calculations per pixel), so this stuff can't be made parameterizable; you have to edit it in directly.  The current lighting and bloom functions:

1. Foreground objects are rendered to a buffer with a 0-alpha background

2. Lights, the current scene, and the foreground buffer are fed into light
2.a. Illumination = sum(light magnitude * light color) * foreground pixel alpha
This makes sure only ships and stuff in the foreground are lit; this will include weapon barrels and asteroids in the next SS update.
2.b. Output Pixel = clamp((scene pixel + min(scene pixel, foreground pixel) * Illumination) / hdr, 0, 1)
hdr is 256 with bloom on, and 1 with bloom off, since bloom requires HDR (which I interpret as a 48-bit image, which is probably overkill because that allows luminosity up to 256 times higher than what a 24-bit image can provide).  Anyway, this function is important because it makes darker parts of the ship less reflective, preserving contrast, detail, and depth, and also ignores damage glow, weapon hit sprites, etc. when doing this calculation, avoiding unrealistic over-brightness.

3. If bloom is on, the render from step 2 is fed into bloom1
3.a. Output Pixel = horizontalGaussian(max(lighting scene pixel - 1/256, 0) * hdr
This outputs a hdr over-brightness map, which has been blurred horizontally via a blur kernel; in other words, if all of the pixel's components fall below the maximum drawable range, no bloom will occur.  Bloom only occurs on pixels that are brightened beyond the displayable range.  Once again, hdr is 256.

4. The render from step 3 is fed into bloom2
4.a. Output Pixel = verticalGaussian(max(horizontal gaussian pixel, 0) * intensity
This outputs a normalized over-brightness map, which has been blurred vertically via a blur kernel (completing the box blur, since it has now been blurred in both directions).

5. The renders from steps 2 and 4 are fed into bloom3
5.a Normalized Scene Pixel = lighting scene pixel * hdr
hdr is still 256.
5.b. Output Pixel = normalized scene pixel + max(1 - normalized scene pixel, 0) * bloom pixel
What this does is composite the blurred bloom pixels onto the scene.  This time, the lighting curve is the opposite as before; it has a stronger effect on darker pixels and a weaker effect on brighter ones.  This avoids washing out the ship and has a nice haze effect on the black of space.

The math is intentionally as simple as possible, for maximum performance.  Other modders are welcome to offer alternatives for the user to choose from.  Setting up these shaders to work in the first place is a job and a half for me (getting that bloom working properly and looking good in GLSL 1.1 was particularly nightmarish), but writing GLSL code is pretty easy, so don't feel intimidated.
« Last Edit: May 21, 2014, 03:30:44 PM by Dark.Revenant »
Logged

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2806
    • View Profile
    • Sc2Mafia
Re: [Graphics] ShaderLib Graphics Enhancement Mod (Alpha v1.21) (Bloom!)
« Reply #101 on: May 23, 2014, 05:03:42 PM »

Update!  See if this fixes your visual glitches and performance issues, if any.  By the way, ripples and such will sometimes be slightly off-center and I have no way of fixing that until the next Starsector update.

ShaderLib Alpha v1.21

Alpha v1.21 (May 23, 2014)
- Update to the light and bloom shaders for clarity and slightly better performance
- Changed displayable mod name to "ZZ ShaderLib" so it loads and runs last
- Added "use64BitBuffer" option to settings.json
- Improved color depth
Logged

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2806
    • View Profile
    • Sc2Mafia
Re: [Graphics] ShaderLib Graphics Enhancement Mod (Alpha v1.22) (Bloom!)
« Reply #102 on: May 23, 2014, 06:22:10 PM »

Quick update.

ShaderLib Alpha v1.22

Alpha v1.22 (May 23, 2014)
- Fixed a major issue on some computers involving sprite alignment
- Added method to ShaderLib: void setVanillaViewport()
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: [Graphics] ShaderLib Graphics Enhancement Mod (Alpha v1.22) (Bloom!)
« Reply #103 on: May 23, 2014, 07:30:46 PM »

Something really weird is going on now, lol; my screen's flashing every time I fire off a lighting event.  Do I need to change the initialization settings?
Logged
Please check out my SS projects :)
Xeno's Mod Pack

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: [Graphics] ShaderLib Graphics Enhancement Mod (Alpha v1.22) (Bloom!)
« Reply #104 on: May 23, 2014, 07:37:54 PM »

Hrmm.  It appears that some bright white light is firing every time something using a light fires; it's a bright white light. 

It's definitely the lighting system, not the bloom / distortion (which works better here, btw), I just disabled both.

Were you creating a StandardLight to test alignment all the time and forgot to remove it from the build, maybe?
Logged
Please check out my SS projects :)
Xeno's Mod Pack
Pages: 1 ... 5 6 [7] 8 9 ... 27