Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RELEASED] Vegetation Studio

Discussion in 'Assets and Asset Store' started by LennartJohansen, Jun 23, 2017.

Thread Status:
Not open for further replies.
  1. blitzvb

    blitzvb

    Joined:
    Mar 20, 2015
    Posts:
    284
    Thanks for your replies!

    - Do you know when mesh support will be added? Wondering if I should go terrain ... cause mesh also come later for other assets.
    - I use chunk of meshes for performance reason but I guess I can add VS on each individual tile before the combine in chunk. Though I have the feeling that adding 40/50 VS component will be slow at runtime no?

    Maybe the combination of multiple VS with mask, as you suggest, will be better. Like one per biomes (forest, desert..) with mask over individual hex that do not conform or conform.
     
    Last edited: Nov 10, 2017
  2. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi.

    I just finished the guide to upgrade shaders. Simple process to do. I added a section showing how to set this up if the shaders is made with Amplify Shader Editor also. This helps you from having to manually change the shader.

    https://www.awesometech.no/index.php/guide-adding-instanced-indirect-support-to-shaders/

    There is 2 reasons for why the Runtime Prefab Spawner is only set up to work on trees, objects and large objects.

    1. Vegetation using instanced indirect only has the instances stored in a compute buffer on the GPU and the run-time prefab spawner can not access the instances to evaluate if a prefab needs to be spawned. This was done by design since I did not need the instances in CPU memory. It is not a big change to fix this.

    2. I did not add grass and plants to the list since I thought there would be way to many grass instances to spawn prefabs on. But if someone has a need for this I can add it when point 1 is done.

    for now you can add the banana plant as a object and render it instanced. This will work around the problem until I update.
     
  3. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    I have a few other features planned before I start to look at mesh support. I do not think I will start before January, and that may also change depending on the other features.

    How big are these chunks? How many can be visible as the same time? We could maybe set up a pool of VegetationSystem components and re-use those on the currently visible tiles?
     
    Mark_01 likes this.
  4. blitzvb

    blitzvb

    Joined:
    Mar 20, 2015
    Posts:
    284
    Less than 10 chunks could be visible at the same times. Yeah a pool could help.
     
  5. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Do you have any culling system set up for the chunks? CullingGrouop API?
     
  6. blitzvb

    blitzvb

    Joined:
    Mar 20, 2015
    Posts:
    284
    Yeah. self made based on the position of the camera. So I guess it would be a little more than 10 VS with the culling.

    Do you think it will works fast?
     
    Last edited: Nov 11, 2017
  7. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
    Lennart was kind enough to still get me into the beta an hour ago, even though it's over (thanks a lot!). Without reading anything I loaded up the demo scene, added a dragon, lighting box and clicked the "Start all Vegetation Systems" button. Top: without Vegetation Studio, Bottom: with Vegetation Studio:



    What can I say ... I'm sold, this is a must have for me :D
     
    Last edited: Nov 12, 2017
  8. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Development update.

    I had a couple of quiet days after submitting to the asset store but work continues. I am currently doing some smaller fixes and feature changes. I will release this to the beta testers in a couple of days. Plan is to have a update ready to submit as soon as 1.0 hits the asset store.

    Vegetation Studio has a facebook page now :) I will post videos and bigger news there. The normal development updates will be here on the forum.

    https://www.facebook.com/VegetationStudio/

    Lennart
     
    DonLoquacious, antoripa, osss and 2 others like this.
  9. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
    Cool! Looking forward to it. I had to toy around some more, because this is so much fun :)



    And with a weather and day/night cycle system:

     
    camta005, Malbers, LittleMike and 4 others like this.
  10. Migueljb

    Migueljb

    Joined:
    Feb 27, 2008
    Posts:
    562
    Does vegetation studio support all of unity's lightmapping features in 2017.2 version? The best one for terrains and trees being distant shadow mask.
     
  11. Wurlox

    Wurlox

    Joined:
    Nov 1, 2015
    Posts:
    50
    @Rowlan That looks amazing. Can't wait for VS to hit the stores. :) - One Question: Is the grass that we see in your video from VS or is it an additional asset? I really like the look of it.

    Thanks and regards,
    Wurlox
     
    Rowlan and turboscalpeur like this.
  12. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi

    Did some testing. In order for Enlighten to bake the distance shadow mask it needs static objects in the scene. A first step would be to add the Scene vegetation Baker component to the same object as the VegetationSystem Component.
    Then select the trees you have and press the bake to scene button.



    You will then get a root GameObject with all the trees for the terrain as static children.



    Next, Unity requires the mesh renderers to be set to Lightmap Static. Select them and enable. if someone needs this I can probably add a setting to enable lightmap static on bake to scene.



    Make sure the directional light is set to mixed mode and that the distance shadowmask is configured correct.
    I did not have all night to wait for a bake and just tested with a single tree.



    This tree is now in the scene and we see it with a real-time shadow. My shadow distance in this example was 150 meter.



    Here is the same tree after shadow distance and now the distance shadowmask kicks in.



    Last step is to delete the baked trees and use Vegetation Studio to render as normal using instancing. You will now get shadows from the trees in the distance shadow mask. Make sure that your lighting is not set to automatic bake as rebaking without the baked trees in the scene would remove the shadows again.

    If anyone tries this on a full terrain let me know your results.

    Lennart
     
  13. turboscalpeur

    turboscalpeur

    Joined:
    Nov 29, 2015
    Posts:
    302
    It is from the RUSTIC Grass: http://u3d.as/DVZ

    and

    FERNS World: http://u3d.as/ivJ

    Both are mixed; I shared them since the begining of the Build of VS with @LennartJohansen to use in its Demo Scenes.
     
    lanrosta and antoripa like this.
  14. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
    Thanks. It's from VS. The screenshot difference above shows what you get from VS. And more, which I still have to check out. By the way, guess what, the trees are also from VS. I didn't expect that. And they are moving in the wind. It's very exciting.

    Edit: ah, I just checked @turboscalpeur 's comment. Good to know where to get more, thanks!
     
  15. MortenGulden

    MortenGulden

    Joined:
    Mar 15, 2015
    Posts:
    19
    @Rowlan Try putting touchbend on the dragon to have it bend the grass as it moves through :)
     
  16. Migueljb

    Migueljb

    Joined:
    Feb 27, 2008
    Posts:
    562
    Great to see that working Lennart. Definitely in VR right now we need every optimization working and baked shadows is a must and being able to have real-time shadows in the front and baked in the back with distant shadow mask is sorely needed now that unity finally has that working for us.
     
  17. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    695
    hi !! beautiful

    And very good animations too. Are they own or of any asset of the store ???

    regards
     
  18. BackwoodsGaming

    BackwoodsGaming

    Joined:
    Jan 2, 2014
    Posts:
    2,229
    Looks like @Malbers little dragons. If it is and they are using the animations that come with the little dragons, Malbers always does a great job with the animations he provides. And Malbers stuff is available in the asset store.
     
    ftejada likes this.
  19. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
    Thanks, but honestly I only combined assets, credit goes out to the asset developers. Yes, what @Shawn67 said. They are from Malbers. Excellent animations there, lots of praise from me. I'm totally looking forward to the upcoming big dragon combined with Vegetation Studio :)
     
    ftejada, Malbers and BackwoodsGaming like this.
  20. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
    Definitely have to try that. Also having particles (butterflies, pollen, etc) flying around. Lennart pointed out there's a runtime prefab spawner. I think I should read the documentation to see what's possible, haven't done that so far. Proof for me how awesome VS is :D
     
  21. Anon32

    Anon32

    Joined:
    Oct 11, 2013
    Posts:
    28
    Excited for this, looks like I can achieve the dense forests I have planned for my streamed world. Cheers :D
     
  22. lawsochi

    lawsochi

    Joined:
    Oct 24, 2016
    Posts:
    107
    Hi Lennart. I had the idea of a video for your asset, suddenly you will be interested. so, the script :-D
    in an empty project create terrain 2x2 km., paint with one texture, take any free tree Speedtree, and with the help of the button Mass Place Trees we place 15 000 trees, run, and ... get 15 fps)
    After that, add VS to this scene, run, and .... how much? 100? 500? FPS? In any case, this is magic;)
    I think it will be visual and easy to understand for everyone, and without the influence of other assets (weather, post-effect, etc.). such an idea. :)
     
  23. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    When I do a video on importing trees from the unity terrains I will add a FPS counter.
     
    lawsochi likes this.
  24. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Documentation.

    Hi. I have added a new section on the website. "3rd party setup". If we discover something special is needed to set up with another asset I will try to make small guides for the configuration needed.

    I just added the first. There is a small issue with Unity using to much GPU time on some projectors when setting up Vegetation Studio with Aquas water. I had a look at this with @dogmachris and we found an easy configuration to get around this.

    https://www.awesometech.no/index.php/configure-aquas-water/

    Lennart
     
    dogmachris, Mark_01 and Whippets like this.
  25. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    Hi Lennart. Has the option to change vegetation type been removed for good? Not a huge issue but the ability to change between trees and plants keeping all masks settings etc was quite useful.

    Another feature if it is feasible would be removing/enabling texture features of a vegetation package.
     
  26. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi.

    1. I will probably add the option to change type again, problem was as it was implemented it would no re initialize some settings based on shader, billboards etc. I removed it to not make problems. It was initially made for internal testing.

    2. You can change the texture mode from no textures, to 4,8 etc.
    Select the vegetation Package.

    Choose your new number of terrain textures and press the change button.

     
    AndyNeoman likes this.
  27. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    Excellent, thanks Lennart.

    I didn't realise you could change back and forth with the texture options, perfect.
     
  28. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
    Since my dragons are the Little Dragons: Sea from @Malbers I had to toy around with mentioned Aquas. I bought it on sale some time ago and didn't try much. Well, my fault coz from what I just learned it's awesome :) Good combination with Vegetation Studio. I also toyed around with Time of Day. And I had to check out the grass bending that you guys mentioned. It was just a quick test, but I see what you mean, have to check it out more and see the possibilities.

    In case anyone wants to see how VS looks like with Aquas and Time of Day:



    I'm totally looking forward to Black Friday next week, have to buy some more assets to go with VS :D
     
  29. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,200
    Add-On to above post, in case anyone wants to see the difference with and without VS:

     
  30. Wurlox

    Wurlox

    Joined:
    Nov 1, 2015
    Posts:
    50
    @turboscalpeur I already guessed that the grass is from your assets as it always looks good. Thanks for clarifying. Some of your assets are still on my buy-list. I will do that once I get VS :)

    @Rowlan Looks really amazing. I think you already implemented touch bending if I see it correct. Is there any setting to make the grass be bend longer after you stepped on it? Is it possible to achieve something like this:



    Thanks and regards,
    Wurlox
     
    turboscalpeur and ftejada like this.
  31. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Hi. Let me explain the touch bend. Vegetation studio includes a component called the TouchReactSystem. It is set up by default with Vegetation Studio. It is responsible for rendering selected meshes and colliders to a buffer on the GPU that is centered around a selected camera. This buffer will store the heightinfo of the rendered meshes and colliders.

    This buffer is then used by the grass/plant/flower shader where that will modify the vertices of the patches.



    There is a few ways to assign objects to this system.
    • Add a TouchReactCollider or a TouchReactMesh component to any GameObject.
    • Use the included TouchReact material on any mesh like a trail renderer or other and make sure this renders to the layer assigned to the Touch React collider. This layer must be excluded by the normal camera or you will see green areas like bellow
    • Enable the TouchReact checkbox on vegetation items. This is done in the example image below.

    Debug mode is enabled that lets you see all objects affecting the grass.

    In 1.0 release of Vegetation Studio this buffer has no memory. It will only move the grass away as long as something affecting grass is rendered to the buffer. In order to make tire tracks etc. you use persistent meshes like a trail renderer that stays a while after a wheel has passed. While you could leave footprint meshes/quads the same way the workflow is a bit hard.

    What can be done here is to make the TouchReact buffer double buffered. You basically swap the buffers every frame. Copy the content from the old buffer (with new camera position offset) to the new and in the process modify the height values. Letting grass raise up at a set rate etc. Then you render the colliders/meshes again as normal without clearing the buffer.

    Speed will be fast as this is just reading the old buffer before rendering the new, could be done in a compute shader pass or with a normal Graphics.Blit.

    This does have some limitations. The buffer is located in worldspace around the camera, if the camera was to move fast, out of the area and back it would not remember the state of bounce back. This I do not think is important. multiple buffers to keep history better would take a lot of memory.

    I did not have time to do a test on this, and really do not know how the end result will look. It is on my list to prototype this after some other features are completed.
     
  32. Wurlox

    Wurlox

    Joined:
    Nov 1, 2015
    Posts:
    50
    Thanks for your detailed explanation. It would be great if you can come up with a good solution for this in the future. However I will also check that out myself once VS is on the asset store. Something like burned grass (when a fire spell is hitting it) also comes to mind.

    Regards,
    Wurlox
     
  33. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Let me know and I can help you get started.

    For burning grass it could be done the same way but there is another way to get data to the shaders.
    Grass and plants are rendered instanced indirect and Vegetation Studio has a final compute shader pass where I do GPU frustum culling, LOD selection etc.

    In this pass I also to a final masking from a texture. This is located under the Run-Time mask in the GUI. Each grass patch samples this masks and includes/excludes based on some settings.

    This we could extend. Imagine you make a burning grass manager that handles updating a burn mask. You add an API for starting fire at positions. Every frame you process the mask with a compute shader, increasing intensity, increasing area etc.

    We could add a general function to sample a mask and pass the result value as a per instance variable to the shader using a structured buffer. I have a vector4 called ControlData ready for this kind of use now. This way you can have a grass shader with a burn effect based on a float you get from the ControlData passed to the shader.

    The entire grass patch will get the same value. No need to sample this per vertex and you just control the values in your burning grass manager.

    Here is a video with the run-time mask in use. It samples the generated lava mask and excludes grass patches.

     
    Anon32, Rowlan and blitzvb like this.
  34. frankslater

    frankslater

    Joined:
    May 9, 2016
    Posts:
    213
    Great work guys! Does anyone know about how long it takes to hit the asset store after submission?
     
  35. SirTwistedStorm

    SirTwistedStorm

    Joined:
    Sep 20, 2015
    Posts:
    192
    On average it takes 3 - 4 weeks.
     
    frankslater likes this.
  36. Wurlox

    Wurlox

    Joined:
    Nov 1, 2015
    Posts:
    50
    I already checked that video. I'm gonna experiment with those features a bit and see what I can come up with. Looking forward to that. :)
     
  37. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Development update

    There is some changes to the Billboard system. 2 new color settings exposed.

    Tint color is applied to the shader and allows for fine adjustments to the billboards colors. For speedtrees this tint happens in addition to the per tree HUE adjustment.

    Atlas backrgound color allows you to fine tune the background color used in the atlas, this can help reduce the black outlines caused by the mipmaps on far distances. Before reducing the cutoff was the only way to combat this.

    I have also done the first step in allowing 3rd party shaders to provide a custom atlas render shader. This is usefull where tree shaders has custom color code etc that should be applied to the atlas in addition to the diffuse texture.

    This will be included in the first update after asset store approves.



    Lennart
     
  38. Dionysos1111

    Dionysos1111

    Joined:
    Feb 14, 2016
    Posts:
    39
    Where can i buy this?? I can't find it anywhere on the asset store.
     
    S4G4N likes this.
  39. S4G4N

    S4G4N

    Joined:
    Mar 13, 2013
    Posts:
    3,213
    It has been submitted, awaiting approval, then it will be available for SALE
     
    antoripa and LittleMike like this.
  40. Dionysos1111

    Dionysos1111

    Joined:
    Feb 14, 2016
    Posts:
    39
    Ok cool, can't wait for it. I didn't know it takes so long before an asset get approved. Any chance you know when it's gonna be available?
     
    S4G4N likes this.
  41. S4G4N

    S4G4N

    Joined:
    Mar 13, 2013
    Posts:
    3,213
    Hey @Dionysos1111
    I do not know, but it has been submitted more then a week ago as far as I know, so it could be any day now
    We all excited with your for this upcoming release :):):)
     
    antoripa, Mark_01 and Dionysos1111 like this.
  42. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Billboard update.

    The background color for the atlas seems to reduce the black outline on mipmaps but I did not like having to manually adjust it. The billboard renderer will now create a AlphaPadding for the texture while generating the atlas. I am doing this in a compute shader. This gives a much better samlpe color for MipMaps in the distance since it have an averaged color to sample.

    Background atlas color is removed again :)

    Before


    and after. The first image looking more colorful is just a trick of Photoshop using the alpha different than the shader.



    I will add the same system to help on the edges of the VegetationColorMaskCreator component
     
  43. Anon32

    Anon32

    Joined:
    Oct 11, 2013
    Posts:
    28
    Would this asset (Dynamic Decals: https://www.assetstore.unity3d.com/en/#!/content/76410) be a candidate for combatability with your touch bend? It uses GPU instancing. I'd like to use it for spells to get the same effects Wurlox is after. If this works, these two assets would be a match made in heaven lol. Another example would be blood drips that apply to grass which bends it based on amount spilled. Is it a float amount 0-1 for bending or will it have 3 set bends.

    Also would this be a replacement for AFS (advance foliage shader), or do you see it being compatable as well?
     
    antoripa likes this.
  44. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    I have not tested the asset, but you could probably get it to work. The decals will not affect the touch bend, you would have to produce a mesh or collider in the shape of the affected area and then render this to the touch buffer.

    Unity has some problems using projectors on instanced meshes, but i think g-buffer decals in deferred rendering would work nice on top of vegetation.

    AFS should work with Vegetation Studio, but the bend functionality is implemented different and will not work together.
     
    Anon32 and antoripa like this.
  45. Alverik

    Alverik

    Joined:
    Apr 15, 2016
    Posts:
    417
    Hi, does anyone know what I need to do to the default SpeedTree shader to allow trees to work with the Instanced Indirect option? I tried following the guide in the website and added the pragmas and include line into the passes, but the changes only work for the grass, whereas for trees most of the tree's body disappears. I then tried to add the same changes to the passes marked as SM2.0 but same...

    Anyway, I still just know very basic things about shaders, so any advice will be greatly appreciated.

    Code (CSharp):
    1. // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
    2.  
    3. Shader "Custom/Nature/SpeedTree - Instanced Indirect"
    4. {
    5.     Properties
    6.     {
    7.         _Color ("Main Color", Color) = (1,1,1,1)
    8.         _HueVariation ("Hue Variation", Color) = (1.0,0.5,0.0,0.1)
    9.         _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
    10.         _DetailTex ("Detail", 2D) = "black" {}
    11.         _BumpMap ("Normal Map", 2D) = "bump" {}
    12.         _Cutoff ("Alpha Cutoff", Range(0,1)) = 0.333
    13.         [MaterialEnum(Off,0,Front,1,Back,2)] _Cull ("Cull", Int) = 2
    14.         [MaterialEnum(None,0,Fastest,1,Fast,2,Better,3,Best,4,Palm,5)] _WindQuality ("Wind Quality", Range(0,5)) = 0
    15.     }
    16.  
    17.     // targeting SM3.0+
    18.     SubShader
    19.     {
    20.         Tags
    21.         {
    22.             "Queue"="Geometry"
    23.             "IgnoreProjector"="True"
    24.             "RenderType"="Opaque"
    25.             "DisableBatching"="LODFading"
    26.         }
    27.         LOD 400
    28.         Cull [_Cull]
    29.  
    30.         CGPROGRAM
    31.             #pragma surface surf Lambert vertex:SpeedTreeVert nodirlightmap nodynlightmap noshadowmask dithercrossfade fullforwardshadows
    32.             #pragma target 3.0
    33.             #pragma multi_compile_vertex __ LOD_FADE_PERCENTAGE
    34.             #pragma instancing_options assumeuniformscaling lodfade maxcount:50 procedural:setup
    35.             #pragma multi_compile GPU_FRUSTUM_ON __
    36.             #pragma shader_feature GEOM_TYPE_BRANCH GEOM_TYPE_BRANCH_DETAIL GEOM_TYPE_FROND GEOM_TYPE_LEAF GEOM_TYPE_MESH
    37.             #pragma shader_feature EFFECT_BUMP
    38.             #pragma shader_feature EFFECT_HUE_VARIATION
    39.             #define ENABLE_WIND
    40.             #include "SpeedTreeCommon.cginc"
    41.             #include "VS_indirect.cginc"
    42.  
    43.             void surf(Input IN, inout SurfaceOutput OUT)
    44.             {
    45.                 SpeedTreeFragOut o;
    46.                 SpeedTreeFrag(IN, o);
    47.                 SPEEDTREE_COPY_FRAG(OUT, o)
    48.             }
    49.         ENDCG
    50.  
    51.         Pass
    52.         {
    53.             Tags { "LightMode" = "ShadowCaster" }
    54.  
    55.             CGPROGRAM
    56.                 #pragma vertex vert
    57.                 #pragma fragment frag
    58.                 #pragma target 3.0
    59.                 #pragma multi_compile_vertex __ LOD_FADE_PERCENTAGE LOD_FADE_CROSSFADE
    60.                 #pragma multi_compile_fragment __ LOD_FADE_CROSSFADE
    61.                 #pragma multi_compile_instancing
    62.                 #pragma instancing_options assumeuniformscaling lodfade maxcount:50 procedural:setup
    63.                 #pragma multi_compile GPU_FRUSTUM_ON __
    64.                 #pragma shader_feature GEOM_TYPE_BRANCH GEOM_TYPE_BRANCH_DETAIL GEOM_TYPE_FROND GEOM_TYPE_LEAF GEOM_TYPE_MESH
    65.                 #pragma multi_compile_shadowcaster
    66.                 #define ENABLE_WIND
    67.                 #include "SpeedTreeCommon.cginc"
    68.                 #include "VS_indirect.cginc"
    69.  
    70.                 struct v2f
    71.                 {
    72.                     V2F_SHADOW_CASTER;
    73.                     #ifdef SPEEDTREE_ALPHATEST
    74.                         float2 uv : TEXCOORD1;
    75.                     #endif
    76.                     UNITY_VERTEX_INPUT_INSTANCE_ID
    77.                     UNITY_VERTEX_OUTPUT_STEREO
    78.                 };
    79.  
    80.                 v2f vert(SpeedTreeVB v)
    81.                 {
    82.                     v2f o;
    83.                     UNITY_SETUP_INSTANCE_ID(v);
    84.                     UNITY_TRANSFER_INSTANCE_ID(v, o);
    85.                     UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
    86.                     #ifdef SPEEDTREE_ALPHATEST
    87.                         o.uv = v.texcoord.xy;
    88.                     #endif
    89.                     OffsetSpeedTreeVertex(v, unity_LODFade.x);
    90.                     TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
    91.  
    92.                     return o;
    93.                 }
    94.  
    95.                 float4 frag(v2f i) : SV_Target
    96.                 {
    97.                     UNITY_SETUP_INSTANCE_ID(i);
    98.                     #ifdef SPEEDTREE_ALPHATEST
    99.                         clip(tex2D(_MainTex, i.uv).a * _Color.a - _Cutoff);
    100.                     #endif
    101.                     UNITY_APPLY_DITHER_CROSSFADE(i.pos.xy);
    102.                     SHADOW_CASTER_FRAGMENT(i)
    103.                 }
    104.             ENDCG
    105.         }
    106.  
    107.         Pass
    108.         {
    109.             Tags { "LightMode" = "Vertex" }
    110.  
    111.             CGPROGRAM
    112.                 #pragma vertex vert
    113.                 #pragma fragment frag
    114.                 #pragma target 3.0
    115.                 #pragma multi_compile_fog
    116.                 #pragma multi_compile_vertex __ LOD_FADE_PERCENTAGE LOD_FADE_CROSSFADE
    117.                 #pragma multi_compile_fragment __ LOD_FADE_CROSSFADE
    118.                 #pragma multi_compile_instancing
    119.                 #pragma instancing_options assumeuniformscaling lodfade maxcount:50 procedural:setup
    120.                 #pragma multi_compile GPU_FRUSTUM_ON __
    121.                 #pragma shader_feature GEOM_TYPE_BRANCH GEOM_TYPE_BRANCH_DETAIL GEOM_TYPE_FROND GEOM_TYPE_LEAF GEOM_TYPE_MESH
    122.                 #pragma shader_feature EFFECT_HUE_VARIATION
    123.                 #define ENABLE_WIND
    124.                 #include "SpeedTreeCommon.cginc"
    125.                 #include "VS_indirect.cginc"
    126.  
    127.                 struct v2f
    128.                 {
    129.                     UNITY_POSITION(vertex);
    130.                     UNITY_FOG_COORDS(0)
    131.                     Input data      : TEXCOORD1;
    132.                     UNITY_VERTEX_INPUT_INSTANCE_ID
    133.                     UNITY_VERTEX_OUTPUT_STEREO
    134.                 };
    135.  
    136.                 v2f vert(SpeedTreeVB v)
    137.                 {
    138.                     v2f o;
    139.                     UNITY_SETUP_INSTANCE_ID(v);
    140.                     UNITY_TRANSFER_INSTANCE_ID(v, o);
    141.                     UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
    142.                     SpeedTreeVert(v, o.data);
    143.                     o.data.color.rgb *= ShadeVertexLightsFull(v.vertex, v.normal, 4, true);
    144.                     o.vertex = UnityObjectToClipPos(v.vertex);
    145.                     UNITY_TRANSFER_FOG(o,o.vertex);
    146.                     return o;
    147.                 }
    148.  
    149.                 fixed4 frag(v2f i) : SV_Target
    150.                 {
    151.                     UNITY_SETUP_INSTANCE_ID(i);
    152.                     SpeedTreeFragOut o;
    153.                     SpeedTreeFrag(i.data, o);
    154.                     UNITY_APPLY_DITHER_CROSSFADE(i.vertex.xy);
    155.                     fixed4 c = fixed4(o.Albedo, o.Alpha);
    156.                     UNITY_APPLY_FOG(i.fogCoord, c);
    157.                     return c;
    158.                 }
    159.             ENDCG
    160.         }
    161.     }
    162.  
    163.     // targeting SM2.0: Normal-mapping, Hue variation and Wind animation are turned off for less instructions
    164.     SubShader
    165.     {
    166.         Tags
    167.         {
    168.             "Queue"="Geometry"
    169.             "IgnoreProjector"="True"
    170.             "RenderType"="Opaque"
    171.             "DisableBatching"="LODFading"
    172.         }
    173.         LOD 400
    174.         Cull [_Cull]
    175.  
    176.         CGPROGRAM
    177.             #pragma surface surf Lambert vertex:SpeedTreeVert nodirlightmap nodynlightmap noshadowmask fullforwardshadows
    178.             #pragma multi_compile_vertex __ LOD_FADE_PERCENTAGE
    179.             #pragma instancing_options assumeuniformscaling lodfade maxcount:50 procedural:setup
    180.             #pragma multi_compile GPU_FRUSTUM_ON __
    181.             #pragma shader_feature GEOM_TYPE_BRANCH GEOM_TYPE_BRANCH_DETAIL GEOM_TYPE_FROND GEOM_TYPE_LEAF GEOM_TYPE_MESH
    182.             #include "SpeedTreeCommon.cginc"
    183.             #include "VS_indirect.cginc"
    184.  
    185.             void surf(Input IN, inout SurfaceOutput OUT)
    186.             {
    187.                 SpeedTreeFragOut o;
    188.                 SpeedTreeFrag(IN, o);
    189.                 SPEEDTREE_COPY_FRAG(OUT, o)
    190.             }
    191.         ENDCG
    192.  
    193.         Pass
    194.         {
    195.             Tags { "LightMode" = "ShadowCaster" }
    196.  
    197.             CGPROGRAM
    198.                 #pragma vertex vert
    199.                 #pragma fragment frag
    200.                 #pragma multi_compile_vertex __ LOD_FADE_PERCENTAGE
    201.                 #pragma instancing_options assumeuniformscaling lodfade maxcount:50 procedural:setup
    202.                 #pragma multi_compile GPU_FRUSTUM_ON __
    203.                 #pragma shader_feature GEOM_TYPE_BRANCH GEOM_TYPE_BRANCH_DETAIL GEOM_TYPE_FROND GEOM_TYPE_LEAF GEOM_TYPE_MESH
    204.                 #pragma multi_compile_shadowcaster
    205.                 #include "SpeedTreeCommon.cginc"
    206.                 #include "VS_indirect.cginc"
    207.  
    208.                 struct v2f
    209.                 {
    210.                     V2F_SHADOW_CASTER;
    211.                     #ifdef SPEEDTREE_ALPHATEST
    212.                         float2 uv : TEXCOORD1;
    213.                     #endif
    214.                 };
    215.  
    216.                 v2f vert(SpeedTreeVB v)
    217.                 {
    218.                     v2f o;
    219.                     #ifdef SPEEDTREE_ALPHATEST
    220.                         o.uv = v.texcoord.xy;
    221.                     #endif
    222.                     OffsetSpeedTreeVertex(v, unity_LODFade.x);
    223.                     TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
    224.                     return o;
    225.                 }
    226.  
    227.                 float4 frag(v2f i) : SV_Target
    228.                 {
    229.                     #ifdef SPEEDTREE_ALPHATEST
    230.                         clip(tex2D(_MainTex, i.uv).a * _Color.a - _Cutoff);
    231.                     #endif
    232.                     SHADOW_CASTER_FRAGMENT(i)
    233.                 }
    234.             ENDCG
    235.         }
    236.  
    237.         Pass
    238.         {
    239.             Tags { "LightMode" = "Vertex" }
    240.  
    241.             CGPROGRAM
    242.                 #pragma vertex vert
    243.                 #pragma fragment frag
    244.                 #pragma multi_compile_fog
    245.                 #pragma multi_compile_vertex __ LOD_FADE_PERCENTAGE
    246.                 #pragma instancing_options assumeuniformscaling lodfade maxcount:50 procedural:setup
    247.                 #pragma multi_compile GPU_FRUSTUM_ON __
    248.                 #pragma shader_feature GEOM_TYPE_BRANCH GEOM_TYPE_BRANCH_DETAIL GEOM_TYPE_FROND GEOM_TYPE_LEAF GEOM_TYPE_MESH
    249.                 #include "SpeedTreeCommon.cginc"
    250.                 #include "VS_indirect.cginc"
    251.  
    252.                 struct v2f
    253.                 {
    254.                     UNITY_POSITION(vertex);
    255.                     UNITY_FOG_COORDS(0)
    256.                     Input data      : TEXCOORD1;
    257.                     UNITY_VERTEX_OUTPUT_STEREO
    258.                 };
    259.  
    260.                 v2f vert(SpeedTreeVB v)
    261.                 {
    262.                     v2f o;
    263.                     UNITY_SETUP_INSTANCE_ID(v);
    264.                     UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
    265.                     SpeedTreeVert(v, o.data);
    266.                     o.data.color.rgb *= ShadeVertexLightsFull(v.vertex, v.normal, 2, false);
    267.                     o.vertex = UnityObjectToClipPos(v.vertex);
    268.                     UNITY_TRANSFER_FOG(o,o.vertex);
    269.                     return o;
    270.                 }
    271.  
    272.                 fixed4 frag(v2f i) : SV_Target
    273.                 {
    274.                     SpeedTreeFragOut o;
    275.                     SpeedTreeFrag(i.data, o);
    276.                     fixed4 c = fixed4(o.Albedo, o.Alpha);
    277.                     UNITY_APPLY_FOG(i.fogCoord, c);
    278.                     return c;
    279.                 }
    280.             ENDCG
    281.         }
    282.     }
    283.  
    284.     FallBack "Transparent/Cutout/VertexLit"
    285.     CustomEditor "SpeedTreeMaterialInspector"
    286. }
     
    antoripa likes this.
  46. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    If you look at the guide you can see that right now only single submesh meshes is supported. There is a bug in unity instanced indirect that messes up the materials a bit if you render anything than submesh 0. I protoyped a workaround extracting the submeshes and rendering them one by one, speed will be the same but I need to make the system generic before I enable this.

    I do not think you will notice a big increase in speed rendering trees like this. The number of instances is normally less than the 1023 limit of normal instancing and will be drawn in a single call anyway. What you save extra is the time to transfer the matrix array to the GPU.

    Where instanced indirect helps is the high volume meshes like smaller plants, grass, rocks...
     
    Alverik, Mark_01 and antoripa like this.
  47. Alverik

    Alverik

    Joined:
    Apr 15, 2016
    Posts:
    417
    Oh, thanks. Sorry, I forgot about that. I was just trying it with some random speedtrees I had. Well, as long as it works on the grass I'm happy (I felt the big speed up). But I'm working in VR so I though it didn't hurt to ask, lol (since speed matters).

    Anyway, now I'm talking about VR... does anyone have any tips when it comes to using vegetation in VR? I noticed most of the speedtree trees and 2D grass I had look rather bad/fake in VR, so I've been considering using trees with geometry leaves instead of card/plane leaves, just not sure if that'll be a lot slower. Guess we could also make the trees very tall so the player can't see the leaves up close (I think I've seen that done in some other VR games). Do you guys have any ideas or advice?
     
  48. Anon32

    Anon32

    Joined:
    Oct 11, 2013
    Posts:
    28
    So excited to try these out! I'd use the spells collider to apply bend/masks, then decals overlay surrounding vegitation, like a burn or frost effect. I'ts not that important for decals to affect bending, as long as they can be applied over top. I could always have a cone mesh enabled on impact to zone mask/bend, right? Would scaling, and or rotating a mesh effect the bend and masking in real time?

    Also I think your asset will be available November 20th :D ... I'm pretty sure I saw your path demo displayed on the youtube video that was on this page.. dont know where it went :eek: https://go.unity.com/black-friday-2017-teaser/ but im 95% sure it was the path from your demo.
     
    Alverik likes this.
  49. SirTwistedStorm

    SirTwistedStorm

    Joined:
    Sep 20, 2015
    Posts:
    192
    I agree that it should be available next week but doubt it will be in the 50% sale as the price is already reduced to $75 for launch instead of $95. One thing that could happen is because of the sale they wait another week.
    https://www.assetstore.unity3d.com/en/#!/list/black-friday-2017

     
    Rowlan and Alverik like this.
  50. Anon32

    Anon32

    Joined:
    Oct 11, 2013
    Posts:
    28
    No, same. I dont think it would be, but the first time I went to the link it was nothing but a title for black friday, then it linked to the asset store list, then it linked back to the teaser but only had a small youtube video. Which showed the path being created next to the viking hut. Maybe they retracted it for this reason. I can't find the video anywhere xD.. Was only up for a day or so. Conspiracy D:
     
    MortenGulden likes this.
Thread Status:
Not open for further replies.