Gamestudio Links
Zorro Links
Newest Posts
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
6 registered members (Petra, AndrewAMD, VoroneTZ, Quad, 2 invisible), 833 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
sorting of translucent particles #450289
04/11/15 16:49
04/11/15 16:49
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
I'm having sorting problems with particles (non translucent vs translucent), and would like to know where do I dig? I've read in the manual that I could give a non transparent overlay bmap for particles, does it mean that sorting issue can be solved by having an image with alpha channel? It did not help me anyway, I use simple white .png image, and I change its color to get different particle effects (masterQ32 thank you for the idea grin ). I tried to use white .tga with same size and white alpha channel, didn't help. I don't want to use sprites in order to solve this sorting issue, maybe there is another way I'm missing?


Best regards

edit: additional question is about framerate independence for spawning particles, how does engine create/spawn particles? in the manual there is an example how to spawn particles independent to framerate (maxv(1, 40 * time_step). At first I thought it will set amount of spawning particles to a fixed value, independent to framerate, but it just adjusts value of spawning particles to keep it more or less the same.
Originally Posted By: 3run
Quote:
For keeping the particle number independent of the frame rate on continuous particle generation, multiply the number of generated particles with time_step (see example).


Just run it, press ENTER and you'll see how how the number of particles goes up.
Code:
// fade smoke away:
function fadeSmokeTrailPar(PARTICLE* p){
	// decrease alpha:
	p.alpha -= p.skill_x * time_step;
	// if we don't have alpha, kill particle:
	if(p.alpha <= 0){ p.lifespan = 0; }
}

// smoke trail particle:
function smokeTrailPar(PARTICLE* p){
	// set color to white:
	vec_set(p.blue, COLOR_GREY);
	// set size:
	p.size = 4;
	// set gravity:
	p.gravity = -0.4;
	// set alpha:
	p.alpha = 30;
	// set fading speed:
	p.skill_x = 1;
	// set flags:
	set(p, MOVE | BRIGHT | BEAM | TRANSLUCENT);
	// set event:
	p.event = fadeSmokeTrailPar;
}

// main function:
void main(){
	// set framerate limit:
	fps_max = 500;
	// empty level:
	level_load("");
	// wait 3 frames:
	wait(3);
	// set camera positions/angles:
	vec_set(camera.x, vector(-140, 0, 90));
	vec_set(camera.pan, vector(0, -13, 0));
	// vectors:
	VECTOR vectexVec;
	// reset vectors:
	vec_fill(vectexVec.x, 0);
	// create smoke emmiter:
	ENTITY* smokeEnt = ent_create(CUBE_MDL, vector(200, 0, 0), NULL);
	// scale it down:
	vec_fill(smokeEnt.scale_x, 0.35);
	// set it's flags:
	set(smokeEnt, PASSABLE | TRANSLUCENT);
	// save position:
	vec_set(smokeEnt.skill1, smokeEnt.x);
	// loop:
	while(1){
		// reset framerate limit:
		fps_max = 500;
		// if ENTER is pressed:
		if(key_enter){
			// decrease framerate limit:
			fps_max = 60;
		}
		// show framerate:
		DEBUG_VAR(fps_max, 30);
		DEBUG_VAR(num_particles, 50);
		// show text:
		draw_text("PRESS <ENTER> TO LOWER FRAMERATE!", 10, 10, COLOR_WHITE);
		// rotate smoke emitter:
		smokeEnt.pan = cycle(smokeEnt.pan + 30 * time_step, 0, 360);
		// move it:
		smokeEnt.z = smokeEnt.skill3 + fsin(total_ticks * 8, 64);
		smokeEnt.y = smokeEnt.skill2 + fcos(total_ticks * 8, 64);
		// get position of upper left vertex:
		vec_for_vertex(vectexVec.x, smokeEnt, 3);
		// create smoke trail with particles:
		effect(smokeTrailPar, maxv(1, 40 * time_step), vectexVec.x, nullvector);
		// wait one frame:
		wait(1);
	}
}


Last edited by 3run; 04/11/15 17:04. Reason: added question

Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: sorting of translucent particles [Re: 3run] #450326
04/12/15 17:24
04/12/15 17:24
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Here is a screen, to show you sorting problem I'm talking about:


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: sorting of translucent particles [Re: 3run] #450327
04/12/15 17:45
04/12/15 17:45
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Hm I haven't worked with opaque particles in quite some time so I don't know if they are still supported. I think the way to go was to use 24bit textures (meaning no alpha channel), then set the OVERLAY flag and black parts became invisible.
Particle sorting always is a little problematic, esp. when it comes to let's say stuff like black smoke and flames mixed together.


What I do to make framerate indepent particles is something like the following:

my.skill20 += time_step;
while(my.skill20 > 0.5) // 32 particles per second
{
effect(...,1,...);
my.skill20 -= 0.5;
}

On fast moving objects and low framerates I interpolate between the new and old position, should there be a case where more than 1 particle needs to be created in that while loop.


"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: sorting of translucent particles [Re: Superku] #450329
04/12/15 17:53
04/12/15 17:53
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Thank you, Superku! I'll give it a try! As for the interpolating particle between the new and old positions, I tried it once, but didn't get it to work while using MOVE flag (to enable gravity). I'll try once again.


My best regards!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: sorting of translucent particles [Re: 3run] #450349
04/13/15 08:32
04/13/15 08:32
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
I tried to use 24 bit .tga and .pcx images, with OVERLAY flag set on, but it didn't help unfortunately. I could only fix it by using sprites instead of particles, but it's too slow for particularly this project, cause I'm going to have tons of particles (over 2000)..

About interpolating particle between the new and old positions, it works only without MOVE flag set (while BEAM is on). Is there anyway to make 'gravity' work without MOVE flag set (as far as I know, no frown ), or maybe there is an alternative way to simulate 'fake' gravity for BEAM particles?

Greets


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: sorting of translucent particles [Re: 3run] #450356
04/13/15 10:29
04/13/15 10:29
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Hm that's a pity.

I don't understand the problem with MOVE or gravity, it shouldn't make a difference.
What I meant was something as follows:

k = floor(my.skill20/0.5);
for(i = k; i > 0; i--)
{
vec_lerp(temp,old_pos,new_pos,i/k);
effect(my_particle,1,temp,vec_diff(...)*1 or /k or no velocity at all)
}

This could be totally wrong, untested, but should give you an idea.


"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: sorting of translucent particles [Re: Superku] #450364
04/13/15 11:54
04/13/15 11:54
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
What I was doing, was something like this:
Code:
effect(smokeTrailPar, maxv(1, 40 * time_step), my.x, vec_sub(oldPos.x, my.x));
vec_set(oldPos.x, my.x);

It doesn't work with MOVE flag, cause it prevent BEAM from actually being 'smeared' (as the manual said) via 'velocity'.

Some screens to how you what happens:
Quote:
Without MOVE flag:

With MOVE flag:


So it looks to me, that when I use MOVE flag, BEAM is 'smeared' along the p.vel_x. So it works like initial speed, instead of beam length frown
Quote:
vel - Initial speed vector or beam length.


Greets


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: sorting of translucent particles [Re: 3run] #450367
04/13/15 13:07
04/13/15 13:07
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Ah I see. Sure, BEAM stretches the particle along the p.vel_x direction.
Just do the movement by yourself then (without setting MOVE), for example as follows:

void p_event(PARTICLE* p)
{
p.skill_z += 0.25*time_step; // maybe add a maxv limit here
p.z += p.skill_z*time_step;
}


"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: sorting of translucent particles [Re: Superku] #450372
04/13/15 13:51
04/13/15 13:51
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Originally Posted By: Superku
void p_event(PARTICLE* p)
{
p.skill_z += 0.25*time_step; // maybe add a maxv limit here
p.z += p.skill_z*time_step;
}
I didn't even think about moving particle directly, thank you for a tip! laugh

As I'm toying around with the code, I'm getting some really beautiful artefacts grin
It looks much better in motion tongue But anyway, I just wanted to show this.




Greets


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: sorting of translucent particles [Re: 3run] #450375
04/13/15 14:07
04/13/15 14:07
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Lively, and you are welcome!


"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  HeelX, Spirit 

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