Search Unity

[Released!] Custom tree importer

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

  1. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    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:
    6,902
    i just uploaded a new version.
     
    Noogy likes this.
  3. larsbertram1

    larsbertram1

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

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    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:
    6,902
    fine!
     
  6. Low_on_Mana

    Low_on_Mana

    Joined:
    Jun 18, 2018
    Posts:
    37
    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:
    37
    Please, @larsbertram1, any help would be greatly appreciated
     
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    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:
    132
    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:
    6,902
    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:
    132
    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:
    6,902
    URP and forward should be rather easy :) just hack it into the lighting function
     
  13. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    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,526
    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:
    6,902
    line 141 (2nd pass before " sampler2D _LifgrBuffer;): add:
    #include "UnityCG.cginc"
     
    Baldinoboy likes this.
  16. Baldinoboy

    Baldinoboy

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

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,813
    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,526
    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,813
    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,526
    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:
    6,902
    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,813
    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:
    130
    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:
    6,902
    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:
    130
    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:
    6,902
    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,813
    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:
    6,902
    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,813
    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,813
    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:
    6,902
    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:
    14
    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:
    6,902
    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:
    14
    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:
    14
    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:
    6,902
    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:
    14
    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:
    6,902
    what kind of shader error am i expected to see?
     
  39. nick_dv

    nick_dv

    Joined:
    Mar 26, 2016
    Posts:
    14
    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:
    6,902
    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:
    14
    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:
    6,902
    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:
    14
    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:
    14
    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:
    6,902
    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:
    14
    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:
    6,902
    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
     
  48. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    Hi @larsbertram1, are there any known issues with the bark URP shader and the latest betas of Unity? I'm using 2020.2.0b8 and the bark shaders are giving me a 'failed to compile'. Leaves are fine though. thanks.

    Edit, more details:
    'InitializeStandardLitSurfaceData': output parameter 'outSurfaceData' not completely initialized
    Compiling Fragment program
    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_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_RGBM_ENCODING
    Disabled keywords: _NORMALMAP _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS _ADDITIONAL_LIGHT_SHADOWS _SHADOWS_SOFT _MIXED_LIGHTING_SUBTRACTIVE LOD_FADE_CROSSFADE FOG_LINEAR FOG_EXP FOG_EXP2 INSTANCING_ON _NORMALIZEBRANCH UNITY_NO_DXT5nm UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_NO_FULL_STANDARD_SHADER UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_COLORSPACE_GAMMA UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_FULL_HDR UNITY_VIRTUAL_TEXTURING UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_ASTC_NORMALMAP_ENCODING SHADER_API_GLES30
     
    Last edited: Oct 25, 2020
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i did test it so far. now i have (using URP 10 in 2020.2.0b5).
    so you have to replace the "CTI URP Inputs.hlsl" with the new file attached.
     

    Attached Files:

    Baldinoboy and Noogy like this.
  50. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    Wonderful, thank you for the quick fix, it works! On the subject of bark shaders... I'm using Unity's new built-in SSAO URP feature (2020.2.0b8), and there are a few shaders not 'receiving' the effect, including the bark shader.

    I was wondering if I'm missing something, although it's also happening with Microsplat and I'm working with that author to look at it. I actually like that SSAO isn't being applied to CTI leaves since that works with the stylized look I'm using, but it'd be nice if bark received the effect. I can see in the framedebugger that SSAO is being rendered at some point on the bark, but afterwards is cleared out. The ability to toggle the effect on leaves/bark would be fantastic, if that's possible. Thanks.