Home Technical Talk

Correct vertex normals for foliage?

polycounter lvl 9
Offline / Send Message
CarlCraft polycounter lvl 9
I'm working on some foliage (maya 2014), mainly bushes and trees, and I've tried several methods but the way the light just seems random.
What I'm looking for is the results showed in the polywiki:
VertexNormal?action=AttachFile&do=get&target=TreeMakerScript_plus_NormalThiefScript.gif

Although I'm closer to the example to the left.

I've tried setting up each branch with individual vertex normal, that follow a couple of tutorials, one shown here:
14.jpg

So this is how one of my branches looks like, and the results when clumped together to form a tepmorary bush:
vKKIcTP.png
Doesn't seem so smooth.
Here it is in UDK, which I intend to use the foliage in:
oIPCxDw.png

I also tried using a sphere to transfer it's attributes as some other people have mentioned:
m3N4TUO.png

But, yeah, it looks even worse (ignore the sphere).
1fIZoL8.jpg

What am I doing wrong? How do I get the same result shown in the first example?
Thanks

Replies

  • BARDLER
    Offline / Send Message
    BARDLER polycounter lvl 12
    Check your vertex normals in UDK. I had a recent issue where either UDK wasn't importing my vertex normals but never found the problem. I think it was an FBX export problem, but I couldn't be sure.
  • CarlCraft
    Offline / Send Message
    CarlCraft polycounter lvl 9
    I have tried many export/import settings, and made sure that the vertex normals actually change when exporting/importing. The problem (I believe) is how the vertex normals are actually set up, as it doesn't even look correct in Maya.
  • fatihG_
    Offline / Send Message
    fatihG_ polycounter lvl 14
    Yeah, make sure to unlock your normals and try again. also try to have the sphere be about the same size as the bush.

    I dont really remember very well but I think in the past I had it not working so well because the scale of the sphere I used as a base was too small.
  • Santewi
    You might have to go to "import" instead of just right clicking the mesh and selecting reimport.

    Also, when importing, make sure you choose to read the normals from the FBX. Otherwise UDK will just automatically generate them.
  • CarlCraft
    Offline / Send Message
    CarlCraft polycounter lvl 9
    Alright, tried your suggestions. Unlocked normals, made a bigger sphere more fitted for the bush. Also imported is as it's own mesh. Also with Import Tangents and Explicit Normals options on. I'm not getting much better results:
    jNcbFod.png

    This is my setup:
    3wHaPWx.png

    I realised a brighter specular would better define where the light hits, but it won't solve my initial problem. Is it the way my branches are set up (seen in my first post, 3rd picture)?
  • Chai
    Offline / Send Message
    Chai polycounter lvl 17
    I'm working on similar thing, following the same tut but using Unity
    Getting problems but tbh I didn't even know it's supposed to use a sphere ref hah .. that tutorial is really sketchy I'll give it another go, thanks for the thread

    Edit: thanks again, I got it working thanks to your sphere image !
    I didn't even fit the sphere to the shape of the tree, so I don't think that's the issue ..
    So your normals look fine to me, I guess the problem is somewhere in the UDK import as others pointed out, sometimes the engine split normals on import (e.g. uv borders, etc), or maybe the tangents get screwed up, sorry my knowledge with UDK is really limited ..
  • Eric Chadwick
    I made that rotating gif.

    How are you making the backfaces? I had to explicitly duplicate and flip the faces (in Max), then edit the normals, then make sure to prevent the game from creating any backfaces, and use a single-sided shader too.

    Also it could be the shape of your leaf planes to blame. Is it simply 3 quads intersecting? It almost looks like a tetrahedron, but it's hard to tell.
  • CarlCraft
    Offline / Send Message
    CarlCraft polycounter lvl 9
    The backfaces are rendered in UDK, the material is basically two-sided. I'm guessing the generated backfaces are the ones to blame for the incorrect lighting?
    The branches are not tetrahedrons, not sure what to call them
    GwdJc8u.png

    I'll try making the backfaces in maya, see if that will fix it.
    Was actually about to message you, seeing as you made the tutorial! Thanks.
  • Eric Chadwick
    If you let the game engine create the backfaces, this will reset your vertex normals. Because then it is generating new polygons, and so it has to figure out where the new normals will point. To import edited normals, you must prevent this, and explicitly precreate those faces yourself.

    Your mesh may cause problems because you have a vertex directly in the middle there, which will make it very difficult to get good shading... i.e. which direction would those middle normals go? You could get a similar look if you made it into 3 quads. I'll make a pic.
  • Eric Chadwick
  • CarlCraft
    Offline / Send Message
    CarlCraft polycounter lvl 9
    The mesh is already set up that way, unless I'm mistunderstanding it
    S18r7Pu.png
  • CarlCraft
    Offline / Send Message
    CarlCraft polycounter lvl 9
    Alright, got it working.

    So I basically did what Eric told me. Extrude each face on the branch, then merge the vertices together again (creating 2 faces).
    I then stretched a half sphere to cover up the entire tree
    Sg6wwQQ.png

    Selecting the sphere then tree, I went Mesh>Transfer Attributes and made sure only Vertex Normals were being transferred. The trees vertex normals then looked like this:
    JHa6v19.png

    I then turned off Two-sided on the branches material. And this left me with this pleasurable result:
    ZtUJDfn.png
    Compare it to what I started with and it's 10x times better.
    Now I just need proper textures.

    Thanks a lot, everyone!
  • monster
    Offline / Send Message
    monster polycounter
    How are you making the backfaces? I had to explicitly duplicate and flip the faces (in Max), then edit the normals, then make sure to prevent the game from creating any backfaces, and use a single-sided shader too.

    Can we get that info in the WIKI? I remember about a year ago, I went through this process. I eventually figured out what you said, but it wasn't easy. :)
  • Eric Chadwick
    callebo, can I use your pics in the wiki? I'd like to add a section for Maya.

    monster, yes!
  • Chai
    Offline / Send Message
    Chai polycounter lvl 17
    Very cool thanks for the images

    I'm writing an automatic bent normals generator for my modo exporter
    I'm confused, so you're not putting the sphere in the middle of the tree, but rather half a sphere from origin ? I'll try both methods and check results
  • Bek
    Offline / Send Message
    Bek interpolator
    Chai wrote: »
    I'm writing an automatic bent normals generator for my modo exporter
    <3

    With the sphere/half-sphere thing, I imagine it would only make a significant difference if the trees were viewed from a low angle (In which case you'd want to have used the full sphere)? Just a guess from this thread, haven't played around with this stuff myself yet.
  • Chai
    Offline / Send Message
    Chai polycounter lvl 17
    Ok ye I see it now, I must have had lucky miscalculation yesterday ;)
    Should look good with baked vertexcolor gradient

    q_bentnormals.jpg
  • CarlCraft
    Offline / Send Message
    CarlCraft polycounter lvl 9
    callebo, can I use your pics in the wiki? I'd like to add a section for Maya.

    monster, yes!


    Ofcourse! Would be an honor!
  • Eric Chadwick
    dustinbrown... SlideNormalThief is much faster. http://wiki.polycount.com/VertexNormal#Slide_Normal_Thief_MAXScript

    callebo... done. http://wiki.polycount.com/VertexNormal#Editing_Normals_in_Maya

    Chai... that's awesome! OK to add this to the wiki as well?
  • Chai
    Offline / Send Message
    Chai polycounter lvl 17
    Chai... that's awesome! OK to add this to the wiki as well?

    Sure thing, and btw thanks for the original article mate !
  • Eric Chadwick
  • Chai
    Offline / Send Message
    Chai polycounter lvl 17

    Cool, cheers mate
    For any modo users reading this, just released new version of pipelineIO with the bent normals support :)
  • Nightstalker
    Looks kinda odd, you will have to add some other texture maps i think.
  • Add3r
    Offline / Send Message
    Add3r polycounter lvl 11
    Holy necro post batman. Though there is some solid info to be found within this thread.
  • Eric Chadwick
    I sent a private message to Nightstalker. This info might be useful to others, so here:
    I see you're new here. Welcome!

    Unfortunately you posted in an old thread, and posted feedback on art that was done more than six months ago. This is generally not a good thing, because the author is probably not working on it any more.

    Posting a small amount of text in an old thread is discouraged on this forum, because it is seen as a waste of time to others who are subscribed to the thread.

    I hope this makes sense. Please let me know if you have any questions.

    Also, the wiki has moved since this thread was written. The relevant pages are now here:
    http://wiki.polycount.com/wiki/VertexNormal
    http://wiki.polycount.com/wiki/Foliage
  • GlowingPotato
    Offline / Send Message
    GlowingPotato polycounter lvl 10
    So, if the camera is positioned below the tree, everything will become dark.

    How to proceed for first person camera ? Move the botton verxtices normals so it will point to the ground ? but then, looking from a distance, the botton of the tree will look dark. Right ?
  • Eric Chadwick
    Not true, in my experience. If you use a dome, the vertex normals for the foliage in the middle of the bottom will be pointing up, but the bottom sides will be pointing at an angle, so they still get lit.

    Also depends a lot on your lighting setup. If the game uses a single top-down directional, you'll want some sort of ambient light to prevent black backsides. It's best to get a directional ambient if available, so it's not just flat ambient brightness, which looks.... flat.
  • GlowingPotato
    Offline / Send Message
    GlowingPotato polycounter lvl 10
    Directional ambient light ? This is new to me... google it but i just found a light rig made by two opposite directional lights...is this right ?
  • Eric Chadwick
    Lots of ways to do this. You basically want to simulate bounce lighting.

    Here's an inexpensive method we used for a MMO. In the shader we reused the incoming directional light, just flipping the direction, and adding a color control.
    mmo_lighting_backside.jpg

    So the main light is colored a very light orange, the backlight is colored dark tan, and the ambient is dark blue.

    Ambient comes from everywhere, so it tints everything the same. It simulates light coming from all over the sky, hence the blue color. But flat ambient is very horrible looking on its own, because there is no directionality, so it should be used sparingly if at all.
  • Eric Chadwick
    Problem with this approach is the backlight color is static. We chose a color that's closest to the average ground color in an area. So if there's a lot of rock you use tan, if a lot of grass you use green. Then we made different settings for different areas in the game, and transition from one to the next as your character walks across the boundary. That means you need to paint a bunch of different lighting regions to make it more accurate.

    A better way, but a bit more expensive, is to use Spherical Harmonic lighting. Unity uses this with the light probe system (I think it's SH, they don't say exactly).
    http://docs.unity3d.com/Manual/LightProbes.html
  • GlowingPotato
    Offline / Send Message
    GlowingPotato polycounter lvl 10
    That's really cool Eric, thanks for sharing. I definitely gonna pass this to our programmer so we can try it out. Right now our lightning approach is one directional and one ambient light. And since we are building a dynamic day/night system, your approach should look better than our current.
  • Eric Chadwick
    That setup works great for dynamic objects. But for static ones you probably want something a bit more robust, or else your buildings/etc. start to look overlit.

    Light probes (for your dynamic models) and pre-computed GI (for your static ones) work pretty well, check out Unity 5's GI system. Real nice, and supports dynamic lighting changes... sunrise to sunset, etc.
    http://blogs.unity3d.com/2014/09/18/global-illumination-in-unity-5/
Sign In or Register to comment.