Grass Billboarding

Started by
8 comments, last by rubicondev 14 years ago
Hi guys, I am currently trying to implement some tree billboards to my scene and am stuck at the moment. Currently I am trying to employ the method used in the book - Introduction to 3D game programming with directx 10 , Frank D. Luna and he has made it so that the billboards always face the camera. Which I don't want to be honest as when the camera moves the trees look fake. So how would I do this? here is my draw code:
void TreeSprites::draw(const Light& L, const D3DXVECTOR3& eyePosW, const D3DXMATRIX& viewProj)
{
	mfxEyePosVar->SetRawValue((void*)&eyePosW, 0, sizeof(D3DXVECTOR3));
	mfxLightVar->SetRawValue((void*)&L, 0, sizeof(Light));
	mfxViewProjVar->SetMatrix((float*)&viewProj);
	mfxTreeMapArrayVar->SetResource(mTreeMapArrayRV);

	md3dDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_POINTLIST);
	md3dDevice->IASetInputLayout(mVertexLayout);

	

	D3D10_TECHNIQUE_DESC techDesc;
    mTech->GetDesc( &techDesc );

    for(UINT i = 0; i < techDesc.Passes; ++i)
    {
        ID3D10EffectPass* pass = mTech->GetPassByIndex(i);
		pass->Apply(0);

		UINT stride = sizeof(TreeVertex);
		UINT offset = 0;
		md3dDevice->IASetVertexBuffers(0, 1, &mVB, &stride, &offset);
		md3dDevice->Draw(mNumTrees, 0);
	}
}
and here is my draw call:

mTrees.draw(mParallelLight, mEyePos, mView*mProj);
Any help on the matter would be great and if possible could you please explain the matter so that I don't have to ask such a menial question next time round :P Thanks a lot! :D

Game Development Tutorials - My new site that tries to teach LWJGL 3.0 and OpenGL to anyone willing to learn a little.

Advertisement
What would you rather it do? That's pretty much what billboarding is - you have a single sprite that you rotate to face the camera. The upside is that you don't need to render more complex 3D geometry, the downside is that you can only ever see the one angle of the object.
[TheUnbeliever]
well I would rather have them rendered and motionless and then make it look 3D by putting two together at right angles. Because right now it just looks pretty bad to be honest.

Game Development Tutorials - My new site that tries to teach LWJGL 3.0 and OpenGL to anyone willing to learn a little.

Quote:Original post by emforce
well I would rather have them rendered and motionless and then make it look 3D by putting two together at right angles. Because right now it just looks pretty bad to be honest.
It sounds like you just want a model with no billboarding then?
If you are using DX10 then you can rely on hardware instancing to draw an absolute shitload of "real" trees at a fair ole clip. You certainly don't need to use such a dated technique as this. Maybe just have one LOD level and your done.

------------------------------Great Little War Game
Can I use instancing for grass though? It was just I didn't want to be rendering thousands of grass tuft models if it was going to severely increase my processing strain. Although to be honest I haven't created anything big enough to be a strain on my computer :P

+1 for the trees info though. I really appreciate your help! :D

Edit: didn't see jyk's post.

So I just create a 2 models which intersect each other and just texture them? P.s I will try implementing something like this tonight after studying! Thanks a lot :D

+1 as well :D

Game Development Tutorials - My new site that tries to teach LWJGL 3.0 and OpenGL to anyone willing to learn a little.

Have you looked at this?

GPU Gems: Rendering Countless Blades of Waving Grass

Pretty much uses the method you described (renders three intersecting textured quads), also describes animation issues.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
That nvidia thing looks brilliant! Thank you so much for the link. I had a look at a few of the pages and to be honest it looks superb. Is that just a couple of bits from the book or is that the whole deal?

Thanks again!

Game Development Tutorials - My new site that tries to teach LWJGL 3.0 and OpenGL to anyone willing to learn a little.

The GPU gems is a really nice series. GPU Gems 1,2,and 3 have been published, and I think so far 1 and 2 are completely free to read online in their entirety. I actually picked up a copy of Gems 1 just because its a real beautiful hardcover full-color book.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
Quote:Original post by emforce
Can I use instancing for grass though? It was just I didn't want to be rendering thousands of grass tuft models if it was going to severely increase my processing strain.
Oops, that was me projecting from another thread about rendering millions of trees! You do mention TreeSprites in your code :)

But yes, you could use hardware instancing for this too. You only make one drawprim call. But you'd do better with one of those nVidia solutions - I've implemented something similar (not as good, didn't see that article in time) but it was still a jaw-dropper the first time I saw the results. Definitely worth the extra effort.

EDIT: Another technique that can work is, google on standby, "Shell Rendering". It's usually used for fur, but you might get mileage out of grass and it's piss easy to get running.
------------------------------Great Little War Game

This topic is closed to new replies.

Advertisement