Eeeew, my grass looks like ****

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Eeeew, my grass looks like ****

Post by krama757 »

Guys how do you work with billboarded grass? I cant seem to get good results.

My grass texture is:
Image

And my grass turns out to look like:
Image

A desired effect would be like:
[IMG]http://www.kjapi.com/images/screenshots ... t0.jpg[IMG]

Code:

Code: Select all

IBillboardSceneNode* grass[100][100];
	ITexture* grassTex = driver->getTexture("./data/Trial Grass 1/Trial5.bmp");

	driver->makeColorKeyTexture(grassTex, (SColor)(255,0,0,0));
	grassTex->regenerateMipMapLevels();

	int g = 0;

	for(i = 0; i<60; i++){
		for(int j = 0; j<60; j++){
			//g = i;
			//if(i%2 == 0)
			//	g = i+1;
			grass[i][j] = smgr->addBillboardSceneNode(0, dimension2d<f32>(1.0f,0.5f));		
			grass[i][j]->setMaterialTexture(0,grassTex);
			grass[i][j]->setMaterialFlag(EMF_LIGHTING, false);
			grass[i][j]->setMaterialFlag(EMF_BACK_FACE_CULLING, false);
			grass[i][j]->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL_REF);
			grass[i][j]->setPosition(vector3df(i*0.5, -0.5, j*0.5));
		}
	}
Any suggestions would be very appreciated!

(My return gift to the community will be a tree builders tutorial after I get this stuff done :))
master123467
Posts: 60
Joined: Mon Jan 02, 2006 6:03 pm
Contact:

Post by master123467 »

well ok i thnk i could give it a try
Guest

good job!

Post by Guest »

it's very cool!
i am looking forward your tutorial. :D
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

master123.4567 do you have any suggestions? I have no clue what you are trying :)
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

billboard grass looks crappy man. (tho i also made the mistake of making the grass texture too dense)
ideally you want areas of mesh grass clumps that share the same mesh buffer, which create and fade in as you get close, and to know which ones are the top vertices so you can animate them blowing in the wind or being disturbed.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

Well ignore the animation. I just want some good looking grass :)

The problem with rendering grass only at certain distances is that you would have to loop through all the nodes and check to see if they are close enough to the player. This used to lag truevision when I tried it there.


======

I wonder what causes things to lag. Is it the number of triangles rendered or is it just filling...how many pixels of the screen you fill. According to my video card specifications it can easily do 40 million triangles at 40 fps.

My bro says that rendering back to front is much slower than rendering front to back because lag is cause by filling in pixels. Does this ring a bell for someone? If its possible to do this please do tell me how.

Currently im using a nested for loops and am rendering front to back (or so I think...)
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

the particle system node manages tons more billboards because they're all in the same mesh buffer, so they all draw at the same time instead of switching between them.
it still has to make each billboard face the camera every frame though, and upload the vertices to the graphics card. irrSpintz has hardware mesh buffers, which give an amazing performance boost.
if you want a lot of grass though, the only parts that exist should be near the camera. if you had a few types of plant that shared the same textures, you could copy lots of them in to one hardware buffer making a dense clump of plants. you create, fade in, fade out and destroy the clumps as you walk around.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

Ah, so instead of managing each single grass billboard, you manage clumps of them, right?

(Along with using hardware buffers....I still need to get spintz up and running properly. I keep getting runtime errors :()
MikeR
Posts: 767
Joined: Sun Dec 26, 2004 4:03 pm
Location: Northern California USA
Contact:

Post by MikeR »

Your grass looks just like your texture. I saved a copy, and zoomed in a tad so I could see it better. To get the effect you are looking for, you are going to have to remove some of the light green. Making the blades thinner might help as well.
If it exists in the real world, it can be created in 3d

Sys specs:
AMD 3700+ 64 processor
1.0 gb ram
e-Geforce 6600 graphics 256 mb onboard ram
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

omaremad_

Post by omaremad »

http://mirror.ati.com/developer/samples/grass.html

same thing as the others (bad billboard)

but the shader also add realism
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

Do you guys have any good samples of grass textures or the like? A google search revealed nothing.

I think I might get better effects if I can apply better transparecies...I have 2 questions for you guys:
1) When I have a blurry texture, I get a really nastry black outline on all the grass because the colorkey only works on 100% black...is there a better way to do colorkeys?

2) How would I make an object progressively transparent. I took a look at the IMeshManipulator->setVertexColorAlpha(IMesh*, alpha) and it didnt do anything to my tree meshes....so anything else I can do?
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

ideally you need new render mode (or fix the one my clouds use), transparrent alpha channel and transparrent vertex alpha together. spintz or hybrid may have one, i dunno, but i think i remember a discussion about it ages ago. otherwise, transparrent alpha add works with vertex colours but its a ghostly transparrent effect.
also you cant use vertex alpha for most meshes, it's slow, and all nodes that use that mesh will also fade. i think we need some fade-out material/shader for that instead.
all this talk about grass is getting me excited, i think i can feel a grass node coming on!
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Guest

Post by Guest »

did you look at my link?
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

yeah very nice omar! i'm still scared of shaders though. how about i make some particle system grass and you make it wiggle round with a shader. that would be cool
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

I dont mind :) Please do make some grass ^_^

Omaremand I had that link. They use billboards with one blade of grass per billboard. Then they place it in a random position on the heightmap--animating using a vertex shader and lighting using a pixel shader.

But, they are still using billboards. Thats the problem with mine...although I use billboarded grass it doesnt turn out as well. Mike's suggestions involve just chaning the texture.. Is that all there is to it?

I think using spintz's vertex buffers will help with speed...but what about quality?

=======
And what about those other two questions...if I understood your response then we would have to write a new material that allows progressively transparent stuff?
Post Reply