Terrain Trees with ASE

Node-based Shader Editor

Terrain Trees with ASE

Postby Nemo » Sun Jan 06, 2019 11:17 pm

Hi!

I'm trying to set up a bark/leaf tree shader that is usable by Unity's Terrain Trees system. I'm doing a stylized look, so the standard Unity shader won't cut it for me.

I jumped over to here from Shader Forge partly because of the new Terrain splat setup, which is working nicely, and I'm also finding lots of other great features! However, I'm still having trouble finding any information for setting up Terrain-viable tree shaders. Am I barking up the wrong tree? (Sorry for the terrible pun.)

Hopefully I'm just failing at searching and somebody with experience can point me in the right direction. Thanks!
Attachments
ShaderScreen.jpg
Non-terrain placement showing my current shader
ShaderScreen.jpg (215.78 KiB) Viewed 4286 times
Nemo
 
Posts: 5
Joined: Sun Jan 06, 2019 11:05 pm

Re: Terrain Trees with ASE

Postby Amplify_Borba » Wed Jan 09, 2019 11:40 am

Hello, thank you for getting in touch and for your support!

There's two ways to achieve this, you can override Unity's tree shader taking similar steps to those described in the following post regarding overriding Unity's grass - https://forum.unity.com/threads/best-to ... st-3522941, or you can do it through the same method that we used in our SimpleTerrain sample, upon which I'll elaborate further.

Inside the SimpleTerrain sample, you can unpack the 'ApplyGrassWindToTerrain.unitypackage' to replace the SimpleTerrain asset with an alternate version that contains custom shaded grass set up as a tree prefab, so that it can use a material with a custom ASE shader.

Image

We've added the grass for this sample as a tree prefab since the alternative would be to override the grass shader, which we don't recommend due to the lack of flexibility and also since, in our case, it could override users' custom grass.

Please let me know if this helps!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Terrain Trees with ASE

Postby Nemo » Thu Jan 10, 2019 4:07 am

Thanks!

I will now abuse your helpfulness with more issues! (Sorry) I should start with what will be obvious momentarily: I'm coming at this from the art side, and don't have a lot of code experience.

Looking in my SimpleTerrainSample folder, I don't see a new Unity package. I did a search in the project and didn't find it either. Am I misunderstanding how to find it?

So I tried the link! Trying to find the right name seems pretty fraight (Why are they hidden? What's up, Unity?) I found different references to the formatting https://answers.unity.com/questions/784987/using-custom-tree-shaders.html, https://answers.unity.com/questions/559 ... aders.html, and that in your own link.

I tried them all. Just changing the name seems to have triggered an odd result, making all my trees into ghosts. After another name change I got the pink mesh failure, and changing back doesn't get either ghosts or regular shaders back. I'm broken pink from now on. In the process, this error has appeared in the shader console:

Shader error in 'Hidden/Nature/TreeCreatorLeavesFastOptimized': 'vertexDataFunc': output parameter 'v' not completely initialized at line 92 (on d3d11)

Compiling Domain program with UNITY_PASS_FORWARDBASE DIRECTIONAL SHADOWS_SCREEN LIGHTPROBE_SH INSTANCING_ON
Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR


Also, checking out your grass shader from that post, it does worry me that it seems to need further knowledge of how the hidden shader is set up. Between that, the weird way Unity seems to hide all of this, and the fact that people seem to generally be unimpressed with Unity's Terrain tree system, I'm looking into alternatives, like Vegetation Studio. Is there a common "use ASE shaders on efficiently instanced foliage objects" process yet, Terrain or otherwise?

Thanks for your help!
Attachments
TreeShaderGhosts.JPG
TreeShaderGhosts.JPG (153.18 KiB) Viewed 4268 times
Nemo
 
Posts: 5
Joined: Sun Jan 06, 2019 11:05 pm

Re: Terrain Trees with ASE

Postby Amplify_Borba » Thu Jan 10, 2019 12:42 pm

No problem, I'm here to help!

You might be using an outdated version, please make sure that you get the latest build from our website.

Image

Regarding the issue you're having, I'd have to take a look at a sample in order to be able to provide more information.

I'm afraid that the ways I've shared in my previous reply are the only ones currently available, perhaps in the future with Unity's improved terrain system we might be able to streamline this process and make it more user-friendly.

Vegetation Studio has a specific node for ASE, and should work pretty well, although I haven't used it myself. I'd recommend reaching out the developer regarding any possible intricacies since he's pretty active and helpful, and will likely be able to provide better insight than I could.

Please let me know if you have any further questions, thanks!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Terrain Trees with ASE

Postby Nemo » Thu Jan 10, 2019 6:07 pm

Thanks!

The direct download did contain the files. (In my search yesterday I'd re-imported from Unity and it didn't have them. Maybe there's a delay going through them?)

From that example I've been able to Frankenstein together a version of my shader that works with the wind!

It has two remaining oddities I haven't been able to sort out:

1) Every single change to the shader (even benign ones, like making a comment) pinks the material in Unity. If I restart Unity the material displays correctly again, so that's good, but this is not an _ideal_ iteration process :)

2) Every overlap within a mesh is additive. I've attached an image.


On the alternative track, I asked the Vegetation Studio developer what the shader requirements were, and he said it just needs to support instancing. Someone else chimed in to say that deferred lighting is preferable too. But if the requirements are that loose, then maybe I'll head that way. Looking into it now, anyway!

Thanks!
Attachments
TreeShaderAdd.jpg
Note the additive overlap where a given tree's branches cross each other, or join with the trunk. These trees are single merged meshes.
TreeShaderAdd.jpg (223.19 KiB) Viewed 4262 times
Last edited by Nemo on Thu Jan 10, 2019 7:28 pm, edited 1 time in total.
Nemo
 
Posts: 5
Joined: Sun Jan 06, 2019 11:05 pm

Re: Terrain Trees with ASE

Postby Nemo » Thu Jan 10, 2019 6:28 pm

Attached the shader file
Attachments
TreeLeaves.zip
(5.97 KiB) Downloaded 329 times
Nemo
 
Posts: 5
Joined: Sun Jan 06, 2019 11:05 pm

Re: Terrain Trees with ASE

Postby Amplify_Borba » Fri Jan 11, 2019 3:05 pm

Thank you for sharing additional information, could you please send us a simple project with the issue present, so that we can debug it on our side using the same data and assets?

You may share it privately through [email protected].
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Terrain Trees with ASE

Postby Nemo » Tue Jan 15, 2019 3:53 pm

For anyone following this thread, my eventual solution has been to use Vegetation Studio, rather than Unity Terrain Trees.

VS plays reasonably well with the original ASE shader I made, right out of the box, and the remaining bits I'm sorting out now.

For anyone else going down this path, the specific requirements so far are:

    - VS requires your material to enable GPU instancing (a checkbox in the material's inspector)
    - VS works best with (though does not require) deferred rendering
    - VS expects the main diffuse to be called "_MainTex" and your opacity cutoff to be called "_Cutoff". Otherwise, its automatic billboard renderer won't recognize your opacity values.

The last bits I'm in the middle of sorting out are:

    - My shader handles multiple lights fine when an object is placed manually, but when the object is placed by VS, it only uses the first light. This isn't a VS issue, it's something about my shader that doesn't process multiple lights when run through GPU instancing.
    - My custom shader (and my custom trees) need to be set up to support Wind Zones. This may be straightforward, I just haven't attacked it yet, and am only including it as the last step in the "get custom trees and shader to work like default trees and default shader" plan.

Throughout all of this, both the ASE staff and the VS developer have been great at helping me sort out the handoff between the two systems, despite me being totally new to both :)
Attachments
ASE_VS.png
ASE_VS.png (198.65 KiB) Viewed 4233 times
Nemo
 
Posts: 5
Joined: Sun Jan 06, 2019 11:05 pm


Return to Amplify Shader Editor

Who is online

Users browsing this forum: Bing [Bot] and 7 guests