Friday, April 25, 2014

Debugging ONYX Leaf Shaders



So there was something off that I noticed when I was rendering my trees for my Spirited Away tunnel scene... the leaves were either rendering as cards or just looked plain weird.


The error was hard to notice sometimes as leaves in shadow looked okay, as you see here.


But now, see how the leaves that are being directly illuminated look strange?
At first I thought the cutout opacity wasn't working or maybe that it had something to do with the specular maps, but tweaking and changing those didn't change anything.


Zooming in you can see just how bad it is. What the heck is happening?!

After about 20 minutes or so of trial and error changing around nodes in my leaf shader and lots of keyboard banging, I stripped my scene and just put the trees I was instancing side by side and rendered them one at a time. The first tree had the same strange shader error, but the second one didn't. What the? But then I realized that those two trees had different leaf types!



The leaves on the left look bad, but on the right look good. I realized it was because of the way the leaves were split up from ONYX. Notice how the left is just a single square triangulated, while the right is 4 squares triangulated. So there in lies the problem and the solution.

SOLUTION:


In ONYX, when you export the tree as OBJ click Plates to edit the leaves. 


This was the default way I exported the leaves, with a resolution of 0 to save on the polycount. Note that with it set to 0, the count is a comfy 88k polys. (Also note that you should change p-objects to 1 so the UVs aren't all wacky)


Change the resolution to 1. This REALLY ups the polycount to 244k, but honestly not that bad for instanced trees that have correct leaf shading. 

Now to go back to ONYX and re-export all my trees with correct leaves... Hope this helps someone else!

No comments:

Post a Comment