1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SHADER setting-up trees

Discussion in 'Tracks' started by jarodyi, Nov 4, 2014.

  1. jarodyi

    jarodyi New Member

    Joined:
    Oct 10, 2014
    Likes Received:
    10
    1 and can u share u wire.dds and 3ds file in pic with me?

    2 can u show me your trees setting in aceditor? i can`t get trees view right :(

    3 can u tell me how does the "Illumination" works for ? just see the time effect in editor but not set the sun position in game?

    thanks:)
     

    Attached Files:

  2. luchian

    luchian Administrator ACM Racing Team ACM Club Driver

    Joined:
    Jun 3, 2014
    Likes Received:
    524
    2/ Best way (recommended by Kunos) is to use Y trees (remember, AC does not support double sided materials, so you must mirror faces). You can have a look at the trees in the sample track provided with the game STEAM\steamapps\common\assettocorsa\sdk\editor\samples\newbury.

    2014-11-04_223532.png

    You can setup normals manually, but there is an easier way, if you respect 2 conditions. This will assure best look and best performance for your trees.

    1) respect naming convention: KSTREE_GROUP_”anyname“_”number”
    Example: KSTREE_GROUP_test_1. A group will be formed by all the objects that have the same name and continuous numbering: KSTREE_GROUP_test_2, KSTREE_GROUP_test_3, KSTREE_GROUP_test_4, and so on. If you wish a second group, change the name of the group: KSTREE_GROUP_other_1, 2, 3, ...

    2) the pivot point of the single tree must be in the center of the geometry (or slightly moved on Z axis). This way, the ksEditor will set the normals automatically when you import your FBX.
     
    Last edited: Nov 6, 2014
    Willy Wale and liquido like this.
  3. luchian

    luchian Administrator ACM Racing Team ACM Club Driver

    Joined:
    Jun 3, 2014
    Likes Received:
    524
    This is a study made by our fellow forumer @LilSKi << all credits
    Setting up correctly the trees in AC, not only helps you and make your life easier, but also improves the lighting and the performance. Therefore, it's highly recommended that you give this a read and try to follow it :).

    /by Lilski
    Basic overview of trees in AC. There is some confusion out there as to the right and wrong way to setup trees for AC. Below are some examples of different trees and what they look like in the editor/sim.

    Here they are in blender. I did 4 basic types of trees and shown in red are the object names. Two of them use the KSTREE naming scheme and two do not. The TREE on the far left has all normals set to vertical. The rest the normals are untouched from default. Also notice the vertical subdivisions.
    1.JPG
    Here they are in the editor with sun overhead. You can see we now have 4 very different trees. the far left with vertical normals is fully lit with no shading at all. Next to that we see that using the KSTREE object name has altered the normals automatically. The issue here is the entire center of the tree is dark and only the edges are lit up. Next to that in group B you can see the desired result. The only difference between A and B is the extra vertical subdivision shown above. Then TREE2 is just a disaster.
    2.JPG
    Here they are at low light. As you can see TREE is still lit from top to bottom and completely unnatural. I believe this is what most RTB trees are doing. Group A doesn't look bad but again too dark in the center. Group B again is the desired result. TREE2 still a disaster. All 4 trees here are using the same shader settings.
    3.JPG
    One important thing about the tree objects is in order for the KSTREE auto normals to work properly the origin of the object MUST be at the bottom.
    4.JPG
    Now lets discuss the whole GROUP thing. It is worth mentioning that from within blender or 3DS you MUST keep the tree objects separate. DO NOT join them together. The KSTREE naming scheme does that for you with the groups.

    So here is a shot of Bridgehampton trees in blender. Selected below is GROUP_A. Notice each tree is a separate object.
    5-groupA.JPG
    Just to show here is GROUP_B. This trend goes around the whole track with GROUP_C. GROUP_D, etc.
    6-groupB.JPG
    You do not have to use A, B, C, D, etc. You can use anything like KSTREE_GROUP_PINE_, KSTREE_GROUP_MAPLE, etc. I find the letters the easiest.

    This is what it will look like after you load it in the editor. there will be a section called "BLOCKTRANSFORM" and you will find the group names in there. The KSTREE_GROUP part of the name will be stripped away.
    7.jpg
    I hope this clears up some confusion. Also know that just because you use the KSTREE_GROUP_x_ naming scheme DOES NOT mean you have to use the kstree shader. The entire point of the KSTREE naming is to auto set the normals for you and join to single objects according to group name. You can also use KSTREE naming on 3D trees and it will set the normals just like a Y tree. Just make sure the origin is always at the bottom and the normals will all be done for you on import to the editor.

    Some final examples of trees in sim. Notice how the bottoms are all dark as they should be.
    8.jpg
    9.jpg
     
    Pixelchaser and r@m like this.
  4. Pixelchaser

    Pixelchaser Well-Known Member ACM Club Driver

    Joined:
    Jan 4, 2015
    Likes Received:
    745
    be nice to see all lilski`s tutorials here. I should be looking at the grass tuts but I'm so damned lazy. :lol: was it nighteye who did the grass?
     
    Last edited: Jul 5, 2017
  5. Mitja Bonca

    Mitja Bonca Member

    Joined:
    Nov 18, 2014
    Likes Received:
    15
    Location:
    Slovenia
    What ambient and specular values do you use for ksTree, to get the wanted result?
     
  6. Pixelchaser

    Pixelchaser Well-Known Member ACM Club Driver

    Joined:
    Jan 4, 2015
    Likes Received:
    745
    generally you balance that with your complete main scenery. altogether its hovering around 0.2 to 0.3 for these figures when the rest is balanced.
     
    luchian likes this.
  7. LilSKi

    LilSKi Active Member

    Joined:
    Apr 6, 2015
    Likes Received:
    177
    Taken from persistence file from NJMP which is shown above. But obviously a lot depends on your textures and how bright they are and as what Pixelchaser said regarding your surrounding scenery.

    [MATERIAL_5]
    NAME=TREE1__tree1_dds
    SHADER=ksTree
    ALPHABLEND=0
    ALPHATEST=1
    DEPTHMODE=0
    VARCOUNT=6
    VAR_0_NAME=ksAmbient
    VAR_0_FLOAT1=0.4
    VAR_0_FLOAT2=0,0
    VAR_0_FLOAT3=0,0,0
    VAR_0_FLOAT4=0,0,0,0
    VAR_1_NAME=ksDiffuse
    VAR_1_FLOAT1=0.25
    VAR_1_FLOAT2=0,0
    VAR_1_FLOAT3=0,0,0
    VAR_1_FLOAT4=0,0,0,0
    VAR_2_NAME=ksSpecular
    VAR_2_FLOAT1=0
    VAR_2_FLOAT2=0,0
    VAR_2_FLOAT3=0,0,0
    VAR_2_FLOAT4=0,0,0,0
    VAR_3_NAME=ksSpecularEXP
    VAR_3_FLOAT1=1
    VAR_3_FLOAT2=0,0
    VAR_3_FLOAT3=0,0,0
    VAR_3_FLOAT4=0,0,0,0
    VAR_4_NAME=ksEmissive
    VAR_4_FLOAT1=0
    VAR_4_FLOAT2=0,0
    VAR_4_FLOAT3=0,0,0
    VAR_4_FLOAT4=0,0,0,0
    VAR_5_NAME=ksAlphaRef
    VAR_5_FLOAT1=0.5
    VAR_5_FLOAT2=0,0
    VAR_5_FLOAT3=0,0,0
    VAR_5_FLOAT4=0,0,0,0
    RESCOUNT=1
    RES_0_NAME=txDiffuse
    RES_0_SLOT=0
    RES_0_TEXTURE=tree1.dds
     
    Last edited: Jul 11, 2017
    Mitja Bonca and luchian like this.
  8. Pixelchaser

    Pixelchaser Well-Known Member ACM Club Driver

    Joined:
    Jan 4, 2015
    Likes Received:
    745
    its also good to be on the darkside if you cant decide, as trees generally are, well as opposed to ground grass. but it can be close..... what will make it Sweet is when you get the shadowing or ambient occlusion working well on it ala Lilski tutorial.
     
    Mitja Bonca likes this.
  9. r@m

    r@m Active Member

    Joined:
    Jun 7, 2017
    Likes Received:
    126
    [​IMG]
     
    luchian likes this.
  10. Mitja Bonca

    Mitja Bonca Member

    Joined:
    Nov 18, 2014
    Likes Received:
    15
    Location:
    Slovenia
    I did not name tree lines with KSTREE_GROUP_SOMENAME_NUMBER, but only 3d trees.
    So here is the result in ksEditor:
    [​IMG]

    You can see that tree lines have fine lighting. 3d trees has a reversed lighting. What could be wrong?
     
  11. LilSKi

    LilSKi Active Member

    Joined:
    Apr 6, 2015
    Likes Received:
    177
    The normals for tree lines/walls must always be pointed vertical. And it is best to turn off shadows on them as they are not needed.

    upload_2017-7-12_13-41-20.jpeg
     
    luchian likes this.
  12. Mitja Bonca

    Mitja Bonca Member

    Joined:
    Nov 18, 2014
    Likes Received:
    15
    Location:
    Slovenia
    Tree lines are not the problem here, but 3d trees.
     
  13. LilSKi

    LilSKi Active Member

    Joined:
    Apr 6, 2015
    Likes Received:
    177
    No the tree lines are the problem. 3D trees are fine.
     
  14. Mitja Bonca

    Mitja Bonca Member

    Joined:
    Nov 18, 2014
    Likes Received:
    15
    Location:
    Slovenia
    From the game:
    Toward sun (bright 3d trees, and dark tree wall):
    [​IMG]

    Away from the sun (dark 3d trees, and bright wall tree):
    [​IMG]
     
  15. LilSKi

    LilSKi Active Member

    Joined:
    Apr 6, 2015
    Likes Received:
    177
    You can argue with me all you want. The fix is setting the tree wall normals to full vertical. If you want to beat your head against the wall trying to fix it another way be my guest.

    And the 3D Y trees are too bright.
     
  16. Mitja Bonca

    Mitja Bonca Member

    Joined:
    Nov 18, 2014
    Likes Received:
    15
    Location:
    Slovenia
    Hehe, ok. I will take a look into tree wall. It was not logical to me, but I will surely listen to you. Will keep you posted about it.
     
  17. LilSKi

    LilSKi Active Member

    Joined:
    Apr 6, 2015
    Likes Received:
    177
    I also suggest you use the ksgrass shader on the tree walls to get a variation file in there. And again make sure shadows are off on the tree walls.
     
    Mitja Bonca likes this.
  18. Mitja Bonca

    Mitja Bonca Member

    Joined:
    Nov 18, 2014
    Likes Received:
    15
    Location:
    Slovenia
    Can I ask you one more thing? I have one texture for 3d trees and tree wall. Is it not possible to set different shaders for both? Do I have to separate textures?
     
  19. LilSKi

    LilSKi Active Member

    Joined:
    Apr 6, 2015
    Likes Received:
    177
    Just make a new material for the walls in 3Ds. Two different materials can use the same texture in the editor. But in general I have the tree walls as its own texture separate from the 3D tree textures. But making a new material for the tree wall will accomplish the same thing.
     
    luchian and Mitja Bonca like this.
  20. Mitja Bonca

    Mitja Bonca Member

    Joined:
    Nov 18, 2014
    Likes Received:
    15
    Location:
    Slovenia
    Wow, didn`t know that. Thx a lot mate.
     
    Last edited: Jul 12, 2017