Vegetation Template

Posted By: Emre

Vegetation Template - 04/04/08 19:11

Hi Friends. This is quickly vegetation template.(auto create)
Image&Video:



Video

How to use?
Include "vegetation.wdl" to your project and change configuration and added "Terrain action" to your Terrain object.Just this.

Performance?
Good performance. I use randomize invisible function.
3000 entities (200 render) 40 fps on my pc.
my pc configuration:
3ghz pentium(478 pin)
1 gb ram
Radeon 9800 Pro(128 mb)
Note: I use a Loopix's free materials(model&fx) for demo.(terrain,tree,bush etc.)
Mistake:(vegetation.wdl Line:22)
"Invisible Vegetation Randomize. If <10 low performance"
i forgot to change this section. This is not true.
True:Invisible&action(fake wind)randomize. If <=10 high performance else low performance.
And sorry for my bad speak english.
Download Demo&Source:
Rapid
My site

Edit:
Demo's time_factor=0.5;
if you use time_factor=1.0,
lv_speed = random(12);
change:
lv_speed = random(6);
and
if you think "terrain is brightly"(for demo);
open multitex4.wdl file and change line:339.
FinalColor *=(In.Color-0.50);
change:
FinalColor *=(In.Color-0.90);
Now it's very darkness.

Edit3 \:\) if you need a Lite-c version Here

Posted By: Pappenheimer

Re: Vegetation Template - 04/04/08 19:27

Wow! Looks wonderful! Can't wait to try it!

EDIT: Tried it! It s a wonderful atmosphere! I was waiting for the day to come! But, it didn't come!

On my pc (3GHz, 1Gb RAM, Radeon x300) and on my laptop (1,6 GHz Celeron, 512 RAM, Radeon Mobility) quite laggy! \:\(

One suggestion to some trees and stones which are still in the air: get from the trace the normal of the floor under the model, to set it deeper depending the slope of the floor.
Posted By: Quad

Re: Vegetation Template - 04/04/08 19:40

\:o looks awesome.
Posted By: Nems

Re: Vegetation Template - 04/04/08 20:03

Wondefull work, looks so moody \:\)
Posted By: Darkyyes

Re: Vegetation Template - 04/04/08 20:47

This was wonderful \:\) easy to find an estimate of how much poly you should render on screen at maximum in your games, 59-60 fps with 216k polys
with a HD3870
intel e4300
2gb ram in windows vista \:\)

just tweak the vegetation codes and double the amount of trees rocks and bushes, and increase distance to 5000 and you get a great view of polys :p

300k polys at 25 frams :p quite a large fps drop there :p cpu load at 60% on each core while running, gpu I bet running a great deal more ;\)
Posted By: Blink

Re: Vegetation Template - 04/04/08 20:49

fantastic, i love the style of the video, i was actually waiting for a monster to jump out of the fog!!! the vegetaion gives it a real eerie feeling, like you were lost in the woods.
Posted By: Why_Do_I_Die

Re: Vegetation Template - 04/05/08 09:27

Man this looks insanely nice , Thnx for the genorous contribution.
Posted By: BlueBeast

Re: Vegetation Template - 04/05/08 12:28

This looks great \:D

2 quick questions...

Is the framerate much better when you don't have moving/swaying trees/plants?
(is that what slows things down?)

Does the arrangements of trees/bushes change whenever you reload the level? or does it create a file to 'remember' what the arrangements were?
When you find an arrangement that you want, is there a way to save it?

Thanks for the contribution!

- Jason
Posted By: Emre

Re: Vegetation Template - 04/05/08 13:15

 Quote:
Is the framerate much better when you don't have moving/swaying trees/plants?

Yes,sure.
 Quote:
Does the arrangements of trees/bushes change whenever you reload the level? or does it create a file to 'remember' what the arrangements were?
When you find an arrangement that you want, is there a way to save it?

My english very bad but i guess i understand your question.
Tree and brush creating is automaticly but if you reload level,does not change arrangement of tree&brush etc.. Tried demo.

And friends, if your need a performance;
reduce tree & bush number and use d3d_triplebuffer.

Thanks for all comment!
Posted By: ComplexStudios

Re: Vegetation Template - 04/05/08 14:01

harika olmuş tebrikler!
/////////////////////////
it's great.congratulations
Posted By: Machinery_Frank

Re: Vegetation Template - 04/06/08 08:14

Great tool and easy interface. This is exemplary work. Congratulation!
Posted By: not_me

Re: Vegetation Template - 04/06/08 09:06

loooooks amazing! except for the z-sorting errors \:\)
Posted By: nalan

Re: Vegetation Template - 04/12/08 08:53

Looked very convenient,thank you for your help!
Posted By: ello

Re: Vegetation Template - 04/12/08 18:56

yes, this is definately one of the best outdoors i have seen here. i like the second shot. it looks damn coool!

thanks for the contribution!

btw, i like those funny dancing trees. made me laugh
Posted By: NITRO_2008

Re: Vegetation Template - 04/12/08 20:26

Pretty cool. Thanks.
Posted By: S3an

Re: Vegetation Template - 04/14/08 20:02

Very nice contribution!

Ironically i found a 15 to 20 fps jump in the lite-c version by simply removing the set(my, INVISIBLE) and reset(my, INVISIBLE) sections from each function. Apparently the INVISIBLE flag does nothing for performance?
Posted By: RandomDude

Re: Vegetation Template - 06/24/08 12:15

Very nice indeed, thank you!
Just a small question, how do i make areas with no terrain? Now it keeps spawning in my water.
Posted By: Emre

Re: Vegetation Template - 06/24/08 16:10

Good question RandomDude. i forget water. smile
Use it for water problem;
http://mirror.pantharay.com/vegetation.c
(right click&save as)




@S3an; No. invisible flag for performance. Maybe you are right just for demo. But you use 4000/5000 entities and smooth land,performance very low(if you close invisible/visible function). Look at the Jungle Demo .(walk and fly play)

Thanks for all nice comment.
Posted By: RandomDude

Re: Vegetation Template - 06/24/08 16:42

Thx.

Edit2:
Nevermind, But a new problem came up, There is some kind of fog over my water wich makes it really dark.. But i cant figure out what makes it.
(Im using slins watershader with the render2texture.dll for my water.)

SOLVED!
scanner_func_startup used the water material for some reason.. Well well.. smile
Posted By: MadJack

Re: Vegetation Template - 09/06/08 09:03

I like very much this contribution. Thanks Emre !
I just need more control on the way the vegetation and rocks are set, so I am going further on your script by adding a bitmap mask where

  • red channel is for the trees,
  • green is for the bushes 1,
  • blue is for the rocks,
  • alpha could be for the bushes 2

Channel value (0 -> 255) will be used for the density.
There is still random settings for natural effect.
In the black area of the bitmap, nothing is set.

I am getting first results with the red channel, as you can see here :

Here is the bitmap:

Another example


Posted By: Emre

Re: Vegetation Template - 09/06/08 11:26

Wow! very nice MadJack smile
How did you do it? Hit.rgb?
Posted By: MadJack

Re: Vegetation Template - 09/06/08 12:08

In your "terrain" action, instead of a "while" loop to create the trees, I open my BMP file and work on the rgb component of each pixel.
You'll see it soon, I'll give my script here or in the Lite-C contribution forum.

I just want to clean and complete it before grin

BTW, maybe I should say YOUR code with slight changes smile
Posted By: MadJack

Re: Vegetation Template - 09/06/08 13:28

Tree channels working now:



Posted By: MadJack

Re: Vegetation Template - 09/06/08 16:17

OK, this is the function I use :
Code:
function set_decor()
{
	var      aFormat; 
	var      aAlpha;
	var      aPixel;
	var      i,j,k;
	var      aChannel;
	COLOR    aColor;
	var      aStep_x, aStep_y;
	var      nb_obj;
	float    aMaxRed = 0;
	float    aMaxGreen = 0;
	float    aMaxBlue = 0;
	float    aDensityRed = 0;
	float    aDensityBlue = 0;
	float    aDensityGreen = 0;
	float    aDensityDec = 0;
	
	var dens_red[256];
	var dens_blue[256];
	var dens_green[256];
	
	var aSide_x, aSide_y;
	
	BMAP* texv = "vegetation.bmp";   // Vegetation - Rocks density map 
                                         // Format = BMP   type RGB 24 bits
                                         // Size is what you want BUT 128x128 is enough
	
	aSide_x = bmap_width (texv);
	aSide_y = bmap_height (texv);
	
	aStep_x = (my.max_x - my.min_x)/aSide_x ;
	aStep_y = (my.max_y - my.min_y)/aSide_y ;
	
	aFormat = bmap_lock(texv,0);
	
	for (i=0; i < 256; i++) 
	{
		dens_red[i] = 0;
		dens_blue[i] = 0;
		dens_green[i] = 0;
	}
	
	for (i=0; i < aSide_x; i++) 
	{
		for (j=0; j < aSide_y; j++)
		{
			aPixel = pixel_for_bmap(texv,i,j);
			pixel_to_vec(aColor, aAlpha, aFormat, aPixel);
			
			dens_red[aColor.red]++;
			dens_blue[aColor.blue]++;
			dens_green[aColor.green]++;
		}
	}

	for (i=0; i < 256; i++) 
	{
		aMaxRed 		+= i * dens_red[i];
		aMaxGreen 	+= i * dens_green[i];
		aMaxBlue		+= i * dens_blue[i];
	}

	if (aMaxRed > 0) aDensityRed = tree_number / aMaxRed;
	if (aMaxGreen > 0) aDensityGreen = bush_number / aMaxGreen;
	if (aMaxBlue > 0) aDensityBlue = rock_number / aMaxBlue;
	
	for (i=0; i < aSide_x; i++) 
	{
		for (j=0; j < aSide_y; j++)
		{
			aPixel = pixel_for_bmap(texv,i,j);
			pixel_to_vec(aColor, aAlpha, aFormat, aPixel);
			
			aChannel = aColor.red;
			if (aChannel > 0)
			{
				aMaxRed = aChannel * aDensityRed;
				nb_obj = integer (aMaxRed);
				
				aDensityDec = aMaxRed - nb_obj;
				
				if (aDensityDec > random(1)) nb_obj++;
				
				for (k=0; k<nb_obj; k++) 
				{
					if (number_tree < tree_number)
					{
						ent_create(tree1, vector(my.min_x + i*aStep_x + random(aStep_x),	my.max_y  - j*aStep_y - random(aStep_y),my.z+8300), tree_func);
						ent_create(tree2, vector(my.min_x + i*aStep_x + random(aStep_x),	my.max_y  - j*aStep_y - random(aStep_y),my.z+8300), tree_func);
						ent_create(tree3, vector(my.min_x + i*aStep_x + random(aStep_x),	my.max_y  - j*aStep_y - random(aStep_y),my.z+8300), tree_func);
						number_tree+=1;
					}
					
				}
				
			}
			
			aChannel = aColor.blue;
			if (aChannel > 0)
			{
				aMaxBlue = aChannel * aDensityBlue;
				nb_obj = integer (aMaxBlue);
				
				aDensityDec = aMaxBlue - nb_obj;
				
				if (aDensityDec > random(1)) nb_obj++;
				
				for (k=0; k<nb_obj; k++) 
				{
					if (number_rock < rock_number)
					{
						ent_create(rock1, vector(my.min_x + i*aStep_x + random(aStep_x),	my.max_y  - j*aStep_y - random(aStep_y),my.z+8300), rock_func);
						number_rock+=1;
					}
					
				}
				
			}
			aChannel = aColor.green;
			if (aChannel > 0)
			{
				aMaxGreen = aChannel * aDensityGreen;
				nb_obj = integer (aMaxGreen);
				
				aDensityDec = aMaxGreen - nb_obj;
				
				if (aDensityDec > random(1)) nb_obj++;
				
				for (k=0; k<nb_obj; k++) 
				{
					if (number_bush < bush_number)
					{
						ent_create(bush1, vector(my.min_x + i*aStep_x + random(aStep_x),	my.max_y  - j*aStep_y - random(aStep_y),my.z+8300), bush_func);
						number_bush+=1;
					}
					
				}
				
			}
		}
	}

	bmap_unlock(texv);

}


This code is supposed to work with the code given here by Emre
You just need to modify terrain action :
Code:
action Terrain()
{
	my.material=multirgb;
	set(my,UNLIT);
	//section:Terrain Coordinate
	//entry:Minimum x
	my.min_x=-3000;//5295//4081
	//entry:Maximum x
	my.max_x=3000;//4566//3041
	//entry:Minimum y
	my.min_y=-3000;//5200//4053
	//entry:Maximum y
	my.max_y=3000;//4500//3300
	//image:help.bmp
	
	bush2_load();
	
	set_decor();
	
}


It replace, bush_load, rock_load and the tree load part.
Bush2_load could also be done using the alpha channel of the bitmap.
Posted By: Emre

Re: Vegetation Template - 09/06/08 19:29

Thank you very much MadJack!
It's really, really very nice.
Thanks for your effort, and sharing. smile
Posted By: MadJack

Re: Vegetation Template - 09/06/08 19:49

Thanks to you too wink

There was a mistake in my code, all the entities functions were "tree_func", I have edited now, even if it was funny to see rocks like floating on lava grin
Posted By: Blink

Re: Vegetation Template - 09/06/08 23:27

is the c-script version for shader model 3.0 only? i am getting a strange error. i only have shader model 2.0. the error says something about a d3d buffer. and points to line 435 in the wdl.
Posted By: MadJack

Re: Vegetation Template - 09/07/08 09:25

  • This function is in Lite-C.
  • It is developped to work within Emre contribution, but as I needed to clearly see the vegetation distribution, I use a specific main file ("test.c") very simplified (whithout D3D functions)
  • I have no problem by testing from SED -> test.c -> run test with current file
  • The only error message I get is when I try it from WED -> run
  • No problem when using it in my own project (Loopix based)
  • There is no shader used in the function itself, only lite-c script

From there, I can't help you more, sorry, but I can give you my full test project sources here (6.6 Mo):
Test vegetation + density
Posted By: Blink

Re: Vegetation Template - 09/08/08 19:21

thanks, i will give it a shot. i just want some vegetation for a couple of levels in my project, something basic.
Posted By: Frederick_Lim

Re: Vegetation Template - 09/09/08 05:34

Wow that's really amazing, but how to cast the object's shadow on terrain?
Posted By: MadJack

Re: Vegetation Template - 09/09/08 07:59

So far, I don't really know.
I use Loopix's Mystymood template which comes with a shadowmap generator. But for me it will not work because I want to use dynamic night and day, so I need dynamic shadow and I don't know what is the best solution for that...
Posted By: PadMalcom

Re: Vegetation Template - 09/11/08 07:46

hey could you upload the lite-c version on your server? I've got problems downloading the file.
Posted By: MadJack

Re: Vegetation Template - 09/11/08 08:23

What file do you mean ? Mine or Emre's one ?
Posted By: 3run

Re: Vegetation Template - 08/27/11 12:47

Hey guys, is there anyway for someone to reupload "Test vegetation + density" by MadJack? It seems that his website is down.
Posted By: Sajeth

Re: Vegetation Template - 06/25/12 21:01

Bump... I remember having this saved around somewhere, but I cant find it. Loved the mood of it.
© 2024 lite-C Forums