Creating leaves on trees..

Blitz3D Forums/Blitz3D Programming/Creating leaves on trees..

D_Town_Tony(Posted 2004) [#1]
I've seen it done so often but am curious if someone could quickly tell me how its done.


Ross C(Posted 2004) [#2]
Well, You have a tree base, just a mesh of a tree with no leaves on it. Then you attach sprites, or quads, textured with a texture that comprises of lots of leaves.


Ross C(Posted 2004) [#3]
You don't actually create the leaves individualy. A big clump of leaves on a texture, applied to a sprite or quad.


AbbaRue(Posted 2004) [#4]
I use a low poly tree mesh with flat area for the branches.
Then I texture it with a random green mesh, with black set transparent.
Then it looks like real leaves you can see behind.
Here is code for making random green texture.

ts=512
tex55=CreateTexture (ts,ts,15)
SetBuffer TextureBuffer (tex55,0)
For cdy= 0 To ts-1
For cdx= 0 To ts-1
rca=255 ;Alpha
rcg=Rnd(0,150) ;Green
rcr=Int(rcg/2) ;Red
rcb=Int(rcg/4) ;Blue
argb=0 ;clear color
argb=(rca Shl 24) Or (rcr Shl 16) Or (rcg Shl 8) Or (rcb)
If rcg<74 Then argb=0 ;just to be sure lots of black
WritePixel cdx,cdy,argb

Next
Next

SetBuffer BackBuffer()


Remember that last line to set the buffer back to BackBuffer.