Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Advanced foliage shader [released]

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

  1. laurenstjong

    laurenstjong

    Joined:
    Feb 28, 2013
    Posts:
    6
    Hello Lars

    I just bought your Advanced Foliage Shader 2.03 pack and I came across a little bit of a glitch.

    It seems that the self shadow model is not updated with the wind deformation or am I totally wrong?

    $2013 09 01 - AFS v3 Artifacts.jpg

    Hope this is a littlebit clear.

    thank you
    Laurens
     
  2. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    637
    This was probably already answered but does foliage allow for self shadowing onto other foliage?
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    hi laurens,

    i hope you are totally wrong ;-) as the wind animation is rendered in both: the shadow caster and shadow collector pass. so self shadowing should always work correctly.
    from what i can see it the screenshoot there are a lot of different possible reasons which cause the "problem" you are facing.
    first: unlike the basic lambert the foliage shader uses wrapped around diffuse lighting plus translucency.
    second: you seem to not have not set up any textures. if i create a simple cylinder and just add the foliage shader to it lighting looks terrible. but as soon as i add any texture it looks ok.
    third: do not underestimate the inaccuracy of unity’s shadow. i guess what you call "correct selfshadowing" on the model using the lambert lighting are no shadows but just the regular lighting as the faces point away from the light source. it should look the same if you deactivate real time shadows.

    so i would ask you to add texture to your model and try again.
    please let me know if this fixes your problem.

    lars


    btw. using the shaders on tree like models will probably not give you the desired result as the fact that the shader uses just one input to control primary a secondary bending will become quite obviously.
     
    Last edited: Sep 2, 2013
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    hi blueivy,

    either "self shadowing" or casting shadows onto other foliage it should be...
    and yes both is supported as the shader is fully integrated into unity’s lighting pipeline. so game objects using the shaders will cast and receive shadows, whereas foliage placed within the terrain engine will only receive shadows. but that is unfortunately nothing i can change as plants placed within the terrain engine simply seem to be ignored when it comes to shadow casting.

    please have a look at the ground lighting demo to see all lighting features:
    http://dl.dropboxusercontent.com/u/..._v2_groundlighting/afs_v2_groundlighting.html

    lars
     
    Last edited: Sep 3, 2013
  5. laurenstjong

    laurenstjong

    Joined:
    Feb 28, 2013
    Posts:
    6
    Hello Lars,

    Thank you for the quick reply!

    I'm sorry to bother you again though, but I checked this self shading thing again and I cannot get arround the fact that there is something funky going on. I also noticed the same thing in the web player scene you posted in the previous post.

    It could be because of the wrap arround lighting but i would just like to show you a little example project I made to check if it's only on my personal PC ( to exlude that it is a local hardware thing). If you could import the package I sent you in a clean unity project I set up a demo scene to show you what I mean.

    Hope this is clear.

    Thank you very much
    Laurens
     

    Attached Files:

    Last edited: Sep 3, 2013
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    hi laurens,

    i had a look into your issue and saw what you mean.
    it is a – let’s call it feature ;-)

    and all you have to do in order to get correct shadows received by the foliage is to assign a proper texture to the slot named: "Normal (GA) Trans(R) Spec(B)". it does not have to be a perfect texture. just make sure that the blue channel is set to rather dark values or better even black (a simple "yellow" texture will be enough).

    when using a "real" texture blue stores the spec values which are mostly around 0.0 – so i have never really realized this problem – especially as it only occurs in forward rendering which i do not use.
    but thanks for pointing this out. i will work on a workaround for the next release.

    i have also noticed some "shadow acne" on the models but i doubt that this is something that can be enhanced by the shader. you might have to raise the shadow bias (...) but i would suggest to make your models more curved and add depth to the "fern_geo" leaves. right now they are simply flat.

    cheers,
    lars


    p.s.: please read your pm!
     
    Last edited: Sep 3, 2013
  7. HamiltonAFJr

    HamiltonAFJr

    Joined:
    Aug 28, 2013
    Posts:
    3
    Hi Lars! I'm enjoying very much the shaders, finally I have confidence in working out of the terrain system.
    But I`ve encountered a glitch, when we use Screen Space Ambient Occlusion we can see the sampling trough the geometry with your shaders applied, take a look:
    $Captura de Tela 2013-09-03 às 19.59.17.jpg

    Without SSAO:
    $Captura de Tela 2013-09-03 às 19.59.26.jpg
     
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    hi Hamilton,

    that looks quite annoying!
    but i am a bit clueless as i have tested the shader with almost all built in image effects and of course ssao:
    it works perfectly for me both in deferred and forward rendering – but i can only test it in unity 3.5 pro…

    but i have to say that it does not look like ssao coming through the plane at all – but like some kind of inverted shading!
    totally strange and i have never seen something like this before.

    if you could see the generated ssao it would be a depth test error. but you can’t as a depth test error would look like this:
    $ssao.jpg

    nevertheless please check if the "resources" folder is in your project. it contains the tweaked shaders which usually should make ssao work…
    does it look the same if you assign a texture to the plane’s material?
    which shader (there is a bunch of in the package) does the plane use?
    which version of unity do you use? and which lighting pass?

    and in order to test if it is a shader bug or a unity bug please create a tree...
    set up a material for the leaves and add some simple planes to the tree.
    the tree creator will generate 2 materials of which the "optimized tree leaves" is very much similar to those of the foliage shaders.
    drag that material on top of the plane and check how it looks.

    if it looks the same it is either a unity bug – or a bug in your driver’s software.

    sorry for the inconvenience,

    lars
     
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    and here is how it looks in unity 3.5 and should look for you too:

    $ssao_u3.jpg

    ssao just at the edges: fine.
    and nothing shines through but the shadows.

    lars
     
  10. HamiltonAFJr

    HamiltonAFJr

    Joined:
    Aug 28, 2013
    Posts:
    3
    Hello Lars. Sorry for the lack of infos. I'm o a Macbook Pro early 2011, OSX 10.8.4 Mountain Lion, Unity 4.1.5.f1, Advanced Foliage Shader v2.03.
    The project that I want to use these shaders is not reliable at all, the guys that were working on it left the project and now I have to fix lots of things and I'm not even a programmer.
    Anyway, I've created a new and clean project and imported the shaders, created a camera and added a bunch of image effects. It returned no problems with the Advanced Foliage Shader nor the Advanced Foliage Shader Atlas.

    $Captura de Tela 2013-09-04 às 00.12.21.jpg

    But when i changed to the Advanced Foliage Shader Atlas noBending this glitch showed up in both scene and game view:

    $Captura de Tela 2013-09-04 às 00.29.03.jpg
     
    Last edited: Sep 4, 2013
  11. HamiltonAFJr

    HamiltonAFJr

    Joined:
    Aug 28, 2013
    Posts:
    3
    Maybe it's my video driver, but Apple may not update this model anymore.
     
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    hi there,

    i am sure that it is not your video driver ;-) as i should have pretty much the same…
    in fact it is a bug in the "nobending" shader – a shader that i haven’t looked after for quite a while as i do not consider it to be part of the core.
    nevertheless it is nice to have it so it should work correctly.

    as it uses the "TransparentCutout" pass it has to have a color value assigned.
    so simply fix the shader by adding:
    Code (csharp):
    1.  
    2. _Color ("Main Color", Color) = (1,1,1,1)
    3.  
    e.g. right after line:
    Code (csharp):
    1.  
    2. _Shininess("Shininess", Range(0,1)) = 0.2
    3.  
    in the "Properties" block.

    please let me know if this fixes the problem.

    lars
     
  13. erran-liu

    erran-liu

    Joined:
    May 13, 2013
    Posts:
    10
    Hi Lars, found a small bug, now the shader doesn't work with Light Cookies. If I assign any Light Cookies, the shader just render like a diffuse.
    Please check it and tell me if there's any quick solution, I don't really need the Light Cookies appear on the foliage, but I need them for the other part of the scene.
     
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    hi erran,

    sorry but i can’t confirm that: the shader DOES work with light cookies – tested with unity 3.5 in deferred lighting mode and unity 4.2.1 in forward rendering. anyway.
    which shader do you exactly mean?
    which version of unity do you use?
    which rendering path?

    and an image would be helpful as i can’t reproduce your problem.

    lars


    advanced foliage shader + light cookie (unity 3.5. deferred rendering)
    $Bildschirmfoto 2013-09-05 um 12.11.24.png
     
  15. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    hi there,

    right now the advanced foliage shaders get completely rewritten to take advantage of the new shadow collector and shadow caster batching feature in unity > 4.2.

    lars
     
  16. erran-liu

    erran-liu

    Joined:
    May 13, 2013
    Posts:
    10
    Hi lars, thank you for your fast reply.
    I am using Unity 4.2.0 f4 and Afs 2.02, I tried Forward and Deffered Light, different light cookie maps, same result.

    Actually, when I say the shader doesn't work, I mean the specular and the translucency disappeared.

    To make it clear, I took two screenshots in the sample scene.The plant still swing with the wind, just lose some effect.
    The only change I make is assign a cookie on the light in the samle scene.
    $Unity 2013-09-06 12-43-54-42.jpg $Unity 2013-09-06 12-44-03-39.jpg


    And there's another really important question, may be stupid, but really confuse me.
    How to make the model two sided?
    When my artist export a FBX model, it's single-sided, I mean I can assign a two-side shader to make it two-sided, but AFS's shader is single-sided, when I assign them to my model, only one side can be seen.
    If I change AFS shader with adding "Cull OFF", specular and translucency disappeared again...
    The models you provide in the sample are two-sided, even I assign a single-side shader to them, what's the trick?

    We are using 3D max creating the model.
     
    Last edited: Sep 6, 2013
  17. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    hi eran,

    i am currently working on version 2.04 and cookies just work perfectly in unity 4.2.1 – as they do with version 2.02 in unity 3.5.
    i will test version 2.02 with unity 4.2.1. as soon as i find the time.
    but i have to admit that i am on mac. so i have exported a little webplayer. please try it out so we will know if it is a mac/pc related problem or something else: https://dl.dropboxusercontent.com/u/2322017/afs_v2/afs_cookies/afs_cookies.html

    it should look like this:

    $cookies.png

    as far as the problem of two sided geometry is concerned:
    you can’t just add "cull off" to the shader as the lighting function always needs the correct normal – which would be flipped when using "cull off" and looking at the backface of a triangle.
    generating 2 sided geometry is pretty easy although i do not know anything about 3d max: simple choose the faces you want to be double sided (most likely just the leave planes) copy them and flip their normals. then combine all into a single mesh.
    that’ it.

    lars
     
  18. erran-liu

    erran-liu

    Joined:
    May 13, 2013
    Posts:
    10
    Your test scene works perfectly on my PC.

    I will upgrade AFS to 2.03 and try later.
    And the two-side model works well, thank you for your help!
     
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    hi erran,

    updating is a very good idea as v 2.03 brings some very nice new features.

    lars
     
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    hi there,

    version 2.031 has just been accepted by the asset store which brings some minor fixes and some nice improvements:

    Advanced Grass shader
    - "no Translucency" version needs only single sided geometry as culling is disabled in the shader
    - lighting fixed which replaces the hot fix from the forum

    Advanced Foliage shader groundlighting
    - Groundlighting affects directional lights only
    - "Groundlighting Attunation" added which lets you control its strength
    - non atlas version added

    CombineChildrenAFS Script
    - script will automatically detect materials, so you can have meshes with different materials (grass, ground lighting, regular foliage) under the same parent object

    i hope you will enjoy.

    lars
     
  21. Setmaster

    Setmaster

    Joined:
    Sep 2, 2013
    Posts:
    239
    Edit: Not a bug, just something that happens with static batching disabled

    Just bought it and I'm having a problem when running the demos, tried opening them in a clean project but this keeps happening. Video:
    http://youtu.be/pQXAMhNFIDs
     
    Last edited: Sep 11, 2013
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    that is a feature!
    probably your are using unity free, or static batching is diabled.
    try the "03 indie - touch bending demoscene_static batching disabled.unity" scene to see touch bending working with unity free.
    if you are with unity pro simply activate "static batching" in the player settings.

    lars
     
  23. Becoming

    Becoming

    Joined:
    May 19, 2013
    Posts:
    781
    Hey Lars,

    I bought AFS to enhance the look of the RTP Demoscene i am doing for Tomaszek. We will credit that AFS is used for the foliage, so this is something you might want to know ;) Of course AFS will excluded from the RTP package on the assetstore. I hope you appreciate the little extra advertising for your great product. Now to my question, its not directly related to AFS but since i saw that you also created the very nice tree tutorial on the Unity wiki i will just think of you as the unity foliage expert ;) Maybe you can help with this or you have an idea:

    We dont use lightmapping because we need a rotating sunlight, this leads to the problem with the tree billboards, they don't recieve any shadows and because of this are way too bright in shadowed areas. Is there any way around this? The only thing i can think of would be a seperate billboard tree atlas which is darkened but i am only an artist and no coder, so i have no idea if something like this is possible... Any ideas, or maybe some completely different approach?

    Thanks,
    Peter

    ps: AFS is great, thanks for this package! My only crtiticism would be the need for double sided geometry for most of the shaders, though i understand that there are probably good reasons for this :)
     
  24. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    hi peter,

    i am absolutely excited to see your demo – so hurry up!
    and of course i like the extra advertising – what else should i do? ;-)

    tree billboards – that is a very annoying topic in almost all concerns.

    how would i make them receive real time shadows?
    well, usually i work with shadow distances which match the billboard distance so billboards would never receive any real time shadows.
    depending on the scene’s complexity and layout it is something around 60 – 90 meters.
    so my first question would be: what is your shadow distance and what your billboard distance? and can you really afford such long shadow distances?

    real time shadows
    anyway – the built in billboard shader uses alpha blending which does not support receiving shadows due to its nature as it does not even write to the z-buffer. you would have to use alpha testing which would first of all produces hard edges instead of soft ones like alpha blending. next you would have to write your own lighting function which only adds shadows but does not add any lighting itself as the billboard textures already are fully lit. and probably you will have to adjust the alpha cutoff value according to the distance to the camera in order to avoid frazzling billboards.
    but billboard textures itself do not contain shadows which usually leads to overbrightened billboards when looking against the sun as they will have full translucency but no selfshadowing…

    lightmaps
    another approach might be to work with lightmaps, yes lightmaps.
    let say you have 36 low resolution and high contrast lightmaps (just including the shadows not the general lighting information) for your terrain. than feed in one of those as global texture according to the current sun position by script. within the billboard shader sample the lightmap according to the billboard’s position and multiply the albedo with the sampled value.
    it a very lossy approximation as the whole tree is lit by the way its pivot would be lit. so no difference in shading within a single billboard.

    not using lightmaps
    although using lightmaps will probably give you much more correct results you might also go with a global terrain normal map – which at least – is just a single texture…
    doing so won’t let the billboards receive shadows but just adjust their brightness according to the the terrain’s normal dot light direction.
    so sample the global terrain normal map according to the billboards position, calculate the lighting for that normal and multiply it with the albedo.
    you might have to add some kind of threshold.
    that would be like adding "ground lighting" from the afs to trees.
    thinking of your demo terrain this might be too inaccurate as steep slopes will not cast shadows on trees which are placed on rather flat terrain next to the slope... but pushing it a little bit further: you might sample the normal according to the tree position + light position.
    anyway – doing it this way will always be not accurate.

    sorry, but i can’t help you with an out of the box solution.

    there is a very good reason for this: translucency does not work with single sided geometry at all! and real time shadows either.
    but what is the problem? some more triangles? well those will be skipped by the shader if they point away from the camera at nearly no costs. some more memory and bandwith: yes. but double sided geometry is absolutely needed.

    lars
     
  25. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    hi peter,

    i have completely forgotten the 4th solution which is not shader but script based!

    it would need lightmaps as well i guess (at least if you want to run it fast), but instead of adding "shadows" in the shader you would tweak the tree’s color (terraindata.treeInstances.color) in the terraindata according to the trees position / lightmap sample.

    this color gets multiplied to the billboard texture (standard behaviour of the shader) but should not be multiplied with the albedo of the mesh trees as they would receive doubled shadows… so you will have to command it from the mesh shader(s).
    the drawback: you will loose the variation in brightness on mesh trees.

    lars
     
  26. Becoming

    Becoming

    Joined:
    May 19, 2013
    Posts:
    781
    Hey Lars,
    thanks for this very complete answers, really appreciate that much!! Not only billboards are an annoying topic in many ways but also the shadows are. If these two come together we have annoyance² :)

    Unfortunately we need high shadow distance, at least for the very high quality setting. I'll look deeper in the solutions you describe and come back to you when i know more. I will send you an PM in the next few days as there might be some collaboration opportunities that you might be interested in...

    About the double sided geometry needed for translucency, i understand of course! Its not a real problem, only lazyness to export all leaves meshes from purchased tree assets to make them doublesided ;) At some point i have to do it anyway, as most of the trees are not built in the way i would like them to be and i need to optimize them to save fillrate.

    Thank you so much for your posts,
    Peter
     
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    hi peter,

    trees made with the tree creator should be double sided…
    and do i get you right, you use the advanced foliage shaders on trees? trees placed within the terrain engine?
    well, they have not been written to be used on tree like objects (stiff trunk and branches, flexible leave planes) as they have just one value for primary and secondary bending. and version 2.03 does not support billboarding ( version 2.04 does!).
    nevertheless i would recommend to use a tweaked shader if you want it on trees. i am waiting for your pm!


    that is a quite underestimated point as everybody is just talking about vertex count… i am glad that somebody else also takes care about fillrate ;-)

    lars
     
  28. erran-liu

    erran-liu

    Joined:
    May 13, 2013
    Posts:
    10
    Hi lars,

    I've found the reason why light cookie doesn't work on my project, it's about the Pixel Light Count in QualitySettings. When change it to 1(from 0), light cookies works.

    Found a small bug of AFSFoliageTool, there should be "currentMesh.colors = colors" at the end of the function AdjustVertexColors();

    About the two-side mesh, still has problem. we use Maya to make the mesh two-side, and found that the cruncher does't work with it(cruncher is a tool to reduce triangles of mesh to make LOD). Mean while, the banana tree you provided works.
    I know that there's some instruction in the doc for making double-side mesh, but it's not enough detail for us(my artists are not experienced).
    Can you share which tool you are using to make the mesh double side, and maybe more detail of the procedures?


    BTW, thank you for providing such amazing assets for people, it can be the best solution to create foliages and will change unity.
     
    Last edited: Sep 17, 2013
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    hi erran,

    i am glad that you solved the problem.
    thanks for pointing this out, although it is already fixed in the current development version ;-)

    i have used cinema4d and modo but none of them is more advanced than maya i guess.
    and my process is pretty simple. so lets take the banana:

    first i have modeled the trunk. then the leave plane as single mesh.
    i copied the leave plane and flipped its normals.
    next i combined the original leave plane and its copy into a single mesh --> final leave mesh.
    i duplicated the final leave mesh several times, positioned all copies properly around the trunk, scaled and slightly reshaped them to create some variety.
    finally i combined all meshes into one.
    c‘est ca.

    if you work with the cruncher and it does not support keeping double sided geometry i would simply reduce the polycount using cruncher.
    then copy the result. delete all faces which do not have to be double sided, flip their normals and combine them with the mesh generated by the cruncher.

    thank you. i hope it will.
    and it would be nice if you wrote a comment on the asset store...

    lars
     
    Last edited: Sep 20, 2013
  30. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    hi there,

    just a sneak preview on the upcoming version 2.04:
    next to some improvements and bugfixes a new shader will be included which allows you to place your custom made foliage as trees within the terrain engine.
    so now – when using the advanced foliage shaders within the terrain engine – you will also be able to benefit from capsule colliders and casted shadows. Not to mention that this new shader brings you the pretty much most smoothly blending billboards even at very strong wind settings ;-)

    the shader might not be suitable for all kind of foliage and trees, but it is faster than the built in ones, supports all kind of unity’s built in wind zones and should be great on any kind of bush or shrub that you need to render over very large viewing distances.

    Webplayer: http://dl.dropboxusercontent.com/u/2322017/afs_v2/afs_v2_touchbending/afs_v2_demoscene.html

    lars
     
    Last edited: Sep 18, 2013
  31. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    just a very small update as proof concept:
    the webplayer now contains 4 "real" trees: 2 pines taken from the bootcamp demo using the built in tree creator (fast) shaders and 2 slightly modified pine trees (modified just within unity using the afs foliage tool) using the afs tree for terrain shader.
    i guess this show what i meant with "smoothly blending billboards".


    Webplayer: http://dl.dropboxusercontent.com/u/2...demoscene.html


    lars
     
  32. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Once I imported the program, I got errors with the:
    "Assets/Standard Assets/Scripts/Utility Scripts/CombineChildren.cs" once I removed the program folder,
    I still get errors with the file, only removing it allows me to go into play mode without compiling errors.
    Is this a regular Unity script or one you put there?
    I reinstalled Unity 4.x and no change.
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    "Assets/Standard Assets/Scripts/Utility Scripts/CombineChildren.cs" is not part of the package....

    my script is called: "Assets/Advanced Foliage Shader v2.03/Scripts/CombineChildrenAFS/CombineChildrenAFS.cs"

    it does not cause any errors (marked red) but it does produce warnings:
    "Assets/Advanced Foliage Shader v2.03/Scripts/Combine Cildren AFS/CombineChildrenAFS.cs(207,72): warning CS0618: `UnityEngine.GameObject.active' is obsolete: `GameObject.active is obsolete. Use GameObject.SetActive(), GameObject.activeSelf or GameObject.activeInHierarchy.'"

    unfortunately it has to as it supports both unity 3 and unity 4. but that is nothing you should worry about.
    so sorry, but your problem must be somewhere else.

    lars
     
  34. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Hmm, didn't have the problem until I imported the plugin and tried to run in Play mode,
    my layout got corrupted and I got the errors. Going to PM you with some questions, if you don't mind.
     
  35. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    FYI, here is the actual first of five error messages:

    Assets/Standard Assets/Scripts/Utility Scripts/CombineChildren.cs(84,72): error CS0246: The type or namespace name `DebugNormalsInEditmode' could not be found. Are you missing a using directive or an assembly reference?

    And the error I get when I reimport your plugin after removing the Unity combine children script:

    Assets/Advanced Foliage Shader v2.031/Scripts/Combine Cildren AFS/DebugNormalsInEditmode.cs(9,17): error CS0246: The type or namespace name `CombineChildrenAFS' could not be found. Are you missing a using directive or an assembly reference?
     
    Last edited: Sep 18, 2013
  36. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,464
    Hi, this is a very nice asset.

    I am working mainly with mobile and would like to know how this package performs on Mobile.

    Thank you.
     
  37. Goblox

    Goblox

    Joined:
    Nov 3, 2012
    Posts:
    178
    I purchased the ATS Colormap shader some time ago and I'm interested in this one as well. Could this be used to help prevent (or at least reduce) tall grass poking though mobile objects? Either via a wind zone or "collision". Mainly I'm just concerned with cars.
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    hi rocky,
    thanks for your kindness.
    (in fact i think it is a simply must have asset in case you have any foliage in your game ;-) )

    but back to your question: mobile…
    well, that is nothing i am very into, but the shaders are nearly as heavy as the built in "tree creator leaves shader" and made for real time (pixel) lighting and shadowing – nothing you will use on mobile i guess.
    you can simply test the built in "tree creator leaves shader" shaders to find our about performance (which probably will be evil).
    touch bending needs shader model 3 though…

    so if you are looking for mobile optimized foliage shaders you can have a look at my free ats mobile foliage package:
    https://www.assetstore.unity3d.com/#/content/3460
    http://forum.unity3d.com/threads/136752-ats-Mobile-Foliage-released
    no real time lighting, but lightmapping support. and the shaders come in 2 flavours alpha cut off (best for most android devices) and alpha blended (best for ios devices).

    however it might be usefull to buy the Advanced Foliage Shader v.2.03 anyway as they come with some nice and handy tools which will help you also when using the mobile shaders.

    lars
     
  39. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    hi goblox,
    theoretically: yes.
    practically: may be not.

    if you want to avoid "tall grass" from poking through your cars you would have to use the "touch bending" shader/script solution.
    and although i would claim it to be pretty fast it involves physics for collision detection. so performance will depend on the number of instances of "tall grass" you have in your scene.
    i would definitively not recommend to use touch bending on every single grass mesh – which might be 10.000 or even 100.000 in your scene.
    in case you have just 5000 – give it a try!

    so what is about testing?
    go and get the package, test it (please report about your tests!!!!!!) and get a refund in case the package absolutely does not fit your needs.

    lars
     
  40. FractalCore

    FractalCore

    Joined:
    May 15, 2009
    Posts:
    151
    I've just been trying out the Geometry Brush. Works really well, except that it paints the geometry with ANY mouse click. So I can't hold right mouse and look away or middle mouse to pan without scribbling plants all over my surface. Could it be modified to only except the left mouse button?
     
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    hold "alt" to rotate the camera and use the scrollwheel to zoom in and out.
    that is pretty much all i need to navigate while painting.

    lars
     
  42. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Gonna buy this now (and colormap ultra), looks great! :) --- but hoping that your previously mentioned 2.04 update will arrive into the Asset Store soon... got an ETA of sorts? ;)

    I too am targeting mobile. But only current-gen / next-gen devices. Already both my different HTC One devices support (report) "shader model 3", max4096px textures etc. As soon as I get Android 4.3 on them, I'll switch to "GL ES 3.x only" (so iOS7+ or Android 4.3+), as soon as Unity 4.3 lands will switch to Deferred render path.

    My point? Mobile is catching up fast. Of course current-gen mobile won't approach current-gen gamer PCs or gaming laptops, but the newest phones and tablets are already almost similar to 2-3 year old cheap consumer netbooks/ultrabooks in power / capabilities, not to mention technically speaking "better" than the "current-gen" 7-year-old consoles. Fillrate and draw-calls may remain optimization issues for some time to come (not to mention shadows...), but triangle throughput and texture samplers and stuff like this is really getting better and better at a good rate.

    Why do I write all this? Just to subtly make "my favourite" most talented AssetStore providers aware of the fact that mobile is getting more HD all the time, it's no longer 2D puzzles --- and if your terrain shaders require "at least Shader Model 3.0" that's a good baseline to keep up for a good long while, please don't go DX11 or GL4.x or something like that --- give it another 6-12 months and all those uber-optimized shaders will be highly useful to many, many mobile-first gamedevs..
     
    Last edited: Oct 2, 2013
  43. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    hi metaleap,

    it will be interesting so see some numbers.
    so if you test the shaders on mobile let us know how they perform.

    lars

    ps: version 2.04 will come soon.
     
  44. FractalCore

    FractalCore

    Joined:
    May 15, 2009
    Posts:
    151
    Wouldn't it just be a few lines of code? Seems like a pretty easy fix. I knew about holding alt etc. But holding right mouse and flying around with WASD is a preferred method of getting around the evironment.

    I can't program but can it just have some of this added... http://docs.unity3d.com/Documentation/ScriptReference/Input.GetMouseButtonDown.html
     
    Last edited: Oct 3, 2013
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
  46. David-Lindsay

    David-Lindsay

    Joined:
    May 20, 2009
    Posts:
    121
    Hi Lars,

    I am really enjoying playing with the AFS shaders and getting ready to do some serious wilderness level design. However, there are a few snags and I need some clarification.

    I have read all documentation, double checked with your examples and remade assets from scratch just to confirm, but still have the same problems. I feel as though I may be one of the first people seriously using the advanced foliage shaders in a production workflow... no? But I don't know what tools you have used in your modeling and exporting process so I am getting different results. In my tech testing project...

    There are three areas I believe need more documentation -maybe you can help me with this?

    1.
    The Afs Foliage Tool -> Adjust Vertex Colors

    "(Blue/%)" what does this mean? If the slider is set to -50, does that mean the original blue value divided by negative 0.5? Maybe it should read "Vertex Blue Value x AFS Tool Factor"? If this is set to zero, does that mean infinite or max blue value (divide by zero), or does it simply mean set to zero (multiply by 0) or actually does it mean no overall change to the vertex colors (0% shift)? Really not sure what this means, sorry!

    The apply button seems not to affect the mesh instance, but rather it seems to overwrite the referenced unity asset with whatever changes you have made. This doesn't seem good for experimenting, as there is no way to undo things you need to try in order to get the bending right. Maybe there is a third button called SAVE, so that after you've finished testing and satisfied with the bending, you can save the permanent changes and overwrite the mesh asset.

    2.
    When painting vertex colors, it is possible to separate different colors to layers/channels. There seems to be some conflict or problem with my workflow when the alpha channel comes in with the mesh. I painted my ambient occlusion onto the vertices, but when the afs tool receives this, it seems to make other colors not work. It's weird because when I try bringing in ONLY green vertices, the fluttering works fine, but when I bring in all four channels RGBA, there is no fluttering at all. Maybe the AFS tool needs to be run before the AO? Or perhaps you can suggest which tool to use for vertex coloring and I will try that instead (it could be an exporting problem, butI don't know how to test that).

    3.
    Y-Up. How do left-handed and right-handed XYZ directions affect the shader and the AFS tool? If my mesh is made in max and 270,0,0 by default, will this affect the AFS tool baking the vertex colors into a new mesh? I can make sure all my imports are 0,0,0 upright with in Unity, but would like to know before I go through and re-export 1-by-1, cause this could take some time.

    4.
    Touch bending seems to have massive amplitudes, stretching high or through the floor, even when the bending is set very low. This might be due to my exporting from 3dsMax, especially concerning the Y-Up. Moving into the plants from different directions confirmed some sort of odd phenomenon, as the bad deformations only seemed to happen from some angles (a 90 degree arc).

    Sorry about the long questions, but they are definitely a hitch in my plan!

    Thanks for the great shaders and looking forward to your reply!
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    hi david,

    you are definitively not the first one ;-)

    "Blue/% -50" would be: Blue = original Blue - (original Blue * 0.5).
    so it will lower the primary and secondary bending by half.

    whenever you hit "apply", the colors are calculated based on the current ones or the last ones you have applied. that might not always be the best way i have to admit, but works pretty well.
    so i would recommend to always use small steps and iterate to find the right values.
    in case you want to return to the original colors you can simply drag the original mesh into the proper slot.

    Make sure that your final mesh has only one vertex color layer (rgba) applied – so flatten all layers using your 3d app. Otherwise unity probably does not know which vertex color layer to import.
    i have successfully tested blender, modo and maya to paint and import vertex colors.

    "Adjust vertex colors" works independently from the orientation whereas "Set bending" needs the right orientation.

    probably you are using the wrong script as mentioned in the documentation:
    in case static batching is enabled you will have to use "touchBendingCollisionStatic.cs" otherwise "touchBendingCollision.cs".
    please have a look at the both demo scenes that deal with touchbending.
    another reason might be the fact that the player’s speed go above the defined "Max speed" parameter. if so simply raise "Max speed".

    please let me know if this fixes your problems.

    lars
     
  48. David-Lindsay

    David-Lindsay

    Joined:
    May 20, 2009
    Posts:
    121
    Awesome,

    Fast reply ftw!

    1. Okay, what you said worked just fine -by using a different Unity3d vertex color painting plugin called VPaint, which cheats by storing the vertex data in a separate object, I can continue to Repaint->AFS->Test so I got around this now too :)
    2. Sure, that worked just fine -I also realized that When exporting the final vertex color data to a unity.asset, the currently selected channels were the only ones exported -so after finishing alpha I just reselected all and this completed the solution.
    34. I solved the bending direction problem like you said by changing the Y-up 3dsMax FBX exporter setting -it worked for bending, cool, thanks! The touch bending was set right and it works as normal now -but I get a lot more bend than your demo plants -not to worry though because it can be set. Maybe the red affects this a lot?

    It certainly adds a lot of steps to the workflow, but once I have the prefabs set up, a level designer can go through and use them to some really great effect, so it's worth it. You know what they say about the last 10% taking 90% of the time. :) Thanks for your help!

    This foliage is now just so efficient to render... Any thoughts on how to improve trees efficiency? Even the unity tree creator still takes it's toll on performance. Seeing as you've done terrain, grass and foliage... will you try to tackle trees next?
     
  49. David-Lindsay

    David-Lindsay

    Joined:
    May 20, 2009
    Posts:
    121
    Is it possible for you to include in the next update some alternative shaders for LoD consideration?

    For example: AFS is quite expensive when far away. While using unity's LoD system, it is possible to swap one prefab for another. But even a lower poly mesh still has the performance cost of the AFS shader. It makes sense that a lower cost shader could be a stripped down version of AFS, looking like the original but not animated in any way. Because trying to use a different shader and tweak till it looks the same color and specularity takes a lot of time.
     
  50. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,974
    hi david,

    yes: red influences touch bending. it is added on top of vertex color blue (just like written in the pdf: adjusting phase variation…) so it is always a good idea to keep all red values close together. may be lower than i have suggested (which was 0.5 – 1-0). but you can use the foliage tool to play arpound with those values.[/QUOTE]

    i have changed my whole workflow and just add some vertex color green values to the outer regions of leave meshes, add some different shades of red and bake the ambient occlusion: around 2 min per plant. i set up vertex color blue using the foliage tool. so altogether i need about 5 min for a regular plant.
    but of course i have also spent several hours just with a single plant optimizing bending on each single leave.
    i am glad to read this!

    well, trees… they just cost a lot of draw calls. but version 2.04 will come with a special "tree" shader which will let you at least use smaller bushes and may be even trees within the terrain engine (supporting billboarding of course) while cutting the number of draw calls to half.

    lars