Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (M_D), 1,430 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
d3d_instancing = 1; #415816
01/24/13 08:57
01/24/13 08:57
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline OP
User
rojart  Offline OP
User

Joined: Oct 2004
Posts: 900
Lgh
I tested sprite instancing with infinite_level.c example, and indeed works.

But, if I try with particle sprites, like code below the fps went down.

Is d3d_instancing = 1 restricted for sprite particles?

Code:
///////////////////////////////
#include <default.c>
#include <particles.c>

///////////////////////////////

function p_fountain(PARTICLE* p)
{
	VECTOR vTemp;
	vec_randomize(vTemp,2);
	vec_add(p.vel_x,vTemp);
	vec_set(p.blue,vector(random(255),random(255),255));
	set(p, MOVE | BRIGHT | TRANSLUCENT);
	p.alpha = 100;
	p.size = 2;
	p.gravity = 0.2;
	p.skill_a = 3; // fade factor
	p.event = p_fade;
}

function p_fountain_sprite(ENTITY* p)
{
	VECTOR vTemp;
	vec_randomize(vTemp,2);
	vec_add(p._VEL_X,vTemp);
	vec_set(p.blue,vector(random(255),random(255),255));
	set(p, _MOVE | BRIGHT | TRANSLUCENT);
	p.alpha = 100;
	p._SIZE = 6;
	p._GRAVITY = 0.2;
	p._FADE = 3; 
	p.event = p_fade_sprite;
}


function main()
{
	d3d_instancing = 1;
	max_entities = max_particles;
	fps_max = 1000;
	level_load(NULL);
	video_window(NULL,NULL,0,"Sprite particle demo");
	vec_set(camera.x,vector(-150,0,50));

	while(1)
	{
		if(key_s) {
			effect_sprite(NULL,p_fountain_sprite,maxv(2,40*time_step),vector(0,0,0),vector(0,0,5));
			draw_text(str_printf(NULL,
			"%d fps for %d sprites",
			(long)(16/time_frame),(long)num_entities),
			5,5,COLOR_WHITE);
			} else {
			effect(p_fountain,maxv(2,2*time_step),vector(0,0,0),vector(0,0,5));
			draw_text(str_printf(NULL,
			"%d fps for %d particles (press [S] for emulation with sprites)",
			(long)(16/time_frame),(long)num_particles),
			5,5,COLOR_WHITE);
		}
		
		if(key_i)
		camera.flags |= ISOMETRIC;
		else	
		camera.flags &= ~ISOMETRIC;
		
		wait(1);
	}
}



Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P
Re: d3d_instancing = 1; [Re: rojart] #415818
01/24/13 09:47
01/24/13 09:47
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Originally Posted By: rojart
if I try with particle sprites, like code below the fps went down. Is d3d_instancing = 1 restricted for sprite particles?


d3d_instancing = 1 is for sprite entities only and doesn't affect particles. The Pro Edition automatically uses instancing which can be turned off by particle_mode = 1.

Re: d3d_instancing = 1; [Re: HeelX] #415820
01/24/13 10:18
01/24/13 10:18
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline OP
User
rojart  Offline OP
User

Joined: Oct 2004
Posts: 900
Lgh
In the manual is nothing described about sprite entities restriction and should be changed.

Quote:
Renders objects with instancing; as many objects as possible are rendered with a single draw function, thus reducing the rendering time in levels with many similar objects f.i. for vegetation sprites. Instancing can increase the frame rate by up to 30%.


Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P
Re: d3d_instancing = 1; [Re: rojart] #415826
01/24/13 11:13
01/24/13 11:13
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
HeelX is right, particle instancing is automatically activated with the Pro Edition. "Objects" means entities, not particles. This will be made clearer in the manual.

Re: d3d_instancing = 1; [Re: jcl] #415830
01/24/13 11:39
01/24/13 11:39
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline OP
User
rojart  Offline OP
User

Joined: Oct 2004
Posts: 900
Lgh
Ok thanks, but if particle instancing is automatically activated but not for sprite particle entities.

But by default, internal image is set, like ackfont.pcx, is this not sprite entity?

Quote:
When the particle has no bmap, it is a colored dot, taken from an internal image that also contains the default font. This font can be replaced by providing an external ackfont.pcx image. Note that this will also replace the default particle image, which is taken from position (100,56) of the ackfont.pcx image.


Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P
Re: d3d_instancing = 1; [Re: jcl] #415831
01/24/13 11:40
01/24/13 11:40
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
maybe a bit offtopic, but is there any chance to have once some kind of model instancing in 3DGS (Pro)? as I remember I read once it was developed, but was cancelled finally because of the complexity and low resulting performance increase. but as I know static and dynamic batching is used widely in games to run faster, and offered by some other engines, probably having different entity management system...


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: d3d_instancing = 1; [Re: sivan] #415835
01/24/13 12:39
01/24/13 12:39
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Originally Posted By: sivan
is there any chance to have once some kind of model instancing in 3DGS (Pro)?
I support this feature request! If you have developed this already, why not dropping it into the engine? Would be a nice addendum to the already neglected beta page wink

Re: d3d_instancing = 1; [Re: HeelX] #415851
01/24/13 17:13
01/24/13 17:13
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline
Serious User
Rackscha  Offline
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
@sivan: complexity depends on the restrictions you dont want to have tongue

i.e.:
- Load mesh, if its a new mesh: create a pointer to an empty entity_instancelist. The model saves the pointer. The list_pointer is also registerd for the engine

-on visiblity cheeck for entity:
if its visible:
add the entity to the list of its model

on drawing:
engine runs through all registerd entity_instancelists. On each list, it creates the instance buffers
1 static buffer linking to the mesh
1 dynamic buffer with an entry array. One entry per entity in current instancelist. each entry holds position, rotation, texture.

then these 2 instance buffers are send to the instancing drawcall.

for the entities, you have to write a shader which incoorporates thes instancebuffers. Because the given instance mesh is rendered for each entry. the entry is given to the shader(which param is specified in the instancebuffers)

Basic instancing, restricted to position, rotation, texture

Important: the above is the rough description on doing it in DX11. In DX9 it might be a bit different. But i dont think its TOO diferent.


MY Website with news of my projects:
(for example my current
Muliplayer Bomberman,
GenesisPrecompiler for LiteC
and TileMaster, an easy to use Tile editor)
Sparetime-Development

Re: d3d_instancing = 1; [Re: Rackscha] #415861
01/24/13 21:23
01/24/13 21:23
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
I would be happy with DX11 too laugh


Free world editor for 3D Gamestudio: MapBuilder Editor

Moderated by  old_bill, 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