Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.95.1a is out! (12/10/21); Blog post: Hyperspace Topography (10/12/22)

Pages: 1 ... 4 5 [6] 7 8 ... 27

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

xenoargh

  • Admiral
  • *****
  • Posts: 4934
  • naively breaking things!
    • View Profile

Quote
assuming you're already using a different weapon (which I recommend in many cases, considering the capital-sized vanilla muzzle flash...) that lacks a flash light.
I generally don't; it just multiplies the maintenance hassles when you have so many weapons to balance for :)

Anyhow, it's a straightforward change:
Code: java
                // Flash light
                if (data.hasFlash) {
                    if ((float) Math.random() <= data.chance) {
                        StandardLight light = new StandardLight();
                        light.setIntensity(data.flashIntensity);
                        light.setColor(data.flashColor);
                        if(proj.getSource() != null){
                          if(proj.getSource().isFighter() || proj.getSource().isDrone()){
                              light.setSize(data.flashSize / 3f);
                            } else {
                              light.setSize(data.flashSize);
                            }
                        }
                        if (Float.compare(data.flashOffset, 0f) != 0) {
                            double facing = proj.getFacing() - 180.0;
                            if (facing < 0f) {
                                facing += 360.0;
                            }
                            facing = Math.toRadians(facing);
                            Vector2f offset = new Vector2f((float) Math.cos(facing), (float) Math.sin(facing));
                            offset.scale(data.flashOffset);
                            Vector2f.add(proj.getLocation(), offset, offset);
                            light.setLocation(offset);
                            ....
So, one null test, one boolean, a branch and a math step.  

On the particles, I'm reducing them to no more than three, even for big stuff; the muzzle lights, if adjusted properly, make lots of particles irrelevant, and I'm looking forward to the performance improvements :)
« Last Edit: May 18, 2014, 04:05:02 PM by xenoargh »
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2744
    • View Profile
    • Sc2Mafia
    • Email

I am not doing a hidden conditional change in light size in the data path.  This is a design decision.

So I'll put a scalar in settings.json, which will be default 1.0 but you can set it to whatever you want because it's integrated in Vacuum anyway.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 4934
  • naively breaking things!
    • View Profile

Works for me; totally understand about not wanting a hidden Thing, I just figured that's about right for most use cases :)
Logged
Please check out my SS projects :)
Xeno's Mod Pack

xenoargh

  • Admiral
  • *****
  • Posts: 4934
  • naively breaking things!
    • View Profile

Caught a minor bug; under some circumstances, it appears that intensity can go below zero before a light is removed from the sim, resulting in a bright flash.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2744
    • View Profile
    • Sc2Mafia
    • Email

That does not help if you don't list those circumstances.

In any case, it occurred to me that there is no way to flag a LightAPI to be removed.  I'll be fixing this oversight on tonight's update, by adding a boolean return to advance() that flags whether it should be destroyed that frame.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 4934
  • naively breaking things!
    • View Profile

Well, it's observable when you hit a ship a glancing blow, that I know for certain.  You can see these bright flashes of very intense color briefly then.

It's pretty clear that something's causing the values to leap upwards; perhaps the shader doesn't check to make sure that the value of the intensity is > 0 and the StandardLight isn't getting removed in time, or it's not handling the lifetime correctly?  I'll take a look at that when I can; been too busy with RL tonight, unfortunately. 

Another feature request; it'd be nice to apply the offset to certain projectiles while they're in flight- rockets and missiles would look good that way.  A boolean check vs. a CSV value to use / not use the offset should be all that's needed :)
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2744
    • View Profile
    • Sc2Mafia
    • Email

That can only happen if the fadeout time for the attached light is shorter than the projectile's actual fade out time. I'll add a check to ensure the intensity/size are clamped to zero in the final phase.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 4934
  • naively breaking things!
    • View Profile

That makes sense; all of the projectiles in Vacuum have been clamped to 0.25 seconds of fadeout time, and projectiles that do a hit go through a brief fadeout :)

Anyhow, should get to testing distortion implementations soon.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2744
    • View Profile
    • Sc2Mafia
    • Email

Upcoming in a few hours: Big update with a few infrastructure changes and most importantly: BLOOM
Logged

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2744
    • View Profile
    • Sc2Mafia
    • Email
Re: [Graphics] ShaderLib Graphics Enhancement Mod (Alpha v1.2) (Bloom!)
« Reply #84 on: May 19, 2014, 09:30:54 PM »

Now with Bloom!

Spoiler
[close]

ShaderLib Alpha v1.2

Alpha v1.2 (May 19, 2014)
- Bloom effect added to Lighting Engine (for situations where the lights are particularly bright)
- Added "enableBloom", "bloomQuality", "bloomMips", "bloomScale", and "bloomIntensity" options to settings.json
- Added methods to StandardLight: void setVelocity(Vector2f velocity), void setVelocity2(Vector2f velocity), Vector2f getVelocity(), Vector2f getVelocity2(), Vector2f setOffset(), Vector2f getOffset()
- Added methods to WaveDistortion and RippleDistortion: void setVelocity(Vector2f velocity), Vector2f getVelocity()
- Added methods to ShaderLib: void drawScreenQuad(float scale), void copyScreen(int texture, int textureUnit)
- Added "offset" column to lights CSV (how many pixels behind the projectile to spawn the standard light, which may be useful for missiles; ignored for beams)
- Added "fighterBrightnessScale" option to settings.json (default 0.5)
- Added two arguments (int texture, int textureUnit) to ShaderLib.screenDraw()
- Updated WaveDistortion texture (should act properly now; to get a sphere, set the intensity to 1/4 the size)
- Updated RippleDistortion texture
- Fixed enableLights and enableDistortion settings options
- Updated LightAPI's advance method to return a boolean representing whether it should be destroyed that frame or not
« Last Edit: May 19, 2014, 10:03:46 PM by Dark.Revenant »
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 4934
  • naively breaking things!
    • View Profile
Re: [Graphics] ShaderLib Graphics Enhancement Mod (Alpha v1.2) (Bloom!)
« Reply #85 on: May 19, 2014, 09:49:28 PM »

Sounds solid; hopefully it didn't break too much of what I've been doing; I am pretty excited about some of the stuff I've gotten done ;)
Logged
Please check out my SS projects :)
Xeno's Mod Pack

xenoargh

  • Admiral
  • *****
  • Posts: 4934
  • naively breaking things!
    • View Profile
Re: [Graphics] ShaderLib Graphics Enhancement Mod (Alpha v1.2) (Bloom!)
« Reply #86 on: May 19, 2014, 11:39:34 PM »

Tried out the distortions.  Not sure what they're quite supposed to do yet.  I built one like this:

Code: java
            
        for(int i = 0; i < 10; i++){
            WaveDistortion distortion = new WaveDistortion();
            distortion.setLocation(point);
            float timer = MathUtils.getRandomNumberInRange(0.5f,1.5f);
            distortion.fadeOutIntensity(timer);
            distortion.setSize(MathUtils.getRandomNumberInRange(150f,350f));
            distortion.setLifetime(timer);
            DistortionShader.addDistortion(distortion);
        }
I was expecting it to cycle the rings and do a ripple effect, but there doesn't appear to be a wave cycle timer- it's just one wave per instance.  So I tried this but it didn't look anything like what I expected.

This produced some really huge distortions that then popped back to normal very suddenly, which didn't look terribly good.   It also didn't seem to distort the background stars?

I was hoping to make a nice bunch of outgoing ripples from the point, but it appears that if I want to do that, I need to implement EveryFrameCombatPlugin, maybe?
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2744
    • View Profile
    • Sc2Mafia
    • Email
Re: [Graphics] ShaderLib Graphics Enhancement Mod (Alpha v1.2) (Bloom!)
« Reply #87 on: May 20, 2014, 12:14:48 AM »

First of all, if you want a ripple effect, it's best to use RippleDistortion, since that will actually produce a ring shape.  Each frame (it's 60 total) is a thinner version of the ring; if you increase the size and play the frames, it will look like an expanding ripple.  If you want it to cycle, extend it with an override of advance that loops the animation, size, and intensity instead of killing the object.

Second, you shouldn't set a lifetime in this case; it will be removed when it finishes fading out.

Third, you didn't actually give that distortion a starting intensity (it defaults to 20 units if you don't).  Multiple overlapping distortions does not produce an entirely reliable effect; it will look better if they overlap less (such as concentric rings).

Fourth, you didn't make it change size, which is needed for it to actually expand outward.  To do this, set the size to some value and then fadeInSize, then set the size to some other value if you want it to begin at a size other than 0.  Setting a non-zero starting size for a fadeIn will actually shorten the fade-in time (as you might expect), so you should adjust the timer accordingly.

(You can fade in/out size and intensity independently)
« Last Edit: May 20, 2014, 12:19:58 AM by Dark.Revenant »
Logged

xenoargh

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

I think I need an example, lol.  I tried this:

Code: java
        RippleDistortion distortion = new RippleDistortion();
        distortion.setIntensity(1f);
        distortion.setLocation(point);
        float timer = MathUtils.getRandomNumberInRange(0.1f,0.5f);
        distortion.fadeInIntensity(0.1f + timer);
        distortion.fadeOutIntensity(1.0f + timer);
        distortion.setSize(MathUtils.getRandomNumberInRange(500f,750f));
        distortion.fadeInSize(1.0f + timer);
        DistortionShader.addDistortion(distortion);

Expectation:  Big wave starts from center and rapidly distorts everything around it, moves out to big radius, fades.

Result:  Nothing obviously visible happens to the scene; even worse than the last one, lol :)
« Last Edit: May 20, 2014, 10:02:18 AM by xenoargh »
Logged
Please check out my SS projects :)
Xeno's Mod Pack

xenoargh

  • Admiral
  • *****
  • Posts: 4934
  • naively breaking things!
    • View Profile
Re: [Graphics] ShaderLib Graphics Enhancement Mod (Alpha v1.2) (Bloom!)
« Reply #89 on: May 20, 2014, 10:26:16 AM »

Tried messing with the intensity settings and capped the timers to make sure it's all strict.  Still not really getting much if any distortion:

Code: java
        RippleDistortion distortion = new RippleDistortion();
        distortion.setIntensity(45f);
        distortion.setLocation(point);
        distortion.fadeInIntensity(0.1f);
        distortion.fadeOutIntensity(2f);
        distortion.setSize(MathUtils.getRandomNumberInRange(500f,750f));
        distortion.fadeInSize(2f);
        DistortionShader.addDistortion(distortion);
Logged
Please check out my SS projects :)
Xeno's Mod Pack
Pages: 1 ... 4 5 [6] 7 8 ... 27