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,332
    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,427
    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:
    786
    @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,427
    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,427
    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,427
    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,427
    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,427
    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:
    167
    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,427
    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,095
    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,427
    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.
unityunity