Search Unity

Advanced foliage shader [released]

Discussion in 'Assets and Asset Store' started by larsbertram1, Apr 24, 2012.

  1. nova234

    nova234

    Joined:
    Feb 19, 2018
    Posts:
    17
    Any new Information, when I can use Tropical Forest Pack with Unity 2019 LWRP. Its based on your shader and the dev is waiting too. My boss is not switching back from LWRP and I don't wont to lose month of hard work. I would be really thanks full if I get any info s when you start to work on it and when you release it.
     
  2. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,350
    Hi @nova234, Waiting and looking forward to the LWRP & HDRP support of the CTI shaders, but it is a complete rewrite since they each handle shading completely different from SRP. Work has started on it but it is a lot of work. So hopefully something we will see soon but not something that can be rushed.

    When the support is out though will get you an updated TFP version to you and on the store as soon as possible.
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,592
    it is based on the cti shaders. this is the afs thread. so you are at the wrong place...
     
  4. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    788
    @larsbertram1

    Out of curiosity, can you tell me what exactly AFS is using modified deferred library include file (Afs_DeferredLibrary.cginc) for? I'm not seeing any obvious AFS-specific changes in there, but I need to merge it with another asset that actually does a lot of changes there (NGSS). If there are changes, I would've really appreciated them being wrapped in "// AFS" comments! :)

    The only thing I noticed is an additional shadow strength out parameter in
    UnityDeferredCalculateLightParams. Is that the only change?
     
    Last edited: Aug 2, 2019
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,592
    i think so, yes.
     
  6. Jellonek

    Jellonek

    Joined:
    Jan 3, 2018
    Posts:
    2
    Hello.

    I need to add to AfsFoliageShaderLite.shader: _DetailAlbedoMap ("Detail Albedo x2", 2D) = "gray" {}

    half3 detailAlbedo = tex2D (_DetailAlbedoMap, TRANSFORM_TEX((_UVSec == 0) ? IN.uv_MainTex : IN.uv2_Tex, _DetailAlbedoMap)).rgb;

    and it's working perfectly for TEXCOORD0, but for TEXCOORD1 not.

    Any sugestions why?
     
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,592
    it should be: IN.uv2_DetailAlbedoMap, shouldn't it?
    and you have to declare it in the Input structure.
     
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,592
    from the docs:
    The input structure Input generally has any texture coordinates needed by the shader. Texture coordinates must be named “uv” followed by texture name (or start it with “uv2” to use second texture coordinate set).
    https://docs.unity3d.com/Manual/SL-SurfaceShaders.html

    and if you can't solve the problem with _DetailAlbedoMap_ST and TRANSFORM_TEX, do not use TRANSFORM_TEX. feed in your own tiling param (as float or float2).
    IN.uv_MainTex should already have applied the TRANSFORM_TEX anyway.
     
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,592
    this just works for me:

    Shader "Custom/NewSurfaceShader" {
    Properties {
    _Color ("Color", Color) = (1,1,1,1)
    _MainTex ("Albedo (RGB)", 2D) = "white" {}
    _Glossiness ("Smoothness", Range(0,1)) = 0.5
    _Metallic ("Metallic", Range(0,1)) = 0.0

    _DetailAlbedoMap ("DetailAlbedo (RGB)", 2D) = "white" {}
    _UVSec ("UV channel", Float) = 0
    }
    SubShader {
    Tags { "RenderType"="Opaque" }
    LOD 200

    CGPROGRAM
    // Physically based Standard lighting model, and enable shadows on all light types
    #pragma surface surf Standard fullforwardshadows

    // Use shader model 3.0 target, to get nicer looking lighting
    #pragma target 3.0

    sampler2D _MainTex;
    sampler2D _DetailAlbedoMap;
    float _UVSec;

    struct Input {
    float2 uv_MainTex;
    float2 uv2_DetailAlbedoMap;
    };

    half _Glossiness;
    half _Metallic;
    fixed4 _Color;

    // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
    // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
    // #pragma instancing_options assumeuniformscaling
    UNITY_INSTANCING_CBUFFER_START(Props)
    // put more per-instance properties here
    UNITY_INSTANCING_CBUFFER_END

    void surf (Input IN, inout SurfaceOutputStandard o) {
    // Albedo comes from a texture tinted by color
    fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
    o.Albedo = c.rgb;

    float2 detailUV = (_UVSec == 0) ? IN.uv_MainTex : IN.uv2_DetailAlbedoMap;
    o.Albedo += tex2D (_DetailAlbedoMap, detailUV);

    // Metallic and smoothness come from slider variables
    o.Metallic = _Metallic;
    o.Smoothness = _Glossiness;
    o.Alpha = c.a;
    }
    ENDCG
    }
    FallBack "Diffuse"
    }
     
  10. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,592
    i just focused on the uvs here.
    what you do with the sample is up to you.

    i don't know what this Lite shader is...

    do not use TRANSFORM_TEX here.
     
    Jellonek likes this.
  11. Jellonek

    Jellonek

    Joined:
    Jan 3, 2018
    Posts:
    2
    I was talking about: Shader "AFS/Foliage Shader Lite".

    And now it is working correctly, one small mistake ! Thank you very much and have, a nice day.
     
  12. Radu392

    Radu392

    Joined:
    Jan 6, 2016
    Posts:
    192
    Hello, I recently bought this pack and I'm having an issue with the 'Foliage Shader v4'.



    I'd like to put some detail meshes onto my terrain. However, the detail mesh using that shader is red (grass on the left). The grass on the right is a detail mesh using the standard shader and the one in the middle is gameobject using the foliage shader. This is with a completely virgin terrain.



    Also the wind affects the gameobject and detail mesh differently. The detail mesh moves all of the leaves from bottom to top, but the gameobject moves only the higher parts of the grass which is the correct behaviour. (imagine a whole human moving as opposed to its upper body) How can I get the same result with the terrain? Playing with the wind settings on the 'SetupAdvancedFoliageShader' doesn't get me the same result as the gameobject.
     
  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,592
    i do not see any red mesh and adding them to the terrain needs you to add them to the terrain and paint them using the tools built in to the terrain...
     
  14. mattis89

    mattis89

    Joined:
    Jan 10, 2017
    Posts:
    1,099
    Hello! Does this shader work on naturemanufacture assets? And also, does bending work when rendering with VS Pro? @larsbertram1
     
  15. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,592
    unfortunately not without painting new vertex colors.
    you will have to set vertex color green to 0.0 or to very low values at the outer edges of the leaves.
    you may set vertex color red to entire shells to get some variation depending on the model.
    you may use the included foliage tool to set primary and secondary bending
    only if the you spawn the plant as game object when it gets close to the camera. it relies on physics and materialpropertyblocks. vs pro displacement is not suitable for anything else but grass afaik.
    .
     
    mattis89 likes this.
  16. bobAZ2019

    bobAZ2019

    Joined:
    Mar 28, 2019
    Posts:
    11
    hi,

    i just bought this in December 2019.
    just wondering when will AFS support URP?
     
  17. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,592
    i have no eta yet – but 2 other assets which support URP:
    Advanced Terrain Grass [>] (grass and foliage shaders)
    Lux URP Essentials [>] (grass, foliage, tree creator trees)

    which shader do you want to use with urp? and which feature do you need?
     
  18. bobAZ2019

    bobAZ2019

    Joined:
    Mar 28, 2019
    Posts:
    11
    i bought both of your Advanced Terrain Grass & Lux URP Essentials. excellent stuff.
    i also bought Advanced Foliage Shaders v.5 & Tropical Forest Pack (TFP).
    actually, i bought TFP because it needs AFS.

    anyway, the stuff i need is the URP shader that will work with TFP.
     
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,592
    this is a completely different story then. the tropical forest pack uses cti – which already supports urp.
    ask baldinoboy for a proper package.
     
  20. TaylorMonkeyAl

    TaylorMonkeyAl

    Joined:
    Nov 13, 2019
    Posts:
    2
    We're using AFS in an upcoming project and I'm currently having some issues with the Child Combine script when using the AFS Foliage shader and Legacy Vertex Color Bending.

    Instead of the foliage behaving like it would before combining, it seems to lose wind movement aside from what looks like turbulence. Combine Children with Vertex Color Bending seems fine (or at least better) from what I can tell.

    Does Combine Children properly support the AFS Foliage shader with Legacy Vertex Colors?
     
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,592
    it should! altho i do not recommend to use legacy vertex colors at all.
     
  22. TaylorMonkeyAl

    TaylorMonkeyAl

    Joined:
    Nov 13, 2019
    Posts:
    2
    Do you mind running a quick test on your end to see if combining several instances of a tree (like the banana tree) with the shader set to use legacy vertex colors produces the same/similar movement as when it's not combined?
     
  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    5,592
    it might not!
    if gpu instancing is disabled and dynamic or static batching are enabled the foliage shader will take the wave size into account as specified in the setup script because it is not clear if the pivot of the mesh the vertex shader is operating on is the pivot of a real plant. so the shader does not do any calculations based on he pivot but uses some world space noise (waves).
    if you combine meshes the combine children script will bake the pivots into the mesh. so you alwas get the "better" bending based on pivots.

    but i did a quick test, opened the overview demo, created a new game object, parented 3 copies of the banana legacy colors under it and added the combine children script: hitting play the bending of the combined mesh jsut looks fine.
     
unityunity