Home Technical Talk

Tree texturing

I've got a question regarding the creation of decent looking trees for real time.

Firstly, I've been through the tuts in the Wiki and some of them have been a huge help, I can get the geometry creation and the placing of alpha cards just fine... but I cannot make a decent texture... at all.

The tutorials are all very informative but all have one thing in common and that's that they don't really cover the actual diffuse creation much other than 'find a good branch/leaf/tree texture'... and that's where I'm struggling. Or they suggest PaintFX which is not possible when you don't have access to Maya.

How do people usually go about creating a good diffuse for the branches/leaves?

Is the best way to map some singular leafs onto planes, arrange/scale them in a decent arrangement, then ortho-render them from the top, then repeat for different variations, then map to bigger planes with alpha's?

Also, is it better to do the branches and leaves separately or together?

Two final questions...

1. How in the world do I find a decent 'branch' texture, there's plenty of leaves available in texture collections and CGTextures, but branches aren't so easy to come by it seems.

2. Will I need to spend a lot of time varying the shade/size of the individual leaves on the diffuse or will the final lighting/shadowing provide enough visual variation?

In the tutorials it looks like they use a single leaf texture but somehow by the end, the tree looks nice and varied anyway.

Thanks!

Replies

  • Eric Chadwick
    Options
    Offline / Send Message
    they don't really cover the actual diffuse creation much other than 'find a good branch/leaf/tree texture'
    That's because photos are often the quickest and best way. Just find a good photo and paint an alpha for it.
    http://cgtextures.com/
    Or they suggest PaintFX which is not possible when you don't have access to Maya.
    You're using 3ds Max right? Particles work great for this, just distribute them on selected vertices of the ends of your branches. For example:
    http://www.andyzibits.com/tut_particle_tree_generation.html

    Is the best way to map some singular leafs onto planes, arrange/scale them in a decent arrangement, then ortho-render them from the top, then repeat for different variations, then map to bigger planes with alpha's?
    Yes, if you need to generate a normal map. Otherwise just use a photo. Even with a photo you could use Crazy Bump or the like to generate a decent nm. However most trees avoid normal mapped foliage, usually too expensive a tradeoff for such a small benefit.
    Also, is it better to do the branches and leaves separately or together?
    Trees look much more natural when you have some dead branches here and there, usually towards the bottom. See the trees in STALKER for example, they did an awesome job on theirs.
    1. How in the world do I find a decent 'branch' texture, there's plenty of leaves available in texture collections and CGTextures, but branches aren't so easy to come by it seems.
    Photograph them yourself, or paint them. Silhouetted against the sky is a good way to take photos, as long as you compensate the exposure and you have a good lens that's clean (to avoid bloom).
    2. Will I need to spend a lot of time varying the shade/size of the individual leaves on the diffuse or will the final lighting/shadowing provide enough visual variation?
    Variation only matters for Fall colors, in my experience. Otherwise trees are pretty universally green. You can use vertex color to add some variety. Vert color is also useful for a fake ambient occlusion (darken the interior).

    My several cents...
  • Tom Ellis
    Options
    Offline / Send Message
    Many thanks Eric, awesome response.

    Just a couple things,

    I was unclear about what I meant by using PaintFX. It seems a lot of the tuts use it for laying down the branch diffuse in 2D because it's a parametric way of getting some varied branches. This is a huge step which I'm having the trouble with since branches are tricky.

    I should be able to get something started now thanks. I'll post over in WAYWO when I get some good progress and further crits wil help me nail it hopefully.

    Just gotta keep fighting that urge to fire up SpeedTree, I feel like making trees is kinda a staple skill that I should have even if I use SpeedTree in future.

    Thanks again.
  • Eric Chadwick
    Options
    Offline / Send Message
    You can easily get good branches by painting them in Photoshup, just make a brush that decreases size over the length of the stroke. Or via pressure. White on black. Using reference is key!

    Oh, and good to know how to make them, as not all studios will get a SpeedTree license, without which you cannot use their meshes legally.
  • Tom Ellis
    Options
    Offline / Send Message
    Ok, rather than pollute WAYWO, I thought I'd continue my development in this thread.

    Here's attempt number one... it looks absolutely horrendous I think...trees...are...hard.

    Really it was just a 'test run' to see what I could produce quickly, just to see if I could get the workflow sorted so admittedly if I spent some more time on it then I should be able to get something better looking. Also, I didn't look at any ref so there's another area for improvement next time.

    A couple of things stand out to me though, firstly, the lighting on the leaves. This is just a Max VP shot so it'll be different in engine, but I couldn't get it to light properly. I either had to have SI turned up to 100 which made some look ok but most look blown out and too light, or I turned SI down and any backfacing leaves were black.

    Secondly, when using a realtime shader (Xoliuls or 3Point) it wouldn't display the alpha correctly. The colour looked a lot better but wherever two alpha's overlapped, the plane shape that the texture is mapped onto became visible and blocked out anything behind it if you see what I mean.

    So if anyone has suggestions on where to go from here it'd be much appreciated. Would it be better to rotate some of the leaves on the original branch in the Z as well? It kinda seems odd to do that since it's gonna be rendered from the top but I'm not sure how else to get it looking less 'flat' even though it will be flat.

    firsttree1.jpg
  • Eric Chadwick
    Options
    Offline / Send Message
    I didn't look at any ref so there's another area for improvement next time.
    Biggest no-no right there.
    lighting on the leaves. This is just a Max VP shot so it'll be different in engine, but I couldn't get it to light properly. I either had to have SI turned up to 100 which made some look ok but most look blown out and too light, or I turned SI down and any backfacing leaves were black.
    Option 1: bend the vertex normals, like this. Option 2: 100% self-illumination/emissive, black diffuse (or none), with vertex color to darken the inner vertices. Option 3: Light map instead of vertex color.
    Secondly, when using a realtime shader (Xoliuls or 3Point) it wouldn't display the alpha correctly. The colour looked a lot better but wherever two alpha's overlapped, the plane shape that the texture is mapped onto became visible and blocked out anything behind it if you see what I mean.
    Yeah, welcome to the pain of alpha sorting. Some options here. Most games just use alpha test for foliage... renders faster and has no sorting problems. Downside is you have a hard on/off transparency, and no antialiasing. You can reduce this somewhat with various stipple techniques, see Crysis trees for example.

    Would it be better to rotate some of the leaves on the original branch in the Z as well? It kinda seems odd to do that since it's gonna be rendered from the top but I'm not sure how else to get it looking less 'flat' even though it will be flat.
    First, don't duplicate just that one mini-branch to make a whole branch... the duplication is too obvious in the final result, every "end" looks the same. Some of the leaves look really big too. However the rest of the leaf layout looks good.

    In the final tree, some of the leaves have been scaled really large, that looks quite odd.

    Another trick is to model each branch in a triangle cross-section, like here. This creates less of a flat look.

    I think in general it's looking pretty good. Also helps to make a forest of instanced/rotated/scaled trees and see how it looks.

    And get some reference!
  • Eric Chadwick
    Options
    Offline / Send Message
    Another alpha-sorting option... combine alpha blend with alpha sort. It's supposed to give you nice soft-edged alpha (the alpha blend), mixed with better sorting (the alpha test). But in practice it looks like crap. You still get a fringe of sorting errors around many of the leaves.

    GTA San Andreas did this. Awesome gameplay, but crappy trees...
    gta1.png
  • Tom Ellis
    Options
    Offline / Send Message
    Nice one Eric, many thanks.

    I had no idea how complex of an issue the whole alpha sorting thing was, I assumed I'd just hit the wrong checkbox or something!

    Trees are certainly one hell of an artform once you actually get into the intricacies, yet there's a lot of people *cough* RexM *cough* Adam *cough* who make it looks so damn simple to produce incredible looking stuff.

    I'm getting there for sure, along with the links you've posted, I should be able to get something looking much better next time.

    Thanks again!
  • mayaterror
    Options
    Offline / Send Message
    Eric seems to be talking about getting a photo like this:

    artificialfoliagebranch.jpg

    This is just the first crappy artificial branch I could find on the net, but this illustrates what he's talking about with getting a good photo and creating an alpha from it. You could just take some black matte board or some other good solid color, lay your branch of choice on it, photograph it, and use magic wand, refine edge, quick mask, and many other tools in Photoshop to get a good alpha selection. I've done this, it can get a little tedious in Photoshop but it works.

    Have you looked at NG Plant for foliage generaation? It's free and it's awesome IMO. I'm sure some of those high-end plant generators like Speed Tree and Plant Life are awesome, but this little gem is freakin' sweet. No offense to the author of the Tree Maker script but NG Plant blows it away. It even exports with proper UVS, you just have to UVXform a little. The only thing Tree Maker has over NG Plant is the filleting/blending between branches...

    I experimented a lot with foliage to find what works for my engine, and I'm using a combo of custom made-models and NG-Plant trees, plus one or two Tree Maker trees. For the tree canopies, NG Plant allows for poly-plane generation in a realistically distributed way, and with whatever density you want. NG Plant also allows you to preview your canopies with cylindrical or spherical billboarding, which is what all the cool kids are doing with their foliage.

    For foliage textures, DXT1a with sharpened mips. I think the GPU softens the hard edge on the DXT1a, but programmers are the ones who know about that stuff... But anyway, this format may or may not be possible for your engine.
  • Rick Stirling
    Options
    Offline / Send Message
    Rick Stirling polycounter lvl 18
    ^^

    Great for masks

    Never leave the raw image with the black backgroud, always make the background a green colour that blurs with the leaves, otherwise you can get horrible fringing in the mips.

    Also, try to fit the uvs/polygons as close to the branch shape as possible to cut down on the number of pixels you are testing alpha for. Even though the alpha pixels don't get drawn, they still get processed to see whether or not they should be drawn. OCCASIONALLY it's cheaper to add more polygons to make the poly shape fit the texture - you pay a higher memory cost for the extra geometry, but you save some per pixel processing. Ask your programmer.
  • mayaterror
    Options
    Offline / Send Message
    ^^


    Never leave the raw image with the black backgroud, always make the background a green colour that blurs with the leaves, otherwise you can get horrible fringing in the mips.


    You make an excellent point that I forgot to mention, use a color that matches the leaves as your bg, I did a whole set of interchangeable foliage and I used like 3 shades of green, a yellow, an orange, a red, and a really light blue for snow/ice covered branches, brown & gray for dead branches.

    It was hell on earth reconciling alpha, mips, and DXT1, but I finally got it and this proper color matting was one of the keys.

    The other key (for my engine) was that every freakin' pixel in the alpha MUST be either black or white - nothing else, or you are in for some serious RAGE!

    I think that's one of the fundamental ideas behind DXT1a, though. I mean the b/w alpha, not the rage thing, although they got some of that in there too.
  • Eric Chadwick
    Options
    Offline / Send Message
    But DXT1a basically stores the alpha in the RGB, so the bkg color is literally thrown away. You have no color at all (black) where it's supposed to be transparent.
  • NAIMA
    Options
    Offline / Send Message
    NAIMA polycounter lvl 14
    You can easily get good branches by painting them in Photoshup, just make a brush that decreases size over the length of the stroke. Or via pressure. White on black. Using reference is key!

    Oh, and good to know how to make them, as not all studios will get a SpeedTree license, without which you cannot use their meshes legally.
    Can you tell me how you do that in photoshop ? Is ther a special setting? I do not have a graphic table yet tough ....
  • Eric Chadwick
    Options
    Offline / Send Message
    Brush palette, Expanded View (so you see the settings), Shape Dynamics, set the Size Jitter dropdown to Fade, and change the number to affect how long it takes to scale down. This works without a tablet. Best to get a pressure-sensitive device though, the Fade method is very tedious.
  • Tom Ellis
    Options
    Offline / Send Message
    Ok, I'm gonna get back on this over the weekend, and I'm already struggling.

    Two things;

    Firstly, in the Jeremy Cooke tutorial that Ben Apuna reposted about halfway down this page, how in the world did he create that triple triangle thing geometry for the initial branch? He says it's 'basically a rotated quad (I get that bit) with an extra poly pulled out'... but that seems impossible! I spent about 10 minutes looking at it like it was one of those optical illustions and couldn't work out how to 'pull out another poly'. Not only that, but how is it UV'd? It seems so simple yet I had a nightmare trying to recreate it.

    Secondly, and going back to the texturing.

    I'm pretty comfortable with putting together the branch and leaf formations now, but I'm having some real trouble getting a nice looking conifer branch / leaf setup. This kind of conifer. The main problem being It's difficult to get a good shot of what a conifer branch looks like real close up. It looks kinda fir/pine from a distance but obviously I'm gonna need some close up images of the branches/leaves.

    I actually went out earlier to try and find some examples. I saw one or two that looked kinda similar but not quite right, and also the branches with the leaves on started real high up, and only made up about 10% of the top of the trunk so getting a hold of any branches / leaves without a VERY long ladder / Spiderman would've been impossible.

    Thanks!
  • Eric Chadwick
    Options
    Offline / Send Message
    Can't see the image. I get a 403 forbidden error.

    The tri geom... make a quad, create an edge from one corner to the other, copy+rotate one of the triangles using that edge as the axis, done. Make sense?
  • Tom Ellis
    Options
    Offline / Send Message

    The tri geom... make a quad, create an edge from one corner to the other, copy+rotate one of the triangles using that edge as the axis, done. Make sense?

    Aha no wonder I couldn't do it, I was trying to make it one piece of geometry, welded verts and all. I was thinking all along 'I'm sure this isn't even possible'. Now it is clear, and it was so obvious I completely missed it! Thanks Eric.

    Just to be sure, I'm guessing the quad is UV'd before copying and the new tri is overlapped with the existing half quad which is just planar mapped right?

    Yeah sorry about the dead link, here's some examples of the kinda tree I mean. It's so hard to tell what the actual branch/leaf composition is from a distance, yet it's hard to get up close or find a pic online:


    6650-050-E268AC16.jpg

    They kinda look like needles that you'd see on a pine tree, but I don't think they are.

    And here's rexM's amazing example; obviously a large part of making it look good is getting the height right and making dead / bare branches running up the entirety of the trunk. But the actual green textures are hard to make out, and the ones I'm struggling with:

    latestfirs22.jpg
  • Mark Dygert
    Options
    Offline / Send Message
    ^^

    Great for masks

    Never leave the raw image with the black backgroud, always make the background a green colour that blurs with the leaves, otherwise you can get horrible fringing in the mips.
    Just to reinforce what Rick is saying.
    TreePlanesExplained00.jpg
    1. Like Rick pointed out, different colored background can be bad. Even with a alpha much tighter than whats here, you have to worry about mip mapping making a mess of your tight alpha mask and the background begins to bleed into what gets displayed.

    If you have a fuzzy alpha mask that gets alpha tested (pixels are on or off no opacity sorting going on, it can get messy with a fuzzy mask because it will decide which of the gray pixels will be solid or transparent.

    2. Green works pretty well, it works better if you can pad it accurately with actual color that is on the pixel edge, other wise you still get a outline, its just not as hideous.

    3. It can help to add a gradient overlay to help fake the shadowing you get toward the inner part of the tree.

    http://www.polycount.com/forum/showthread.php?t=72325
    Also check out this thread it has all kinds of great info. Eric is particularly helpful with tips and tricks on editing the normals to also help with shading, IF your engine supports that sort of thing.
  • Tom Ellis
    Options
    Offline / Send Message
    Nice one Vig thanks.

    Yeah I've checked out that thread, a lot of awesome tips. Funnily enough it was right under this thread when I bumped this one yesterday.
  • divi
    Options
    Offline / Send Message
    divi polycounter lvl 12
    those are probably firs or spruces.
    unlike pines their twigs and needles tend to hang down.
    2010-06-12_1540.png
    those might be a tad exaggerated, but you'll probably get the idea.
  • Tom Ellis
    Options
    Offline / Send Message
    Cheers Divi.

    Yeah you're right, the leaf pattern does ten to 'droop' rather than protrude upwards I think.

    It's just what the leafs and twigs actually look like close up so I can make a decent diffuse. After further research I've got a bit closer to finding out. I discovered 'Confier' is an umbrella term and looking at the trees within that group turns up some better results. But it's still a bit tricky to see how the branch foliage is made up close.

    Seeing the diffuse of an in game fir/pine close up would probably help but I can't find a good example.
  • Eric Chadwick
    Options
    Offline / Send Message
    Just to be sure, I'm guessing the quad is UV'd before copying and the new tri is overlapped with the existing half quad which is just planar mapped right?
    Yes.

    Also I find it's best to make the branch-planes double-sided in a manual way, by duplicating and flipping the faces, instead of just disabling backface culling. By manually duplicating them, I get vertex normals and UVs that I can tweak. I can kill the rorschach UV effect, and fix the shading.

    One way to see how other games do it is to use a tool like this, to make mesh/texture screencaps. It even has a Max importer.
    http://www.deep-shadows.com/hax/3DRipperDX.htm
  • Tom Ellis
    Options
    Offline / Send Message
    Thanks Eric, that DX grabber thing is pretty awesome. I'm guessing I'm late to the party on that one but it should come in very handy. There's been a lot of moments playing a game when I've thought 'I'd love to see how that was made/textured'.

    Right, back to work!
  • NAIMA
    Options
    Offline / Send Message
    NAIMA polycounter lvl 14
    divi wrote: »
    those are probably firs or spruces.
    unlike pines their twigs and needles tend to hang down.
    2010-06-12_1540.png
    those might be a tad exaggerated, but you'll probably get the idea.

    tought those are side viewed texture panels , why make this instead of making a top viewed panel and then modify tweack the sahape of it , so it looks also like this side view but more 3d , unless I guess you need to have mostly a side view of the tree and very low poly ...
  • hyumanoido
    Options
    Offline / Send Message
    hello polycount users,

    I'm the admin of hyumanoido.de and I've been getting a lot of clicks from this forum (over 650 to date) directing to the once uploaded GTA SA tree pictures I posted but meanwhile deleted.
    I'm not a graphic designer and my website doesn't have anything to do with this topic so I thought I'd provide you with some of the pictures you're vainly looking for on my page.

    311224.jpg 568256.jpg 217618.jpg 915234.jpg

    greetings,
    simon
  • Eric Chadwick
    Options
    Offline / Send Message
    Haha, sorry about stealing your bandwidth, my bad! I think your site is getting hit because we have a link to this thread on our wiki.
  • hyumanoido
    Options
    Offline / Send Message
    it's not very well-frequented anyways, so it's no problem^^
    just thought I'd let you know!
  • ZeroCartin
    Options
    Offline / Send Message
    ZeroCartin polycounter lvl 16
    I just realized what an amazing thread this is. Good to know lots of stuff here :)
  • Eric Chadwick
  • Chase
    Options
    Offline / Send Message
    Chase polycounter lvl 9
    Here ares some variations I was taught that might help....

    1) Find reference, bring it into Max/Maya, lay image on a plane.
    2) Spline out limbs and the trunk based on reference. Then loft the trunk and limbs. Duplicate the splines and edit the depth (Z axis) because they'll be initially flat. Cool thing about lofts is that when you edit the splines it affects the renderable mesh at the same time.
    3) Spline out extra branches that can be baked down as a Diffuse. The vert count doesn't matter here because it'll just be baked down anyways. Only create two, maybe 3 branches, so that the resolution remains high when baked on to the plane. The more branches the more crowded things get right :poly122:
    4) Spline out a leaf to be baked down with the limbs. Make a few copies of these leaves bending them in different directions to produce depth. Place along the pre-baked branches. Hover the branches with leaves over a plane and bake out the Diffuse/Normal Map.
    5)Take Diffuse into PS to create an Alpha. As other posters suggested select a similar color for the background to prevent anti-aliasing, which would give your texture a halo like effect in the engine.
    6) Back into Max/Maya splice branch Diffuse to spread apart the various branches. Disperse the branch planes among the limbs. Can add a few extra cuts to diversify.
    7) You'll remember the limbs at the beginning appear shoved into the trunk instead of growing from the trunk. Simply do some cutting and welding to finesse the naturalistic appeal.



    Another approach I found to be even simpler involves the lofting and the baking trick; however, instead of baking the leaves down to the branches you create a leave canopy....

    1) Take a square, meshsmooth it and delete half of the faces. (Can be any shape really). Grab all the edges and select the Split function. Select all the faces and use the scale tool to stretch out the quads to create a cluster of planes that the leaves can be applied to.
    2) Stretch out canopy to different sizes and delete faces to create variety.
    3) If you're sharing texture space then select all the vertices and select Connect. This splits the quads into triangles.



    Hopefully that added a little to the tree making process :nerd:
  • Eric Chadwick
    Options
    Offline / Send Message
    Do you have any screenshots of the 2nd approach? Sounds like it would be really ugly, unless I'm missing something. What kind of UV do you use for that?
  • renderhjs
    Options
    Offline / Send Message
    renderhjs sublime tool
    thx to the revival on the first page, thought I might share this here

    Recently I have been working on a masking technique in ShoeBox that uses a difference blend based mask and bleeds out the colors on the edges (step by step explanation here). Which is useful for masking images with complex shapes (trees, leaves, branches) but with a solid or even background color.

    Video on how to use it:
    [ame="http://www.youtube.com/watch?v=6C-OR48x2IM"]ShoeBox: Mask flat images - YouTube[/ame]

    example leaves & trees

    7837941808_e83a812556_o.jpg

    7837979010_fee6e4c41e_o.jpg

    7838035210_340f1cdc13_o.jpg

    oh and I am paying for my flickr hosting - so should be fine ;)
  • Steppenwolf
    Options
    Offline / Send Message
    Steppenwolf polycounter lvl 15

    Good stuff! If anyone's interested. I posted a tutorial about tree modeling a while ago. Was my first post on polycount, never got approved by a mod for some reason but it still can be checked out via direct link:

    http://www.polycount.com/forum/showthread.php?p=1384931
  • Olli.
    Options
    Offline / Send Message
    Olli. polycounter lvl 8
    There are some pretty awesome branch textures on CGTextures in Grunge>Gobos
    They're all black/white though, so you'll need to paint some color mush and use the gobo as an alpha.

    would link but CGT is refusing to give a unique URL
  • Chase
    Options
    Offline / Send Message
    Chase polycounter lvl 9
    Do you have any screenshots of the 2nd approach? Sounds like it would be really ugly, unless I'm missing something. What kind of UV do you use for that?


    I know it might sound kinda unorthodox, but here's a visual rundown of what it would look like....

    1. The first canopy shows what the edge split should look like.
    2. The second canopy is what the texture looks like before stretching out the split edges by way of their faces. For some reason you need to add the material to the mesh before stretching out the faces or it won't work.
    3. The third is with the UV's fiddled around with.
    82390139.jpg

    Here are the UV's....

    19493630.jpg
  • Joshua Stubbles
    Options
    Offline / Send Message
    Joshua Stubbles polycounter lvl 19
    Renderhjs, that is fandamntastic! I'll have to play with the alpha padder, that's pretty incredible.
  • Steppenwolf
    Options
    Offline / Send Message
    Steppenwolf polycounter lvl 15
    A method to do something similar directly in PS without any third party filters or programs is to copy the foliage layer, apply gaussian blur, copy the blurred layer a few times then merge and put below your original layer.
  • renderhjs
    Options
    Offline / Send Message
    renderhjs sublime tool
    A method to do something similar directly in PS without any third party filters or programs is to copy the foliage layer, apply gaussian blur, copy the blurred layer a few times then merge and put below your original layer.
    Yes I explained the steps here, you could do something very similar in Photoshop too, except having dynamic variables :(
    http://renderhjs.net/shoebox/maskImage.htm
    1. The clipboard or dropped file is read.
      example_maskImage_step0.jpg
    2. The first upper left pixel at 0,0 is picked and a new layer with a solid fill of that color is added and set to a difference blend mode.
      example_maskImage_step1.jpg
    3. This difference blend is enhanced in a way that the greatest values out of the R,G,B spaces are multiplied with a scalar. This will be used for the final alpha channel.
      example_maskImage_step2.jpg
    4. A new temporary alpha channel with a high threshold (only full opaque pixels) is generated and applied on the input bitmap.
      example_maskImage_step3.jpg
    5. This temporary masked result padded with bleeding border colors (bad photoshop example here).
      example_maskImage_step4.jpg
    6. The final composite is a result of the temporary color bleend and the difference mask from the first steps.
      example_maskImage_step5.jpg
Sign In or Register to comment.