Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[Released!] Custom tree importer

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

  1. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    80
    Hello @larsbertram1, have you had a chance to look at this? CTI shaders still exhibit odd blocky banding between shadowcascades in URP. Thanks.
     
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,867
    i just uploaded a new version.
     
    Noogy likes this.
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,867
    the update is available.
     
    Noogy likes this.
  4. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    80
    Wonderful, that did the trick, it's working perfectly! I really appreciate you looking into this, thanks.
     
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,867
    fine!
     
  6. Low_on_Mana

    Low_on_Mana

    Joined:
    Jun 18, 2018
    Posts:
    31
    I've been experiencing the same issues as @Noogy was with Veg Studio pro. I've tried updating the shaders with the 2018_CTI_LOD leaves fix and the VSPro_CTI shader controller but nothing seems to have helped.

    Specifically my issues exhibit as:
    *Trees in question are spawning at the camera if set to instanced/Instanced Indirect
    *Prefab placed in environment seems to work fine if GPU instancing is turned off otherwise there will be weird issues with rendering the movement unless the render queue is set to something like 3000 and even then they don't move.

    Environment:
    Built In Render Pipeline
    Gaia Pro
    Enviro
    R.A.M. 2019
    Vegetation Studio Pro
     
  7. Low_on_Mana

    Low_on_Mana

    Joined:
    Jun 18, 2018
    Posts:
    31
    Please, @larsbertram1, any help would be greatly appreciated
     
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,867
    i am not an vspro expert. but i just grabbed latest vspro and cti from the asset store.
    i opened the vspro demo scene and added cti's included "Jatoba LOD Group for Terrain". WHich just works nice using "InstancedIndirect".
    So i guess you should make sure you have the lastest versions as well.
    (i tested it in unity 2019.3.9f1 on win 10).
     
  9. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    80
    Hello @larsbertram1, is there an option for fresnel in CTI? I'm going for a slightly stylized look and additional fresnel or rim lighting would go a long way. Thanks.
     
  10. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,867
    nothing built in.
    and of course it depens on which pieline you use: forward, deferred, urp, hdrp.
    urp and forward should allow you to tweak the lighting function accordingly.
    deferred and hdrp do not. here you could either tweak the albedo or emissive.
     
  11. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    80
    I'm using URP with the forward renderer, though I may change if deferred matures. Tweak the lighting function, do you mean through the SRP? I was attempting to add fresnel to the CTI shaders but sadly my shader knowledge is very poor, I'm strictly a C# programmer.
     
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,867
    URP and forward should be rather easy :) just hack it into the lighting function
     
  13. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    80
    Thanks for the confidence :) I've been attempting to hack in this version of fresnel but not having much luck: https://www.ronja-tutorials.com/2018/05/26/fresnel.html

    I'd like to include the normal in the fresnel effect, this is how I have it set up in shadergraph (screenshot) but not having much luck in code:
     

    Attached Files:

  14. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,398
    Hi @larsbertram1,

    Was messaging you on this issue but did not hear back on the latest question. An issue someone had with CTI in VR-

    unnamed.png

    They also messaged-
    By the way, if I set VR to Stereo mode "Single Pass Instanced", I can
    compile without any problem. It happens only in the mode "Single Pass".

    In our messaging you messaged to swap out code with

    #ifdef UNITY_SINGLE_PASS_STEREO
    o.texcoord = TransformStereoScreenSpaceTex(o.texcoord, 1.0f);
    #endif

    But that was already in the code so was not sure what needed to be done next.
     
  15. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,867
    line 141 (2nd pass before " sampler2D _LifgrBuffer;): add:
    #include "UnityCG.cginc"
     
    Baldinoboy likes this.
  16. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,398
    Will do that. Thanks!
     
  17. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,213
    Do I really need to add "_xlod" in case I don't have another lod level, only switching from mesh to billboard in the load groups? I made a few small plants like that and I noticed it works just fine. Is the "_xlod" tag mostly for when you have multiple lod levels?

    On a different note, an awesome job was done with CTI!! I used to complain about CTI as grass but I just realized the performance is a lot better than I would have imagined with shadows turned off in fact. My mind is blown away now as I can spam an entire terrain with beautiful grass and plants with minimal impact to frame rate and performance.
     
  18. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,398
    Hey @florianalexandru05, believe CTI is still setup that you need _xlod in the model name for the tree to be setup for the LOD shaders, which is what you want. Does not ruin anything if you are not actually using any LODs. Can go from LOD0 to billboard fine.
     
    florianalexandru05 likes this.
  19. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,213
    I made a test and there is no difference if I have "_xlod" or no "_xlod" to a plant that goes from lod 0 to culled or billboard while the wind and shader seem to be the same. I think I'll use this approach for small plants. On trees, I would use the "_xlod" tag for sure. I'm using the LODleavses shader.
     
    Baldinoboy likes this.
  20. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,398
    Oh okay. Cool. Thought the xlod setup the export to use the newer LOD shaders.
     
    florianalexandru05 likes this.
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,867
    right out of my head i think @Baldinoboy should be right: adding _xlod to the file name will make the importer assign the proper shaders. furthermore the importer will bake pivots needed by the advanced bending and lod fade features.
    at least that used to be the fact a while ago :)
    so i just looked into the code: actually _xlp, _xlprl and/or _xlt will make the script bake the pivots - independently from _xlod.
     
    Baldinoboy likes this.
  22. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,213
    That explains it then, I use _xlp on everything. I avoided adding xlod on my grass and flowers and it's ok I think.
     
    Baldinoboy likes this.
  23. swredcam

    swredcam

    Joined:
    Apr 16, 2017
    Posts:
    118
    I'm just updating Unity from 2017 to 2018 to clear an App Store issue. I updated CTI to latest and also added the "2018" fix in this thread. Most of my models look fine but there is one that is not rendering the leaves properly -- the black square around each leaf content is rendered. I'm using the same CTI leaf shader, same alpha slider value and all the same settings as another model that works fine. Is there something I am missing here?
     
  24. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,867
    how do these squares look like? and did you already check the textures and their import settings?
    maybe some has gone wrong here...
     
  25. swredcam

    swredcam

    Joined:
    Apr 16, 2017
    Posts:
    118
    The squares are just the normal non-image part of the texture -- what you would see if using an opaque shader.

    I tried a solution that seemed pretty foolproof, I duplicated the material from the good tree, then edited the duplicate to use the "bad" albedo/normal/etc, and put this new material on the "bad" tree. It was still bad -- which is very strange. I'm still trying some various workarounds, but my back-up is to just delete the offending trees. There are not a ton of them thankfully. They work fine if I revert to the 2017 project with no updates.

    PS -- I will check the imports, I would not think that would change but maybe something got dropped in the update.
     
  26. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,867
    indeed. so i would check the textures and how they look in unity after import. maybe the alpha channel just got lost for some reason.
     
  27. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,213
    A bit of a silly question now but does the bounds object need to be a mesh or can it also be an empty, dummy box? I used a mesh as my bounds and I noticed it works as it disappears after tree conversion but I find it rather annoying that there's a box in my fbx file.
     
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,867
    not a silly question at all. but maybe this one is: what is a dummy box if it is not a mesh?
    but you need a mesh here as the script evaluates the mesh bounds.
    however: i am not sure if this is still needed... i think the latest version always picks up bounds from lod0 if it finds one?

    Edit: No it does not :(
     
    florianalexandru05 likes this.
  29. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,213
    Thanks for the fast reply, man! ;) Np then, your tree importer script is still top-notch. I'm getting really good results with wind and performance now.
     
  30. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,213
    I'm having a small issue with, I think it is the normals in URP for the lod foliage shader? It doesn't seem to be caused by the post-processing but the normal map, I get these dark pixels for some reason but only in URP. The pixels don't move around, they are just random stationary dots. Could this be a Unity version problem?
     

    Attached Files:

  31. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,867
    i think it is an URP issue... so do not have white nor black in your normals and keep the contrast low. the builtin unpacknormal function does some very fancy stuff here...
     
    florianalexandru05 likes this.
  32. GotAThing

    GotAThing

    Joined:
    Jan 10, 2019
    Posts:
    9
    Hi iv been experimenting with ways to interact with the bark material when hit with an axe. I've made a c# script that manually draws the bark texture whenever it is hit. not a great solution tho, very laggy as textures are 4k.
    generating a lower res mask and transitioning between 2 textures within the shader is my next step i guess.
    is there any way to do this without modifying the shader that i may have overlooked(im using HDRP)?can the 2nd material be used in this way? anyone got any suggestions, would be much apreciated
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,867
    i think you have to edit the shader.
    but doing it all in shader might look a bit odd?! to do it properly you would have to swap out the prefab i guess - using a mesh that allows you to remove some parts from the trunk with each hit...
     
  34. GotAThing

    GotAThing

    Joined:
    Jan 10, 2019
    Posts:
    9
    no problem, thought i might have to make some changes.iv been testing out afew ideas in shader graph, the main problem with the mask approach is at the uv seams. Going to test sending an array of hit vectors to shader and masking based on distance. should solve the problem and i can then also use vertex offset to remove chunks from trunk. Unsure how it will perform tho
     
  35. GotAThing

    GotAThing

    Joined:
    Jan 10, 2019
    Posts:
    9
    i have something im fairly happy with now and have been attempting to apply the wind within my shader. i discovered the wind subgraph but have been having some issues. i get a float3 to float conversion error on the custom function output, installing the 7.2 HDRP runtime components fixes the error but breaks the shaders. (they go transparent and glitchy) im using 2019.3.13f1, HDRP 7.3.1
     
  36. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,867
    that is pretty common using shader graph. at least it should only be a warning (yellow) and not an error (red)?
    regarding hdrp 7.3.1. and 7.2.: all the shader does is more or less in the custom function which drives the vertex animation. this should run across all versions of hdrp. the rest comes from shader graph. editing the shader in shader graph or reimporting it often fixes issues.
     
  37. nick_dv

    nick_dv

    Joined:
    Mar 26, 2016
    Posts:
    11
    Please help! Problems with Shader error in CTI Runtime (from 2020-06-21) when using Unity 2019.4.8 and newer. Problem occurs when building the project, see picture below. Works fine in the Unity Editor for all versions. It also works in earlier versions of 2019.4 and also builds fine when removing CTI Runtime. I don't have any own tree imported yet.

    Shader Error 2020-09-12.png
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,867
    what kind of shader error am i expected to see?
     
  39. nick_dv

    nick_dv

    Joined:
    Mar 26, 2016
    Posts:
    11
    Shader Error 2020-09-12.png
    Same scene as my last picture (above) but in Unity editor view (I'm not using any post processing for the camera). Using the Build-in render pipe.
    View attachment 697917
     
    Last edited: Sep 12, 2020
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,867
    is it fixed or is it not? i am confused...
    the "Hidden/Camera-DepthNormalTexture" shader is only needed if you use forward and any image effect relying on a depth/normal texture such as ssao.
     
  41. nick_dv

    nick_dv

    Joined:
    Mar 26, 2016
    Posts:
    11
    No, its not fixed. I'm using Deferred lighting. Still can't build without Shader problems in 2019.4.8 and newer. See picture above. Please assist. Any ideas why this happens?
     
  42. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,867
    then just get rid of the "Hidden/Camera-DepthNormalTexture" shader.
    or do i completely misunderstand you here?
    if your 1st scren shot showed problem with the trees than this is not caused by the shaders (as they run fine in editor) but something unity does during the build process. which may either be shader variant stripping or mesh compression. looks a bit likes latter so deactivate mesh compression/optimization. you my also use renderdoc the see what is going on here.
     
  43. nick_dv

    nick_dv

    Joined:
    Mar 26, 2016
    Posts:
    11
    Thank you. As you say the problem is in building. I will try this and change the options and also Reimport all shaders.
     
  44. nick_dv

    nick_dv

    Joined:
    Mar 26, 2016
    Posts:
    11
    Sorry, It didnt work. I removed the shader Camera-DepthNormalTexture. I reimported all shaders, turned off all opmiization and shader stripping in the Player. Also tryied the RenderDoc v1.9. It did not report any problems. Any other Ideas?
     
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,867
    nope, what does render doc says? how i she frame rendered and which pass causes the issues?
     
  46. nick_dv

    nick_dv

    Joined:
    Mar 26, 2016
    Posts:
    11
    Cant get RenderDoc to work in the Player build. It craches when I try to launch it with my game. Doesnt seem to work with the new Unity Player 2019.4.10. However when I removed a shaders CTI_LOD_Bark.shader and CTI_LOD_Bark_Array.shader. That kind of worked, except for the bark on the trees of course, see pic. The problem for me anyway seems to be in that shader.
     
    Last edited: Sep 13, 2020
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,867
    so i tested it in 2019.4.9f1.
    • i created a new project and grabbed cti from the asset store
    • i updated the shaders (using the 2018.2_CTI_LOD_Leaves_Shader_Fix package).
    • opened the provided "LOD Group Demo".
    • set the camera to deferred
    • assigned the cti deferred lighting and reflection shader
    • set the project to linear color space
    • grabbed the simple birch tree from the "Bark Texturing Demo" as it uses texture arrays on the trunk
    • finally i built and run the scene
    result: everything looks absolutely fine in the build!?

    so i do not think it is the shader. maybe the model/mesh. so you may set wind to 0. then the mesh should not bend and should not be distorted. your first screen shot somehow lets me think of a completely distorted mesh still.

    or you can directly uncheck "optimize mesh data" in the player settings.

    optimizemeshdata.PNG
     
unityunity