Particle color

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Particle color

Post by NutJob »

Anyone know how to change the color of a particle (emitter?)? I see LoG1 had something about creating FX effects but can't convert that usage over to how LoG2 does this, plus I don't want to create new effects anyways; I want to get, let's say, the flame from a torch and change it, dynamically with a script, to another color. Note: I'm not talking about the LightComponent

I don't want to use a predefined defineObject, I'd prefer to change the color, at-will, with code in script_entity. If no one knows, currently, can someone take a guess at what we're waiting for in the Predefined Assets section of the Modding page or is it doable now?
User avatar
Doridion
Posts: 256
Joined: Tue Jun 10, 2014 9:23 pm

Re: Particle color

Post by Doridion »

I'm not sure if you can change the color of a predefined particle effect (( As you said, changing light color is simple for an object possessing the class, but particle effects are just called by objects .... you can always can define your own particle effect, and change his light from the light class of the used object, that's only way that i see.
User avatar
QuintinStone
Posts: 72
Joined: Sat Nov 01, 2014 9:58 pm

Re: Particle color

Post by QuintinStone »

Some particles are sprites pulled from a texture file. Like the hit effect on a green slime. Changing the color for these would involve making a new color-shifted texture.
Crypt of Zulfar
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Particle color

Post by minmay »

QuintinStone wrote:Some particles are sprites pulled from a texture file. Like the hit effect on a green slime. Changing the color for these would involve making a new color-shifted texture.
...So what exactly do you think color0, color1, color2, color3, and colorAnimation do?

The color vectors multiply the RGB channels of the particle texture. You do not need to "make a new color-shifted texture" to change the colour of a particle system.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Doridion
Posts: 256
Joined: Tue Jun 10, 2014 9:23 pm

Re: Particle color

Post by Doridion »

minmay wrote:...So what exactly do you think color0, color1, color2, color3, and colorAnimation do?
There's a difference between colored particles and light color animation. Colored particles are "drawn" in a dds file, placed and animated in a particle system. colorAnimation is just a light wich gives you "supplement" to particle system. However, if particles are drawn in white/grey, there, you can effectively apply color to the particles by modifying light color.

All depends of the material used in the particle system. More else, NutJob asked to "dynimacaly" changing color of a particle emitter, and actually, there's no way to modify a particle system, except by coding it in a script file.

In the torch example, under LoG1, flames are drawn in the torch_self_illum.dds file, so you can not modify it only by changing light color.
NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: Particle color

Post by NutJob »

Doridion wrote:
minmay wrote:...So what exactly do you think color0, color1, color2, color3, and colorAnimation do?
There's a difference between colored particles and light color animation. Colored particles are "drawn" in a dds file, placed and animated in a particle system. colorAnimation is just a light wich gives you "supplement" to particle system. However, if particles are drawn in white/grey, there, you can effectively apply color to the particles by modifying light color.

All depends of the material used in the particle system. More else, NutJob asked to "dynimacaly" changing color of a particle emitter, and actually, there's no way to modify a particle system, except by coding it in a script file.

In the torch example, under LoG1, flames are drawn in the torch_self_illum.dds file, so you can not modify it only by changing light color.
Ok, that helped me immensely wrap my head around what's going on, thank you! My incessant questions about the darn color of particles is mostly because I hate when I change a lantern, for example, to dimly light a room in green hue (from the light component) but the flames are still bright orange. Looks dumb, so I need to change the "flame" color.
User avatar
Doridion
Posts: 256
Joined: Tue Jun 10, 2014 9:23 pm

Re: Particle color

Post by Doridion »

NutJob wrote:Ok, that helped me immensely wrap my head around what's going on, thank you! My incessant questions about the darn color of particles is mostly because I hate when I change a lantern, for example, to dimly light a room in green hue (from the light component) but the flames are still bright orange. Looks dumb, so I need to change the "flame" color.
As i said Nutjob, yep, you can change the flame color to grayscale, and after, just have to change light color ( to change the flame color ^^ ). But ... there's allways a but xD I seen that LoG2 have orange, blue, green, and most other flame colors .... more else, the push_block_trigger got the flare animation where color can ben changed. I would not be surprised that AH have already made most of their particle designs in grayscale, to just have to modify color by lighting ;)
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Particle color

Post by minmay »

Doridion wrote:There's a difference between colored particles and light color animation. Colored particles are "drawn" in a dds file, placed and animated in a particle system. colorAnimation is just a light wich gives you "supplement" to particle system. However, if particles are drawn in white/grey, there, you can effectively apply color to the particles by modifying light color.
I'm not sure what you mean by your use of the word "light" here. Particle systems don't involve lights. As far as I can tell from experimentation, color0-3 are vectors that multiply the RGB channel values in the texture. For example, with a color0 of vec(1,0.5,1), the green channel's values will be halved (a pixel with a green value of 200 would end up with 100) and the other two will be unchanged. A color0 of vec(2,2,2) will double all the values in the texture, clamping them at 255 if necessary. colorAnimation is a boolean that, if true, makes the particles change from color0 to color1, then to color2, then to color3, over their lifetime. At no point is lighting involved, and indeed particles are never subject to lighting at all since, well, they're particles, not surfaces.

Greyscale particle textures aren't necessarily better than colored ones. Yes, they allow you to pick any hue/saturation with the colour multipliers but you're stuck with that one hue for the entire texture. The torch flame particle effect, for example, is impossible with a greyscale texture because it contains multiple hues.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Particle color

Post by AndakRainor »

So, it is not possible to dynamically update the color0 value of an emitter?

I am trying to adapt the color of some clouds particles to the time of day value in the game. How would you do that? (I use multiple predefined particle systems for now, but the transitions are too obvious, that's ugly)
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Particle color

Post by minmay »

It is not. Regarding transitions, remember that you can use ParticleComponent:stop() and ParticleComponent:start() to make emitters start/stop emitting particles without destroying existing particles; using those with two (or more) ParticleComponents would give much smoother transitions than enabling/disabling the components or calling setParticleSystem() on one with extant particles. There are also ParticleComponent:fadeIn() and ParticleComponent:fadeOut().
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Post Reply