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]

Author Topic: [0.97a] Particle Engine (3/3/24)  (Read 29393 times)

V_KJ

  • Ensign
  • *
  • Posts: 31
  • Coffee tastes great, wdym?
    • View Profile
Re: [0.96a] Particle Engine (12/29/23)
« Reply #15 on: February 29, 2024, 11:09:03 PM »

Is there any fix for this?

java.lang.RuntimeException: (Particle Engine) Failure to compile shader: ERROR: 0:1: '' :  version '330' is not supported
ERROR: 0:3: 'layout' : syntax error: syntax error

   at particleengine.Shader.attachShader(Shader.java:46)
   at particleengine.Shader.createProgram(Shader.java:17)
   at particleengine.ParticleShader.init(ParticleShader.java:26)
   at particleengine.ParticleEngineModPlugin.onApplicationLoad(ParticleEngineModPlugin.java:25)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.super(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:748)
Logged
"How do you code in a Macbook?"

Shogouki

  • Captain
  • ****
  • Posts: 309
    • View Profile
Re: [0.96a] Particle Engine (12/29/23)
« Reply #16 on: March 01, 2024, 01:10:51 PM »

Does this work in 0.97?
Logged

float

  • Commander
  • ***
  • Posts: 245
    • View Profile
Re: [0.96a] Particle Engine (12/29/23)
« Reply #17 on: March 05, 2024, 08:51:19 PM »

Is there any fix for this?

java.lang.RuntimeException: (Particle Engine) Failure to compile shader: ERROR: 0:1: '' :  version '330' is not supported
ERROR: 0:3: 'layout' : syntax error: syntax error

   at particleengine.Shader.attachShader(Shader.java:46)
   at particleengine.Shader.createProgram(Shader.java:17)
   at particleengine.ParticleShader.init(ParticleShader.java:26)
   at particleengine.ParticleEngineModPlugin.onApplicationLoad(ParticleEngineModPlugin.java:25)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.super(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:748)

This suggests that your device doesn't support the version of OpenGL that this mod requires. What machine are you using?  For reference, OpenGL 3.3 was released in 2010, so if you have a very old computer, there's not likely anything that can be done.
Logged

V_KJ

  • Ensign
  • *
  • Posts: 31
  • Coffee tastes great, wdym?
    • View Profile
Re: [0.96a] Particle Engine (12/29/23)
« Reply #18 on: March 06, 2024, 01:08:54 AM »

Is there any fix for this?

java.lang.RuntimeException: (Particle Engine) Failure to compile shader: ERROR: 0:1: '' :  version '330' is not supported
ERROR: 0:3: 'layout' : syntax error: syntax error

   at particleengine.Shader.attachShader(Shader.java:46)
   at particleengine.Shader.createProgram(Shader.java:17)
   at particleengine.ParticleShader.init(ParticleShader.java:26)
   at particleengine.ParticleEngineModPlugin.onApplicationLoad(ParticleEngineModPlugin.java:25)
   at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.super(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:748)

This suggests that your device doesn't support the version of OpenGL that this mod requires. What machine are you using?  For reference, OpenGL 3.3 was released in 2010, so if you have a very old computer, there's not likely anything that can be done.

A Mac M1, with Ventura 13.6
Logged
"How do you code in a Macbook?"

float

  • Commander
  • ***
  • Posts: 245
    • View Profile
Re: [0.97a] Particle Engine (3/3/24)
« Reply #19 on: March 06, 2024, 11:01:33 AM »

Ah, a Mac. I don't have one, so I can't really test, but according to my research MacOS restricts OpenGL context to 2.1 unless explicitly told otherwise. I'm not sure what GL context Starsector is using on Mac, but I've attached a jar file that will test this.

Replace Particle Engine/jars/ParticleEngine.jar with the attached file (make sure to backup the original jar) and boot up the game with Particle Engine enabled. It should crash immediately with a message stating which GL versions the game's context supports.

If your context supports 3.2 but not 3.3, I think this should be easily fixable with a version switch from 330 to 150. But, if you're stuck at 2.1 I'm not sure there's much I can do about it -- the required context capabilities would need to be requested before the window is created, which isn't something that a mod would be capable of altering.
Logged

WimeSTone

  • Ensign
  • *
  • Posts: 4
    • View Profile
Re: [0.97a] Particle Engine (3/3/24)
« Reply #20 on: March 24, 2024, 12:22:21 AM »

Excellent. I was implementing quite literally the same thing. Reading through the code made me very happy, very neatly done.
I wonder if Mac would return true for GLContext.getCapabilities().OpenGL33? This should return the capabilities of the context, not hardware right? If so, it would be nice to cache the result somewhere and expose it, so that we could have a failsafe in case the context doesn't support OpenGL 3.x calls. (Also gate the implementation side behind this condition, some 3-4 ifs won't ruin anything).
Logged

float

  • Commander
  • ***
  • Posts: 245
    • View Profile
Re: [0.97a] Particle Engine (3/3/24)
« Reply #21 on: March 24, 2024, 07:21:07 AM »

Excellent. I was implementing quite literally the same thing. Reading through the code made me very happy, very neatly done.
I wonder if Mac would return true for GLContext.getCapabilities().OpenGL33? This should return the capabilities of the context, not hardware right? If so, it would be nice to cache the result somewhere and expose it, so that we could have a failsafe in case the context doesn't support OpenGL 3.x calls. (Also gate the implementation side behind this condition, some 3-4 ifs won't ruin anything).

I’ve actually done a bit more research since my last post, and unfortunately it’s a bit more complicated with Macs. Macs don’t support OpenGL compatibility mode for some reason, which is required for contexts to use both immediate mode and retained mode features, since the former is deprecated. So you’re stuck with a legacy context or with core profile; in the former this mod won’t work and in the latter the base game (which makes extensive use of legacy OpenGL) wouldn’t work.

The only (possible, not sure if it’d actually work in practice) solution would be to use multiple contexts. Unfortunately this isn’t an option in LWJGL2, which only supports a single display via the Display class. So yeah, I think we’re out of options at that point.

I’ve added an option in the settings in dev to disable the mod’s features while keeping it active. It’s not pretty — particles won’t be rendered at all — but it should at least allow mods that use this as a dependency to run. I’ll include it in the next update, whenever that might be.
« Last Edit: March 24, 2024, 07:22:49 AM by float »
Logged

WimeSTone

  • Ensign
  • *
  • Posts: 4
    • View Profile
Re: [0.97a] Particle Engine (3/3/24)
« Reply #22 on: March 24, 2024, 11:59:17 PM »

I’ve added an option in the settings in dev to disable the mod’s features while keeping it active. It’s not pretty — particles won’t be rendered at all — but it should at least allow mods that use this as a dependency to run. I’ll include it in the next update, whenever that might be.

Many thanks for this one. While it isn't pretty, it provides a compatibility option. Maybe, just maybe, in some next major update the LWJGL version will be upped to 3, though that would require a great overhaul of the entire codebase. IIRC, we are getting Java 17 in the next version, so we can only hope for LWJGL to get some love too.
Logged

WimeSTone

  • Ensign
  • *
  • Posts: 4
    • View Profile
Re: [0.97a] Particle Engine (3/3/24)
« Reply #23 on: March 25, 2024, 04:46:05 AM »

Awh, is there a sane way to attach an emitter to a weapon? I'm trying to make a funnel particle system which is attached to a weapon and simulates in local space, respecting both its position and rotation.
The workaround was to make a wrapper CombatEntityAPI, which returns the necessary position, but I find this mildly cursed:

Code
if (dummyWeaponEntity == null) {
            dummyWeaponEntity = new DummyWeaponEntity(weapon);
            engine.addEntity(dummyWeaponEntity);
}

/* and then just pass that entity as an anchor */
emitter.enableDynamicAnchoring();
Particles.anchorEmitter(emitter, dummyWeaponEntity);
Logged

float

  • Commander
  • ***
  • Posts: 245
    • View Profile
Re: [0.97a] Particle Engine (3/3/24)
« Reply #24 on: March 25, 2024, 11:12:11 AM »

Awh, is there a sane way to attach an emitter to a weapon? I'm trying to make a funnel particle system which is attached to a weapon and simulates in local space, respecting both its position and rotation.
The workaround was to make a wrapper CombatEntityAPI, which returns the necessary position, but I find this mildly cursed:

Code
if (dummyWeaponEntity == null) {
            dummyWeaponEntity = new DummyWeaponEntity(weapon);
            engine.addEntity(dummyWeaponEntity);
}

/* and then just pass that entity as an anchor */
emitter.enableDynamicAnchoring();
Particles.anchorEmitter(emitter, dummyWeaponEntity);

Oh, anchorEmitter is basically just syntactic sugar, totally unnecessary. It's just setting the emitter's location to the entity's location each frame, which you can easily do manually with something that isn't a CombatEntityAPI in one of two ways:

1. In a script with an advance feature (EveryFrameCombatScript, AdvanceableListener, etc), just keep track of the emitters you have and set their locations and rotations to the respective weapons' locations and rotations each frame.
2. You can achieve the same thing via a StreamAction in Particles.stream, in particular pass an anonymous class (or a lambda in the next update, finally Java 8 language features support) into doBeforeGenerating that sets the emitters' locations and positions each frame. See the simple trail example for an emitter that does exactly this but with a projectile instead of a weapon.
Logged

WimeSTone

  • Ensign
  • *
  • Posts: 4
    • View Profile
Re: [0.97a] Particle Engine (3/3/24)
« Reply #25 on: March 25, 2024, 09:15:15 PM »

Oh, anchorEmitter is basically just syntactic sugar, totally unnecessary. It's just setting the emitter's location to the entity's location each frame, which you can easily do manually with something that isn't a CombatEntityAPI in one of two ways:

1. In a script with an advance feature (EveryFrameCombatScript, AdvanceableListener, etc), just keep track of the emitters you have and set their locations and rotations to the respective weapons' locations and rotations each frame.
2. You can achieve the same thing via a StreamAction in Particles.stream, in particular pass an anonymous class (or a lambda in the next update, finally Java 8 language features support) into doBeforeGenerating that sets the emitters' locations and positions each frame. See the simple trail example for an emitter that does exactly this but with a projectile instead of a weapon.

Hm .. number 1 worked this time. I think I know where I failed when I tried it before. Forgot to call emitter.enableDynamicAnchoring().
I'll try playing around with StreamAction now.
Many thanks ;D
Logged
Pages: 1 [2]