Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

[Released!] Custom tree importer

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

  1. mikejm_

    mikejm_

    Joined:
    Oct 9, 2021
    Posts:
    346
    Just for the record or anyone else having this "bug" from Blender, I learned the issue. There is something called a "parent inverse": https://docs.blender.org/manual/en/latest/scene_layout/object/editing/parent.html

    So you have to be careful in Blender because you won't see this "hidden matrix" but if it gets created during your parenting (based on settings presumably I haven't figured out the nuance to yet), you cannot see it in your hierarchy or object panels. However, it does become evident on FBX export when it is applied.

    When I take the project with the bark object that keeps rotating -90 on export, if I click that bark (which shows 0 rotation at rest) and go Object > Apply > Parent Inverse, suddenly the -90 rotation becomes visible on the x axis. Then I can go Object > Apply > Rotation and now it is truly set to zero.

    Without doing the Apply Parent Inverse first, there is still a hidden rotation in there. So not exactly a bug. Just a strange design where they are hiding a potential rotation as the "Parent Inverse" rotation. If Blender was better designed, I think this would be visible on a panel somewhere instead of just hiding it completely.

    So if things are rotating weird, or you're not sure, Apply Parent Inverse to anything that is misbehaving then Apply Rotation.

     
    florianalexandru05 likes this.
  2. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,850
    CTI 2022 bark shader seems to be broken in URP! Also, HDRP HLSL doesn't work anymore aside from the share graph shaders, which is still fine at least.

    CTI urp errors.jpg
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    i will skip the hlsl versions completely as they just need tooo much work.
    attached 2 urp versions for 2022.3 lts.
    14_plus package uses shader graph shaders and should be future proof (plus).
    2023 package contains latest hlsl version.
     

    Attached Files:

  4. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,850
    It works, thanks a lot man you're a life saviour!! Yah I agree, it's really hard to maintain...
     
  5. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,245
    If you get errors on the latest version of Unity/URP about not finding a 4 parameter version of DirectBDRF, open the file "CTI URP Lighting.hlsl" in the includes folder, and find the following function:

    Code (CSharp):
    1. half3 LightingPhysicallyBasedWrapped(BRDFData brdfData, half3 lightColor, half3 lightDirectionWS, half lightAttenuation, half3 normalWS, half3 viewDirectionWS, half NdotL)
    2. {
    3. //NdotL is wrapped... not correct for specular
    4.     half3 radiance = lightColor * (lightAttenuation * NdotL);
    5.     return DirectBDRF(brdfData, normalWS, lightDirectionWS, viewDirectionWS) * radiance;
    6. }
    Change it to specify false for the last parameter (Don't do specular):


    Code (CSharp):
    1. half3 LightingPhysicallyBasedWrapped(BRDFData brdfData, half3 lightColor, half3 lightDirectionWS, half lightAttenuation, half3 normalWS, half3 viewDirectionWS, half NdotL)
    2. {
    3. //NdotL is wrapped... not correct for specular
    4.     half3 radiance = lightColor * (lightAttenuation * NdotL);
    5.     return DirectBDRF(brdfData, normalWS, lightDirectionWS, viewDirectionWS, false) * radiance;
    6. }
     
  6. LeraEclera

    LeraEclera

    Joined:
    Feb 12, 2023
    Posts:
    5
    Hi all, i have
    "Shader error in 'CTI/URP Billboard': invalid subscript 'shadowCoord' at line 178 (on d3d11)"
    on Unity 2021.3.7f1.
     
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    for URP 14 and above CTI uses shader graph. a little bit less powerfull but easier to maintain.
    you will fidn a proper package attached.
     

    Attached Files:

    LeraEclera likes this.
  8. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,850
    Hi again, would you be able to have a working version of the HDRP billboard shader for 2023? The shader graph versions of CTI work just fine but there is no working billboard shader.
     
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    oh, there isn't?
    well, you could simply grab the latest version of the free conifer trees.
    or use the package attached.
     

    Attached Files:

  10. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,850
    Yah it's there but for some reason, it was hidden and didn't show up, thanks!
     
  11. nu51313932

    nu51313932

    Joined:
    Oct 28, 2016
    Posts:
    83
    I can make it work with fbx from blender now.
    I have a new question, please.

    Can I lock the tree trunk to not move? because my tree is a giant tree, the trunk should stay still.


    and the second question: how to control specular value of the bark texture? i try to change any value but nothing changed
     
    Last edited: May 29, 2024
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    right out of my head: set main bending to 0 in the global control tags?
     
  13. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,527
    Or just _xw00 to the trunk, which I think is the same effect.
     
  14. nu51313932

    nu51313932

    Joined:
    Oct 28, 2016
    Posts:
    83
    how to reduce specular or increase specular value of the bark material?

    okay, i found out that it is the color variation value.

    thank you so much everyone. I just leran how to use CTI with my friend's licence , but now I wanna buy the license for my account
     
    Last edited: May 30, 2024
    Baldinoboy likes this.
  15. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    :)