Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (VoroneTZ, monk12, Quad), 829 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
particles bugging out #478243
09/24/19 19:22
09/24/19 19:22
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Hello.
I've been working on an update for my game which adds randomly/ procedurally generated maps as a treasure hunt highscore chase.
It's working rather fine technically speaking but every now and then particles appear and stay in place like sprites after an effect call (effect or effect_local, I'm not using A8's built-in multiplayer functions).
Example:
[Linked Image]

In huuuge:
[Linked Image]

Flame particles like that are emitted during a power jump with code like the following:
Code
void p_explo_chunk_fire_fade(PARTICLE *p)
{
	p.size = p.lifespan/p.skill_d*p.skill_a;
	p.vel_x *= 1-0.75*time_step;
	p.vel_y *= 1-0.75*time_step;
	p.vel_z *= 1-0.75*time_step;
	if(p.lifespan < 3 && p.skill_c)
	{
		p.skill_c = 0;
		effect(p_pogoFireTrailClouds,1,p.x,p.vel_x);
		p.lifespan = 0.25;
		p.event = NULL;
	}
}

void p_explo_chunk_fire(PARTICLE *p)
{
	p.y -= 24;
	vec_fill(p.blue,230+random(20));
	p.vel_x += random(4)-2;
	p.vel_y += random(4)-2;
	p.vel_z += random(4)-2;
	set(p,MOVE); // BRIGHT | 
	p.bmap = fireStyle3s_tga[(int)random(3)];
	p.alpha = 100; //60+random(25);
	p.size = p.skill_a = (25+random(8));
	p.skill_d = p.lifespan = 6;
	p.skill_c = 1;
	p.event = p_explo_chunk_fire_fade;
}

Notice how it should be fully opaque but that huge unwanted particle is ~50% transparent.
The same thing happened for a cloud particle where the p.size update is not relative to or at least limited in terms of lifespan:

Code
void p_pogoLandContact_fade(PARTICLE* p)
{
	vec_scale(p.vel_x,1-0.25*time_step);
	p.size = p.skill_a*minv(p.lifespan/6.0,1);   // set in spawn function: p.skill_a = p.size = (8+random(8));
}

[Linked Image]


The particles from example #1 appeared the most frequent. I use them for various particle effects though which is why I replaced them with other unique bitmaps. I've thought maybe particle events are not executed anymore for those quads but could falsify that hypothesis by drawing from that event:

Code
void p_explo_flash1_fade(PARTICLE* p)
{
	p.skill_y = p.lifespan/2.0; // in spawn/ emit/ init function: p.lifespan = 2;
	p.alpha = p.skill_b*p.skill_y*p.skill_y;
	draw_num3d(p.vel_z, p.x, 10, COLOR_RED); // p.vel_z identifies effect calls in the script at various positions, a unique ID for each call (for this specific particle effect)
}

[Linked Image]

Although I didn't print lifespan on screen I think it's safe to assume that lifespan >> 0 and that not skill_b is the issue (as the particle would disappear otherwise).


My first thought was I'm overwriting memory somewhere when I first saw that particle bug appear (and stay indefinitely on screen). However, the game hasn't crashed once since (for 16+ days now) and it can appear immediately in the first level which is loaded directly after the main function.
There's one thing though, one other visual bug and it might or might not be related:
I use(d) GPU bones animation for a bunch of stuff. Every now and then - reproducible though, it would be the same entity/-ies if I generated the dungeon with a fixed seed - entities with GPU bones animation would glitch out.
For example models like coins and goldbars had a "shine quad" in front of the main mesh, assigned to the 2nd skin (TRANSLUCENT entity flag set), vertices assigned to a different bone, and I'd rotate the coins and goldbars but keep the shiny quad in place/ unchanged or scale it down. That would work most of the time but a few coins (like one per level) would rotate twice as quickly or irregularly if more than one coin was on screen. Or the shiny quad would rotate around the origin as well or not be scaled as if it was assigned to the wrong bone. Both main and ent_mtlset shine material had the same matBones[X] code.
Some other entities with only one material and skin could become invisible, at least in the camera render pass (with the matBones material) but their shadows would show (using my custom depth shadow (material) shader/ system, thus when not using GPU bones).

As I changed all objects with said shine quad to spawn a separate shine entity each instead, only have one material and skin anymore and rotate the entity directly and not using bones the particle issues seemed to become a lot less frequent as well - although not fully gone (took me a while to make that bee show up in the previous example). Might just be a pure coincidence though. (One key model relying on a GPU bones shader still continues to show a wrong orientation every now and then.)


Sorry for this wall of text but I am very confused as where to go on with debugging that issue.
Do you have ANY idea why particles could bug out that way and maybe not have their lifespan reduced anymore? (Not sure if it's being reset instead, changing between 120fps and 12fps does not affect their size.) Btw. setting particle_mode = 1; and disabling particle instancing after seeing such a thing happen (and stay) on screen does nothing, I've tried it anyway - it shouldn't be related to drawing the particle anyway, it should be removed when lifespan reached 0 and just disappear either way.
Why would or could GPU bone animation glitch out, seemingly at random?

Thank you a lot for any advice.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: particles bugging out [Re: Superku] #478244
09/24/19 20:11
09/24/19 20:11
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Another example video I just took: https://i.gyazo.com/8c8a234c67f241fa468d0f8770a0626d.mp4
The white number is p.lifespan. It's being set to 2097152.0 whenever camera.z > p.z (~= 288, not 0) for whatever reason which I tested some more after recording the video. It decreases over time as it should otherwise (time_factor is at 0.95 btw for gameplay reasons).
Range of var is +-1048576.999 (according to the manual), and if we take 1048576*2 we get 2097152. Hm! As if the var was treated as unsigned and had a range over-/ underflow.
(I do not want to check for let's say if(lifespan > 1000) and kill the particle to hide that bug, I want to understand it.)

EDIT: camera.z > p.z was a coincidence it seems. Here's another shot where the particle would only stay opaque and "count down" when near the top of the screen. I press a button to set the lifespan to 4 and it fades out correctly:
https://i.gyazo.com/baf621d657baa5e8a9b12b1b42a66af2.mp4

Just for reference, a GPU (and CPU for depth) animated mushroom, not showing for bones anim: https://i.gyazo.com/619a573fe8bfd960912b35bd2f32ed57.mp4
(Glitches happen as well with the additional rendering pass deactivated, tried that early on.)

Last edited by Superku; 09/24/19 20:47.

"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: particles bugging out [Re: Superku] #478253
09/25/19 15:22
09/25/19 15:22
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Bone animation and particles should be unrelated - at least I do not know a connection. If a particle stays on the screen, is its action continuing or has it stopped?

Re: particles bugging out [Re: jcl] #478258
09/25/19 20:06
09/25/19 20:06
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Originally Posted by jcl
If a particle stays on the screen, is its action continuing or has it stopped?

Yes, the particle event continues to be executed (as confirmed by my tests seen above - admittedly, it's a terrible wall of text). They are moved as well, or stuff like p.gravity is considered still.

Somehow their lifespan is set to "range unsigned var" under some circumstances. This depends on the camera's position (and the particle's world position, presumably), meaning moving the camera affects it (on screen or alternatively you have to be very far away for lifespan to not be set to that huge value). Weird!

EDIT: Seems like the var range is +-2097152 after all and not 1048576, right? var is 22+10, 22 bits for the mantissa (?), 21^2 = 2097152.
DEBUG_VAR on a fast increasing var confirms.

Last edited by Superku; 09/25/19 20:29.

"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: particles bugging out [Re: Superku] #478278
09/27/19 13:24
09/27/19 13:24
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
If the action still runs, then the frozen particle is still managed by the engine. The lifespan should still count down any frame. Can you let your particla action check if the lifespan counts down or not? When it is at or below zero, the prarticle is removed by the engine.

Re: particles bugging out [Re: Superku] #478295
09/28/19 18:28
09/28/19 18:28
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
That's the issue, lifespan is set to max value under some circumstances. This can depend on the camera's position. Check out the following video if you can and look at the white number == lifespan:
https://i.gyazo.com/8c8a234c67f241fa468d0f8770a0626d.mp4
When the particle is rendered 50% transparent (for whatever reason) its lifespan is set to max value each frame, otherwise it's counting down.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends

Moderated by  jcl, Nems, Spirit, Tobias 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1