Search Unity

[Released!] Custom tree importer

Discussion in 'Assets and Asset Store' started by larsbertram1, Aug 19, 2014.

  1. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    200
    I just found the VSPro_CTIShaderControler and updated it. However, the error is still there.
     
  2. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    200
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    the original package does not error at all.
     
  4. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    200
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i can't see the image. you can upload it right in the forum...
     
  6. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    200
  7. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    200
    Problem is also, when I enable "Fade out Translucency" (red), I can't use the sliders (blue) anymore. The tree becomes very dark from activating "Fade out Translucency". I don't think this is intentional.

    Error3.jpg
     
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    regarding the "error": it is a warning and fully intentional.
     
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    this feature needs some input from script.
    but actually it is dropped...
     
  10. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    200
    And the "error" with the controllers, is there anything that can be done?

    I need the function "Fade out Translucency", because I use Enviro. During the day the trees look fine, but in the evening the trees start to "glow". "Fade out Translucency" prevents this.
     
  11. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    200
    So it is "normal" that the controllers do not work?
     
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    Fade out Translucency Lets you fade out translucency over distance as trees beyond the real time shadow distance tend to look a bit weird. If checked the leaf shader expects some global shader variables to be set as fade distance and fade range. You may set these manually from any script or use the provided CTI.CTI_Utils.SetTranslucentLightingFade function to so. Have a look at the LOD Group Demo to find out more.
     
  13. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    200
    I read the documentary.

    Once again from the beginning. I can't use the sliders when I use "Fade out Translucency". The nearby trees become almost black.
     
  14. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    200
    You can see it well in the picture here. The function makes the trees much darker, especially trees in the middle of the picture get unnaturally dark spots.

    Tree.jpg
     
  15. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    please have a look into the "LOD Group Demo".
    there you will find the "_SetShadowDistance" object and script which drives the fading of the translucency.
    enabling "fade out translucency" here on the jatoba leaf material does not darken the leaves on nearby trees as the script sets the fade dist to 300. if you lower it to e.g. 100 you will actually see how translucency fades out.
     
    Last edited: Oct 24, 2021
  16. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    Hello @larsbertram1. Is it possible to crossfade the materials to full transparency? Since there is already a form of LOD dither crossfading, would it be possible to expose this so that I could modify it through script? It would be incredibly helpful, for example making a tree partially transparent to see something behind it. Thanks.
     
  17. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    it should be rather easy to add this when it comes to the leaves as they already use alpha testing.
    when it comes to the bark you should add a multicompile so alpha testing (needed for the fading/stippling) will only be enabled on currently fading trees as otherwise you loose early depth testing which will slow rendering down. latter however would only work with trees added as game objects as you can't assign a special material to just one terrain tree afaik. swapping out prefabs might work here but i am not sure how costly it would be to find the correct tree in the terraindata.
    working with lod groups on the terrain should make it a bit more simple as you could add alpha testing only to your lod0.
    driving the fade by script when using the terrain engine sounds cumbersome. i would rely on distance to camera here.
     
  18. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    I've created a custom vegetation system that already swaps out gameobjects when the player is close enough (not using terrains at all), was much easier to handle climbing, cutting, etc, and I'm already managing custom scripts on these objects. I had considered swapping to another shader when transparency is required but obviously it'd look bad and not enjoy all the niceties of CTI. Sadly I'm only a C# programmer so modifying CTI's shaders are a bit beyond me... my shader work is relegated to shadergraph.
     
  19. kgarland

    kgarland

    Joined:
    Jul 21, 2015
    Posts:
    3
    I am getting a bark shader error when I import into my project. The bark is red and black. I am using the default render pipeline, nothing special! I have pasted the error below!

    upload_2021-11-23_11-30-8.png
     
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hmm, the error is not connected to any shader - but has something to do with the ui?
    except from the create billboard thing cti pretty much has no ui.
    but still: the bark shader seem not to be loaded properly.
    so you may select it in the project tab. then in the inspector you should get all errors and warning listed.
     
  21. kgarland

    kgarland

    Joined:
    Jul 21, 2015
    Posts:
    3
    Okay, yeah that brings up the error messages!
    upload_2021-11-23_14-6-49.png upload_2021-11-23_14-6-8.png Unfortunately I do not know how to fix these issues
     

    Attached Files:

  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    the files should be right in place - unless you have moved them around :)
    but usually it is just a common unity problem were serializations goes wrong.
    select the shader in the project tab. then right mouse clic -> reimport. this usually fixes it.
     
  23. kgarland

    kgarland

    Joined:
    Jul 21, 2015
    Posts:
    3
    Wow! That completely worked/ Thank you so much!!!!!!!!!!!!!!!
     
  24. DarkLiKally

    DarkLiKally

    Joined:
    Aug 31, 2013
    Posts:
    7
    Hello,

    I've posted a little issue I have with CTI billboard shaders on the Rocky Hills Environment thread - the author there suggested to ask here for help.
    https://forum.unity.com/threads/roc...evelopment-thread.381438/page-13#post-7775214

    When a tree goes into the Billboard mode - it's becoming just a grey silhouette:



    I applied the shader fixes that the author of the mountain env package provided on his asset store page / thread. I tried both versions he provided for unity 2020 versions as he suggested but I always get this errors when the shader tries to compile:



    I'm Using Unity 2021.2.7f with HDRP 12.1.2. All other HDRP related stuff is working fine in my project.

    Do you have an idea whats wrong or on how I could fix those issues? Is there an official CTI version for HDRP 12.1 available somewhere for testing?
     
  25. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    attached you will find a package for HDRP 12. just let me know how it works for you.
     

    Attached Files:

  26. DarkLiKally

    DarkLiKally

    Joined:
    Aug 31, 2013
    Posts:
    7
    I installed the new shader versions and switched my materials to them - no other changes.
    It seems like the alpha cutoff is not working anymore:
    upload_2022-1-6_21-31-22.png

    Similar thing for Billboards:
    upload_2022-1-6_21-32-0.png

    I tried opening the shader graphs and re-saving / compiling them - but didn't help. Don't know what's wrong really since you also just pipe the alpha cutoff through.
    Or maybe the assets of that pack do not work now with that variant - because before it was using the HLSL versions.
     
  27. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    Hi Lars, apologies but I've been having trouble figuring out how to adjust alpha in the shader code. Is there anywhere specific I should be looking? Shader code is a bit greek to me and so far I've been just tinkering with values to see if anything works.

    The closest i've gotten is to modify the outSurfaceData.alpha in the Inputs.hlsl/InitializeLeavesLitSurfaceData & InitializeStandardLitSurfaceData methods, but it's not quite right. This is for URP btw.
     
    Last edited: Jan 6, 2022
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    that should not make any difference. maybe you have run into a shortcomming of the shader graph inspector.so try to toggle on and of and on "alpha clipping" :)
     
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    right out of my head this should be the right place...
     
    Noogy likes this.
  30. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    just found the time to look into the shader code for URP 12. in InitializeLeavesLitSurfaceData() you will find these 2 lines of code:

    half4 albedoAlpha = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap));
    outSurfaceData.alpha = Alpha(albedoAlpha.a, 1, _Cutoff);

    in the first line the shader samples the combined albedo/alpha texture using a URP define macro "SampleAlbedoAlpha".
    alpha then will be stored in albedoAlpha.a or the 4th component of the half4.
    next line uses another URP macro: Alpha(albedoAlpha.a, 1, _Cutoff);
    the function "Alpha" here performs alpha testing based on albedoAlpha.a, 1 (which could also be a color.rgba value which would be multiplied on top of the alpha and the _Cutoff value.
    in order to tweak the alpha and influence the way alpha testing works you have to tweak it BEFORE Alpha() gets called like:

    half4 albedoAlpha = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap));
    albedoAlpha.a = pow(albedoAlpha.a, 1.75h); // do something here. silly example tho...
    outSurfaceData.alpha = Alpha(albedoAlpha.a, 1, _Cutoff);
     
    Noogy likes this.
  31. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    Thanks for looking into it, happy to know I was at least in the right method. Right now I'm trying to do something as simple as:

    albedoAlpha.a *= _Alpha

    With _Alpha being a half that I added and accessed from script. The result seems to be a slight adjustment to what would normally be the _Cutoff, and then the material goes nearly full translucent, invisible but still affecting the depth and fog in the scene. So there's really no transition in the alpha, more a binary on and off. I'm guessing that changing the CTI URP Leaves.shader tags wouldn't make a difference? IE Rendertype=Transparent or anything?
     
  32. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    not really sure if i understand you.
    but tweaking the InitializeLeavesLitSurfaceData() function will only affect the forward and deferred passes.
    depth and shadow passes do not use this function but do alpha testing right within their fragment shader defs like "DepthOnlyFragment" in the depth only pass.
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    having a closer look at your screen shots: the leave shader expects albedo (rgb) puls alpha (r). so alpha ist stored in its own texture and does not come from the alpha channel of the albedo texture.
    as the shaders are made with shader graph you should be able tosimple rewire them and plug the alpha from the albedo sample into the alpha out put node.
    sorry about the confusion.
     
  34. DarkLiKally

    DarkLiKally

    Joined:
    Aug 31, 2013
    Posts:
    7
    Aaah I see! thanks for the second look :) The old shader was taking it from the albedo map aswell. I'll adjust the shader graph, thanks a lot.
     
    florianalexandru05 likes this.
  35. DeadPoet

    DeadPoet

    Joined:
    Jan 7, 2013
    Posts:
    37
    Hey, Unity 2020.3.18f user here. Until a few days ago I had no problems with the shader, but after an update of my Rocky Hills Enviroment (which uses your Tree Importer) i suddenly get a few error messages, which I can't get rid off by any means that I try. Maybe you can help out:

    upload_2022-2-24_9-34-3.png
     
  36. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,811
    Hello, I think I can reply to this, you have two wind scripts in your project, delete one of the CTI runtime components with the extra wind script. Since you are using 2020.3, you should follow the video tutorial or read the description instructions carefully.


    Unfortunately, I didn't get to update 2020.x up with the right conversion fixes yet but if you download it with (Unity 2021.2.3f1 SRP 12) or above these issues have been resolved. Let me know if that helped!

    You can do a quick search of the "CTI wind" in your project and check if there are duplicates.

    Edit: I UPDATED the pack and you just have to re-download, no more need to apply fixes. :)
     
    Last edited: Apr 14, 2022
  37. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    Hello @larsbertram1, I've upgraded to the latest version of CTI. I know previously I had asked for SSAO support but I had since developed a more stylized look and preferred my trees without SSAO. The previous versions of CTI worked fine but now I'm having trouble disabling SSAO. Could this possibly be added as a toggle in the bark and leaf shaders?

    SSAO also doesn't really play nice with the crossfade effect, it makes it pretty noticeable.

    I'm using URP SSAO source 'Depth' instead of 'Depth Normals' if that matters, thanks.
     
    Last edited: Mar 23, 2022
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    if you are using forward just disable the ssao keyword.
     
    Baldinoboy and Noogy like this.
  39. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    Fantastic, thank you.
     
  40. VenesArt

    VenesArt

    Joined:
    Sep 7, 2020
    Posts:
    5
    Hey! I just switched to Unity 2021.2.15f1 using URP project (URP version 12.1.5), but CTI shaders (CTI/URP LOD Bark and CTI/URP LOD Leaves) appears in "failed to compile" section, and they don't work. Is there any update or fix for them?
     
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    try the attached package. it should extract as shown below. to make sure everything works and updates as expected you may want to delete the old urp folders first.

    extraction.PNG
     

    Attached Files:

  42. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    200
    Hi!

    I use Vegetation Studio Pro and the CTI. With VS Pro I have created billboards. Problem is that from the last LOD to the billboard is a hard transition. The trees suddenly disappear and the billboard appears. Actually I thought CTI uses LOD crossfading. Is it possible to create a smoother transition between the last LOD and the billboards?
     
  43. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    it supports unity's cross fading. but it should work with vs as well: last time i checked it did.
     
  44. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    200
    Hi!

    I use the shader for URP version 10 with CTI and the trees with Vegetation Studio Pro. I have added / changed the following lines to the Leav and Bark Shader to support instance indirect.

    #pragma instancing_options assumeuniformscaling maxcount:50 procedural:setupVSPro
    #pragma multi_compile GPU_FRUSTUM_ON __
    #include "VSPro_HDIndirect.cginc"

    Unfortunately this does not work. Can you help me further?
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    this one does not look right?
    and what does not work? what is broken?
     
  46. swredcam

    swredcam

    Joined:
    Apr 16, 2017
    Posts:
    130
    Is there any easy way to use CTI trees in a Blender animation? I'm working on a Blender project and I have a ton of BLEND trees created for use by CTI in Unity. I would love to be able to use them in the native Blender project and get wind motion of some sort. Otherwise I will probably just do some basic hand-generated animation of the branches here and there.
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    that is nothing i am familiar with.
     
  48. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    I do not see this being possible. Would be really cool to be able to do though. The effect in Unity is being driven by the shaders and for now I do not think there is a way to record the effect and transfer to a time Blender timeline animation.
     
  49. JcAquila

    JcAquila

    Joined:
    Dec 19, 2019
    Posts:
    5
    Hi!

    I'm trying to implement wind shaders by creating the materials for the bark and leaves using the CTI SG Bark HDRP and CT SG Leaves HDRP Shaders.

    The materials seem to act normal when the windzone doesn't work (as seen in the Screenshot below (My Tree is the Right-most Tree)).
    upload_2022-8-4_11-38-12.png

    When the prefab trees seem to work (aka, move with the wind), the materials of my tree seem to glitch (as seen in the below screenshot).
    upload_2022-8-4_11-41-53.png

    Is there something I'm missing?
     
  50. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hmm, i do not really get this. either they bend properly in the wind or they do not. looks like they do not so your setup might be wrong.