TUTORIAL 3D grass

Discussion in 'Tracks' started by luchian, Dec 22, 2014.

  1. luchian

    luchian Administrator Staff Member

    Joined:
    Jun 3, 2014
    Messages:
    3,007
    Likes Received:
    1,493
    AC member SandroX made a video back in July, on how to make 3d grass with 3ds max. Maybe you guys find it usefull as well:



    Objects with suffix KSLAYER5 will be visible only at settings World Detail Maximum, KSLAYER4 on Very High, KSLAYER3 on High and so on. Some examples:

    grassA_KSLAYER1, grassB_KSLAYER1, plantA_KSLAYER1, bushA_KSLAYER1, etc - will all be groupped and visible starting from lowest world detail.

    grassX_KSLAYER2, grassY_KSLAYER2, grassZ_KSLAYER2, etc. - will all be visible starting from world detail 2


    For shader settings, of course you can define your own, but in case you need a starting point, here's an example (also thanks to SandroX) :

    nw_gs.jpg
     
  2. luchian

    luchian Administrator Staff Member

    Joined:
    Jun 3, 2014
    Messages:
    3,007
    Likes Received:
    1,493
    In case you are using Blender, AC member skombijohn (<thank you) shows the way :D

    1) Create the object (a cube for example)
    2) Apply 2 array modifiers, set each to the desired number of iterations (they get multiplied!)
    3) Set the relative offset of one modifier to somthing bigger than 1 on X axis and on the other on Y axis (see screen)

    3d_grass_01.png

    4) Apply both modifiers.
    5) Now you have a single object with many cubes. Let's split em!
    6) Select the object, go to Edit Mode, select all vertices.
    7) Hit "P" and choose "by loose objects".
    8) Leave Edit mode, and you have independet objects!
    9) Now we must correctly set all the objects orgins. So select all single cubes and choose "Set Origin -> Origin to Geometry".

    3d_grass_02.png
    Result:

    3d_grass_03.png
    10) Let's randomize them: With all cubes selected we use the "Randomize Transform" function. To find that function quick hit SPACE and simply type "Randomize Transform".

    3d_grass_04.png
    11) in the tool panel there are now settings for the random transform:

    3d_grass_05.png
    12) When you are happy hit CTRL-A and select "Rotation and Scale" to apply the transformation
    13) Now with all cubes selected simply join them.

    3d_grass_06.png
    14) done.
     
    Dave Thefan likes this.
  3. Fat-Alfie

    Fat-Alfie New Member

    Joined:
    Jun 2, 2015
    Messages:
    23
    Likes Received:
    14
    Quick question: with world detail set to maximum, do you see objects named kslayer5, kslayer4, kslayer3 etc? Or only those named kslayer5? I.e. do they build up together or is each 'layer' viewed in isolation?
     
  4. luchian

    luchian Administrator Staff Member

    Joined:
    Jun 3, 2014
    Messages:
    3,007
    Likes Received:
    1,493
    99% sure they build up together.

    ..sent from my phone.
     
  5. Fat-Alfie

    Fat-Alfie New Member

    Joined:
    Jun 2, 2015
    Messages:
    23
    Likes Received:
    14
    I just did a quick test and yes, I can confirm that KSLAYER3 objects appear when world detail is set to 'high', 'very high' and 'maximum' - so they build up.

    [Sorry, I could have just tested that in the first place instead of asking on the forum :rolleyes:]

    I was going to set my grass objects within each area at 500 for KS3, 1000 for KS4 and 2000 for KS5, but now I have done that test, that would mean on KS5 I would have 2000+1000+500 objects visible (3500) and not the 2000 I thought. I guess I could set KS3 to 600, and then just duplicate each object for KS4 and then KS5, giving me a total count of 1800 objects on KS5.

    I think I need to test performance before I go much further o_O

    Thanks for your help, btw :)
     
    luchian likes this.
  6. Johnr777

    Johnr777 Moderator

    Joined:
    Jul 26, 2017
    Messages:
    1,050
    Likes Received:
    615
    We might have to rethink grass in the very near future, :lol:

    Grass_FX_Mosport.png
     
  7. luchian

    luchian Administrator Staff Member

    Joined:
    Jun 3, 2014
    Messages:
    3,007
    Likes Received:
    1,493
    Wow !

    I saw Ilja's video and it's just awesome (..and honestly incredible in the same time).
    The grass and the indirect illumination are my favourites.
     
    Prototype and MGMetroDave like this.
  8. Johnr777

    Johnr777 Moderator

    Joined:
    Jul 26, 2017
    Messages:
    1,050
    Likes Received:
    615
    Its a bit awkward to work with, specially since we've been using masks for outside terrain. But as soon as it becomes public, I'll definitely do a "how-to" on this :)
     
    Prototype, MGMetroDave and luchian like this.
  9. MGMetroDave

    MGMetroDave Active Member

    Joined:
    Apr 7, 2019
    Messages:
    141
    Likes Received:
    159
    @Johnr777 Definitely looking forward to your how-to! Just tried playing around with the new settings and I must admit to being a bit lost! :lol:
     
  10. Johnr777

    Johnr777 Moderator

    Joined:
    Jul 26, 2017
    Messages:
    1,050
    Likes Received:
    615
    GRASS_FX! (CSP 245 and above)

    Here's a quick explanation on how to apply procedural grass to your track:

    1) Make sure this system is enabled, check CM settings and the Grass_fx.ini file in the extension folder.
    I would disable... CAST_SHADOWS=0, GROUND_COVERING_GRASS=0, EXTRA_DENSE=0

    Shadows can be a bit weird, ground covering grass helps with blending, but looks horrible at the moment, and hides your grass detail maps, you might not want that... and extra dense, only if you really have the hardware for it!

    You'll be able to see it in action in a few tracks: Brands Hatch, Spa, Highlands, Nurburgring...

    2) If your track has a configuration ini file already, great, if not, will need to create one!

    The best method to do this now is to create a new folder inside your track/project, and name that folder extension . Inside that folder, create a text file and name it ext_config.ini . This is a good way to create configurations files since its prioritized over any other folder, and from a few patch versions ago, you can edit it in realtime as well.

    3) Inside that configuration ini, you need to add the following:
    [GRASS_FX]
    GRASS_MATERIALS = the name of the material(s) you want procedural grass on top of

    OR

    GRASS_MESHES = the name of the mesh(s) you want procedural grass on top of

    You may also need to insert the following tags, to trim, tweak, etc.

    OCCLUDING_MESHES = any mesh name entered here will serve as a boundary "zone" to not have grass on.. (ie, kerbs, if they overlap a grass area)

    OCCLUDING_MATERIALS = same as above, but with a material instead

    OCCLUDING_MATERIALS_ALPHA = if an overlaying mesh has an alpha channel, say a gravel edge for example, you can enter the material name of that edge, and this tag will use the white part of the alpha for boundaries!

    ORIGINAL_GRASS_MATERIALS= enter here name of the existing 3D grass material if it exists, it will hide it automatically when grass_fx is enabled

    AND

    This system relies on grass color to generate procedural grass objects, it mostly sees green, but... there are cases when the track or project doesnt really feature a green grass surface for whatever reason... Kyalami, Sebring, a patchy dead/dry area for example...

    COLOR_FACTOR = numbers higher than 1 will allow grass to spawn on not so green surfaces, im assuming less than 1 will require more green?

    TWEAKS

    HEIGHT_MULT = this is the grass height parameters, i think default is 0.5?

    _________________________________

    There are more tags that can be used, and ways to clean things up/optimize... I'll show examples later on, but this should help get you a preview of grass_fx! There are also a few examples in inis for other tracks that can be used for reference: https://github.com/ac-custom-shaders-patch/acc-extension-config/tree/master/config/tracks

    Its an early system with lots of bugs... Ilja even mentioned he might replace certain things, but its safe to say its the future of AC "vegetation" modding.

    Kyalami - Conventional grass scattering method:

    Screenshot_ier_porsche_911_gta_kyalami_2016_29-10-119-1-19-25.png

    Procedural grass:

    [GRASS_FX]
    GRASS_MATERIALS = Base_Grass_Edge, Base_Grass_Tile, Embank_Tile, Embank_Grassy_Tile
    OCCLUDING_MESHES = edge??, Cars??, Canopy??
    OCCLUDING_MATERIALS_ALPHA = Gravel_Edge
    HEIGHT_MULT = 0.3
    COLOR_FACTOR = 1.06

    Screenshot_ier_porsche_911_gta_kyalami_2016_29-10-119-1-10-3.png



    Hope this helps.
     
  11. MGMetroDave

    MGMetroDave Active Member

    Joined:
    Apr 7, 2019
    Messages:
    141
    Likes Received:
    159
    @Johnr777 Thank you, this is an excellent explanation. I totally agree with your words on disabling ground covering grass, extra dense and shadows.

    I have a few questions, which to be honest I'm not expecting anyone to know the answer to yet, but I'll try anyway. :lol:

    Does anyone happen to know...
    1. How to use my own textures for the grass? Ilja mentioned that the current texture is the 'default' texture, which suggests there's a way of overriding it? The default textures are found in assettocorsa\extension\textures\grass_fx, and you can take a guess about how they work. They have 8 sprites/textures from top to bottom for the 'common.dds' (upright grass) and 4 sprites top to bottom for the ground cover. They have a green channel being used for the parts of the grass that will inherit their colour from the ground beneath, the blue and red channels seem to be used for adding other colours for a bit of variety, such as flowers, and then an alpha for transparency. So it seems fairly simple to make your own textures, but I don't know where to put them or how to activate them.

    2. Is there a way to disable shadows, ground-covering grass and extra dense on a per-track basis via the track ini file? My track really looks best without those, as well as running quicker, and I'd like to disable them for my track.

    3. I've noticed that with GrassFX disabled there's a difference to the normal ksGrass on my track in the latest CSP preview 245 compared to the previous preview 205 build. I can't quite work out what's happened. I think it's lowered the grass shaders on the Z-axis by a little bit, or perhaps disabled some of it? I'm not entirely sure what's happened. In fact I thought it was my imagination but I've since switched back and forth between 245 and 205 and the ksGrass in 205 looks perfect but very strange in the latest CSP build.

    Sorry I know I'm forever asking annoying questions! :lol:
     
  12. Johnr777

    Johnr777 Moderator

    Joined:
    Jul 26, 2017
    Messages:
    1,050
    Likes Received:
    615
    1. We are working on getting the ability to have different textures per track, as needed (We asked Ilja nicely, :lol:). But in the meantime, you can overwrite that common.dds file with your own work :)

    2. Unfortunately, not that I know of yet..

    3. Ilja changed how alpha channels work... Theres no more alpha blending/ smoothing bands for certain shaders. They are sharp. Something called alpha-to-coverage, which im not a big fan of, he has mentioned he could add an enable/disable option to this, so theres hope!
     
    MGMetroDave likes this.
  13. MGMetroDave

    MGMetroDave Active Member

    Joined:
    Apr 7, 2019
    Messages:
    141
    Likes Received:
    159
    Thanks @Johnr777 that's very interesting and explains a lot.
     
  14. Johnr777

    Johnr777 Moderator

    Joined:
    Jul 26, 2017
    Messages:
    1,050
    Likes Received:
    615
    Glad to help!
     
  15. MGMetroDave

    MGMetroDave Active Member

    Joined:
    Apr 7, 2019
    Messages:
    141
    Likes Received:
    159
    Fat-Alfie likes this.
  16. MGMetroDave

    MGMetroDave Active Member

    Joined:
    Apr 7, 2019
    Messages:
    141
    Likes Received:
    159
    Alternative grassfx texture, for those who don't mind experimenting. It works well for long grass especially. Contains a few weeds. Feel free to test now and feel free to use in your own tracks when custom grassfx textures become possible...

    (unzip, goes in assettocorsa\extension\textures\grass_fx and don't forget to back up your old common.dds!)
     

    Attached Files:

    Les Neilson and luchian like this.
  17. luchian

    luchian Administrator Staff Member

    Joined:
    Jun 3, 2014
    Messages:
    3,007
    Likes Received:
    1,493
    @Johnr777 do you happen to know why there are 2 modules named Grass_Fx in CSP/Content Manager ?
     
  18. Johnr777

    Johnr777 Moderator

    Joined:
    Jul 26, 2017
    Messages:
    1,050
    Likes Received:
    615
    Huh? Should be just one... and there you can find sliders for the density of the grass, type of antialiasing used, etc
     
  19. luchian

    luchian Administrator Staff Member

    Joined:
    Jun 3, 2014
    Messages:
    3,007
    Likes Received:
    1,493
    2020-02-25_233839.png

    IDK :lol:. This is how it looks on my system. CSP 0.1.40

    LE: options are also different
    2020-02-25_234044.png
    2020-02-25_234055.png
     
  20. Johnr777

    Johnr777 Moderator

    Joined:
    Jul 26, 2017
    Messages:
    1,050
    Likes Received:
    615
    The one active is current, so you should be ok. Don’t know why the original one is still in the menu, maybe the file still around? Should’ve been replaced when you update
     
    luchian likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice