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
2 registered members (degenerate_762, Nymphodora), 1,012 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 5
Page 347 of 554 1 2 345 346 347 348 349 553 554
Re: What are you working on? [Re: oliver2s] #434420
12/18/13 10:11
12/18/13 10:11
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Indeed, but why is the entity count so high, because of grass models? Have you thought about merging them somehow together in small clusters?


"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: What are you working on? [Re: Superku] #434421
12/18/13 10:19
12/18/13 10:19
Joined: Aug 2002
Posts: 3,258
Mainz
oliver2s Offline
Expert
oliver2s  Offline
Expert

Joined: Aug 2002
Posts: 3,258
Mainz
Originally Posted By: Superku
Indeed, but why is the entity count so high, because of grass models? Have you thought about merging them somehow together in small clusters?


This would only work for creating clusters dynamically every time the level is loaded. Otherwise I would not recommend clustering for objects like grass, because this increases the nexus dramatically. (Precalculated) clustering works good for (2D) trees only (and other big 2D objects).

Re: What are you working on? [Re: oliver2s] #434426
12/18/13 11:31
12/18/13 11:31
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
yes, there are about 15000 grass models in this level, and fast enough with the custom shadowmapping based on the old shade-c one, but much slower with pssm (depending on number of views used). it's main drawback is slow creation, because currently cannot be handled by a wmb file (but maybe creating several wmb files can make it faster). I asked Jcl to solve it (max entity count is currently about 3000 in a wmb).

grass merging is not a plan, I thought of dynamically created grass made of dx triangles whose advantage is better terrain surface alignment, but yes, the nexus size can be a problem what maybe can be avoided by dynamc memory allocation which unfortunately makes things slower again, so I don't know...


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: What are you working on? [Re: sivan] #434439
12/18/13 15:16
12/18/13 15:16
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
Actually, batching grass together to clusters of maybe 5k to 10k tris is a pretty good idea. The only "issue" is that it needs to be aligned to the ground. So you will need many different meshes to cover everything. But for terrain if you´ve got a heightmap you could get away with just one mesh by doing the alignment in the vertex shader of the grass sampling the heightmap.
Also in case you did not do it yet deactivate collision mesh generation while creating passable entities by setting the global variable collision_mode to 0 and back to 1 when you are done.

Edit: You may want to consider even bigger grass meshes because the few additional polygons you save from more efficient culling with smaller ones are most probably cheaper than the overhead of more entities.
Or using instanced rendering might be quite simple to implement in Lite-C, the only harder part will be to provide the transformations to the shader, as you would then probably just create a custom grass renderer.

Last edited by Slin; 12/18/13 15:24.
Re: What are you working on? [Re: Slin] #434445
12/18/13 17:32
12/18/13 17:32
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Quote:
The only "issue" is that it needs to be aligned to the ground. So you will need many different meshes to cover everything. But for terrain if you´ve got a heightmap you could get away with just one mesh by doing the alignment in the vertex shader of the grass sampling the heightmap.

I've tried exactly this some years ago and remembered it now because of your comment. I did not get this to work back then because the vertex shader would not except tex2D commands, the trick is to use tex2Dlod (supported from VS3.0 and above) instead. Works fine and is amazingly fast:



"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: What are you working on? [Re: Superku] #434448
12/18/13 18:50
12/18/13 18:50
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
thanks for the good ideas!


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: What are you working on? [Re: Slin] #434481
12/19/13 09:48
12/19/13 09:48
Joined: Aug 2002
Posts: 3,258
Mainz
oliver2s Offline
Expert
oliver2s  Offline
Expert

Joined: Aug 2002
Posts: 3,258
Mainz
Originally Posted By: Slin
The only "issue" is that it needs to be aligned to the ground. So you will need many different meshes to cover everything.


You will still need different meshes if you don't want gras all over the whole terrain. A solution could be a seedmap, but I didn't try that yet.

EDIT: Superku: do you have the shader code for this? Wanna try this in IceX3

Last edited by oliver2s; 12/19/13 09:51.
Re: What are you working on? [Re: oliver2s] #434497
12/19/13 16:04
12/19/13 16:04
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Quote:
You will still need different meshes if you don't want gras all over the whole terrain. A solution could be a seedmap, but I didn't try that yet.

If this is only for relatively small areas you could just move the grass under the terrain in the vertex shader. I gave this a try, see here:



It does not look very good but I think the concept is convincingly simple and fast.

Quote:
EDIT: Superku: do you have the shader code for this? Wanna try this in IceX3

What I did is the following:

Code:
float2 texpos = float2((worldPos.x+1024.0)/2048.0,1-(worldPos.z+1024.0)/2048.0);
	float4 info = tex2Dlod(heightsampler, texpos.xyxy);
	float height = info.g; // terrain height on green channel
	float seed = info.r*2; // "seed map" on red channel, grey = normal length


Then multiply inPos.y by "seed" (the grass polygons should start at z = 0 in MED), multiplay inPos with matWorld and increase Out.Pos.y by some value (the terrain height) and height before you multiply it with matViewProj.


"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: What are you working on? [Re: Superku] #434500
12/19/13 16:46
12/19/13 16:46
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
This discussion about gras got me an idea for camera-aligned gras blades en masse:



You just need DynamicModels for the mesh generation, a dummy gras model (contains just a cube) and a gras texture. Use this code:

Click to reveal..

main.c
Code:
#include <acknex.h>
#include <default.c>

#include "DynamicModels.h"

float camera_pan = 0;

BMAP *bmpGras = "grass.tga";

MATERIAL *mtlGras = 
{
	effect = "spritegras.fx";
	skin1 = bmpGras;
}

function main()
{
	level_load(NULL);
	
	bmap_to_mipmap(bmpGras);
	
	//ENTITY *terrain = ent_create("terrain.hmp", nullvector, NULL);
	
	DMDLSettings.flags = 0; // No flags
	
	DynamicModel *dmdl = dmdl_create();
	
	int i;
	for(i = 0; i < 10000; i++)
	{
		DYNAMIC_QUAD quad;
		memset(quad, 0, sizeof(quad));
		
		float px = random(200) - 100;
		float py = random(200) - 100;
		
		int j;
		for(j = 0; j < 4; j++)
		{
			quad.v[j].x = px;
			quad.v[j].z = py;
		}
		
		quad.v[0].u1 = 0;
		quad.v[0].v1 = 0;
		
		quad.v[1].u1 = 1;
		quad.v[1].v1 = 0;
		
		quad.v[2].u1 = 0;
		quad.v[2].v1 = 1;
		
		quad.v[3].u1 = 1;
		quad.v[3].v1 = 1;
		
		dmdl_add_quad(dmdl, quad);
	}
	
	LPD3DXMESH mesh = dmdl_create_mesh(dmdl);
	
	dmdl_delete(dmdl);
	
	
	you = ent_create("gras.mdl", vector(200 * x, 200 * y, 0), NULL);
	ent_setmesh(you, mesh, 0, 0);	
	ent_remove(you);
	
	int x, y, size;
	size = 4;
	for(x = -size; x <= size; x++)
	{
		for(y = -size; y <= size; y++)
		{
			you = ent_create("gras.mdl", vector(200 * x, 200 * y, 0), NULL);
			you.material = mtlGras;
		}
	}
	
	while(1)
	{
		camera_pan = 3.1415 * camera.pan / 180.0;
		wait(1);
	}
}



spritegras.c
Code:
float camera_pan_flt;

float4x4 matWorld;
float4x4 matView;
float4x4 matProj;

Texture mtlSkin1;

sampler2D smpTex = sampler_state
{
	Texture = <mtlSkin1>;
	AddressU = Clamp;
	AddressV = Clamp;
};

struct vsOut
{
	float4 pos : POSITION;
	float2 uv : TEXCOORD0;
};

vsOut vs(float4 pos : POSITION, float2 uv : TEXCOORD0)
{
	float4 p = mul(pos, matWorld);
	
	p.x -= 6 * sin(camera_pan_flt) * uv.x;
	p.z += 6 * cos(camera_pan_flt) * uv.x;
	p.y += 6 * uv.y;
	
	p = mul(p, matView);
	
	vsOut o;
	o.pos = mul(p, matProj);
	o.uv = uv;
	return o;
}

float4 ps(vsOut i) : COLOR
{
	return tex2D(smpTex, float2(i.uv.x, 1 - i.uv.y));
}

technique
{
	pass
	{
		CullMode = None;
		AlphaTestEnable = true;
		AlphaBlendEnable = false;
		ZWriteEnable = true;
		VertexShader = compile vs_2_0 vs();
		PixelShader = compile ps_2_0 ps();
	}
}





Neither the shader nor the generation is perfect, but i think you can improve this a lot.

EDIT: Forgot to say: Should be easy to combine with the techniques above...

Last edited by MasterQ32; 12/19/13 16:47.

Visit my site: www.masterq32.de
Re: What are you working on? [Re: MasterQ32] #434504
12/19/13 19:41
12/19/13 19:41
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
out now!



Free world editor for 3D Gamestudio: MapBuilder Editor
Page 347 of 554 1 2 345 346 347 348 349 553 554

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