Search Unity

Relief Terrain Pack (RTP) v3 on AssetStore

Discussion in 'Assets and Asset Store' started by tomaszek, Oct 22, 2013.

  1. sundance

    sundance

    Joined:
    Mar 19, 2014
    Posts:
    52
    Tried to play with sliders without results. Noticed that if i check lower quality of textures there are no artefacts. I disabled all enviroment effects and props in scene, only relief, directional light with script and camera with dof is available. But its not metter are there effects on camera or not, because i have black pixels in same ways:
    with DOF only (its more noticeable): http://prntscr.com/4cdq8r
    without DOF: http://prntscr.com/4cdrcz
     
    Last edited: Aug 13, 2014
  2. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    When some black pixels/artifacts are present w/o camera effects enabled - this means we've got something in RTP actually. Could you send me link to your texture that makes it happen (diffuse with gloss + normalmap) ? This might be associated with some gloss or normalmapping locally on detail textures.

    Tom
     
  3. sundance

    sundance

    Joined:
    Mar 19, 2014
    Posts:
    52
    https://drive.google.com/file/d/0BwLrxLgBTB7YbXJJNEM5bzdoWE0/edit?usp=sharing
     
  4. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    120
    Is there some kind of quick start guide on optimizing the terrain? I have a scene with a small 200x200 terrain in it, and when I run the game, i have a 22ms main thread and get about 58 fps. If I disable the terrain, I get down to 14ms main thread and 100fps..

    I mess with settings and just end up making it look awful or worse and really all i want is for it to run faster. (Even changing pixel error doesn't help, because the terrain is exceptionally simple. Not brought in from worldcomposer, I mostly use terrain instead of primitives because of the painting.
     
  5. Becoming

    Becoming

    Joined:
    May 19, 2013
    Posts:
    781
    I dont think there is such a thing, the problem is that the performance is depending on countless factors...
    I am sure people on the forum are willing to help but you have to give more information about what you are actually doing... the things to check that come to my mind are:

    heightmap resolution, splatmap resolution, detail texture resolutions, number of layers, number of tree prototypes/nuber of trees in total, number of grass prototypes/number of grass planes in total, detail placement resolution, shadow distance, shadow cascades, image effects that are used, field of view, etc... this list would go on but if you check these you have already most of the important things...
     
  6. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    RTP iteself can easily consume your 8ms even w/o super fancy stuff enabled. just because RTP shaders are AAA (read - demanding) and for middle range GPUs this must be considered. Remove unused features. Keep them as small as possible. With 8 layers use 8 layers mode in first pass without overlapping conditional branch. If there is only one terrain I'm wondering if this could be caused my using materials. On my recent i3 CPU one terrain tile took 2ms for CPU. So maybe try to deselect materials. Will decrease CPU hit, but will increase GPU hit.

    Tom
     
  7. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    120
    Hey thank you for the response.

    I am not using a heightmap, nor a splat map. The texture resolutions are 512x512. There are no trees. 4 layers. No grass. Image effects all turned off, FoV is standard 60. Terrain size is 200x200.

    I'll have to check the placement resolution. There shouldn't even be any serious shadows because the terrain is almost entirely flat. There are some ridges near the edges but very slight. I did not use a map to generate the terrain, it was flat and I added some very small mounds (like 1 meter tall)
     
  8. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    120
    Its using U4 materials. Its only 4 layers. And its only one terrain.

    This is a radeon 6970 video card which is not fantastic but not terrible either.

    Thanks again for the responses Tom. This is definitely one of the best assets on the store!
     
  9. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Can you tell me GPU and CPU consumption from profiler ? Because your radeon is of similar performance like nVidia's GTX470 which is quite decent GPU. For simple setup with 4 layers RTP should not take more than 2-4ms on GPU. Give me your LOD manager specs.

    Tom
     
  10. Kivak

    Kivak

    Joined:
    Jul 13, 2013
    Posts:
    140
    Hi Tom,

    I am exploring ways of changing the shaders during runtime to adjust to dynamic weather (fun stuff!). I got snow to work great by using the following code:

    Code (csharp):
    1.  
    2. foreach( Terrain terrain in allTerrains ) {
    3.    ReliefTerrain rt1 = terrain.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain;
    4.    rt1.globalSettingsHolder._snow_height_treshold = newSnowLevel;
    5.    rt1.globalSettingsHolder.Refresh();
    6. }
    7.  
    But when I do the same thing with water - not so much. I change the layer water level in a similar fashion, but it doesn't work:

    Code (csharp):
    1.  
    2. foreach( Terrain terrain in allTerrains ) {
    3.    ReliefTerrain rt1 = terrain.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain;
    4.      
    5.    rt1.globalSettingsHolder.TERRAIN_WaterLevel[0] = newWaterLevel;
    6.    rt1.globalSettingsHolder.TERRAIN_WaterLevel[1] = newWaterLevel;        
    7.    rt1.globalSettingsHolder.Refresh();
    8. }
    9.  
    I made sure that the global wetness is 1 and the layer wetness is 1. In fact, I see the sliders moving and they're all in the correct position, but the terrain doesn't show the changes. I found that if I go into scene mode and adjust one of the sliders (even just slightly) it suddenly appears correct on the terrain. It's like the terrain isn't being refreshed.

    Ironically, your sample code in the manual uses TERRAIN_WaterLevel so I am pretty confident the code is right. But do you see any issues or know why this is happening?

    Thanks!
    -Mark
     
  11. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Yes, you got me :). It works when you don't use materials. When you use materials, use this:

    Code (csharp):
    1.  
    2.     foreach( Terrain terrain in allTerrains ) {
    3.        ReliefTerrain rt1 = terrain.GetComponent(typeof(ReliefTerrain)) as ReliefTerrain;
    4.      
    5.        rt1.globalSettingsHolder.TERRAIN_WaterLevel[0] = newWaterLevel;
    6.        rt1.globalSettingsHolder.TERRAIN_WaterLevel[1] = newWaterLevel;  
    7.        rt1.globalSettingsHolder.Refresh(terrain.materialTemplate);
    8.      }
    9.  
    This is also good moment to describe how it works for multiple terrains:
    1. When you don't use materials globalSettingsHolder object is shared between all terrain tiles. This means it's enough to set water level for desired layers (1ts and 2nd in your case) only once. The same for refresh - call it once - Refresh(). No need to do it in loop. Just get any rt1 object from scene and adjust it. This will affect all objects.

    2. When using materials globalSettingsHolder is still shared between tiles (unless they are grouped in independent parents - this moment they have their won globalSettingsHolder object one per group). For a single globalSettingsHolder object you can set water level in array once, but you need to call Refresh() for all terrain tiles, because they use different materials. That's why you need to call Refresh() function with param.

    Shortcut to refresh all at once would be setting water levels (once per every globalSettingsHolder - in most cases this is just one object per scene, because groupping is not used by most users). Then call

    rt1.globalSettingsHolder.RefreshAll();

    This function looks for all terrains and refreshes them one by one.

    Tom

    P.S. As you see - good to ask and you save yourself frustration, because for me it's 5 minutes investigation and tweak :).
     
  12. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Tom,
    I am now using Terrain Composer with 4x4 terrains.
    I see that multi-editing terrains is not supported by RTP, is there a proven workflow for this type of setup?
    Right now I am having to do things like save splat maps and some other things to each terrain individually.
    Also, my largest resources are being taken by:
    Camera.Render/Culling/Terrain.Heightmap.RenderStep3
    Do you have any suggestions on how to lower this resource useage or should I ask in the Terrain Composer forum?

    Thanks
     
  13. Becoming

    Becoming

    Joined:
    May 19, 2013
    Posts:
    781
    Hey Don, you could take a look in the Showcase forum, look for the 24h terrain demo. There is quite some valuable info about how we did the demo and also some info about performance issues. For example it might be faster if you use 2x2 terrains or even just one if possible.

    edit - here is the link:
    24 hour terrain demo
     
  14. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Will check it out, thanks.
     
  15. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    120
    Tom I hope this helps. Here are two shots of my game with the terrain on, and with it off, and with all the settings for the LOD manager.



     
  16. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    I was using one terrain but needed a background view so the scene would look realistic.
    Usually, I would create a very large terrain separately and place it under the main level terrain,
    but I don't always like the results.
     
  17. Becoming

    Becoming

    Joined:
    May 19, 2013
    Posts:
    781
    You might look forward to this: Horizon[ON]
    Its meant to deal with exactly that problem and its very(!) performant, i am currently working to make it go well together with RTP. I think it will be released within 1 or 2 weeks.
     
  18. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Looks quite interesting and will certainly give it a try when it's ready.
    So what about programs like Terrain Composer?
    I tried setting up RTP with TC but not sure what to do,
    I used a copied pasted RTP component on each of the 16 terrains.
     
  19. Becoming

    Becoming

    Joined:
    May 19, 2013
    Posts:
    781
    Terrain composer has a button to add the RTP component to the terrains... actually its quite simple, you can use Terrain Composer to make terrains ready for rtp(assigning the right textures etc.) when the terrains are ready, you only need to focus on setting up RTP but of course you can still make changes with terrain composer. You have to imagine RTP as something that is a applied on top of the terrain and terrain composer as something to make/modify that terrain/s. basically RTP and TC are pretty independent of each other but compliment each other perfectly. In the 24h demo thread there is a PDF tutorial that explains already a lot. If you still have questions, Tom, Nathaniel and i will try to help you where we can. Also, RTP has so many users that specific questions are often times swiftly answered by the community, same goes for Terrain Composer.
     
  20. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Thanks, will have to put this on the schedule for next week.
     
  21. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    I see your terrain is quite simple. With one terrain use "U4 materials" in LOD manager. This can increase performance of RTP shader. But still I can't understand hat on GPU of over 2400 points reported on benchmark site you've got 6ms spent on GPU to render this. I think you sohould look at how many times terrain actually is rendered, because I see 250k triangles spent on terrain alone while it's almost flat, so your small terrain should have quite a low number of triangles mesh. When you're in forward - many realtime lights with shadows can be a bottleneck. Can't you stick to one directional light and lightmap your terrain for others ? Terrain as shadow collector might be also a bottleneck. This would perform the same even w/o RTP then. If you're using forward rendering, try two things:
    1. check "no forward add" in LOD manager and compare. If performance will jump up you know the terrain is rendered too many times to handle many lights
    2. try with default bumped specular terrain shaders and compare the performance.

    Tom
     
  22. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    120
    Hi Tom, Thank you for the response. I am using deferred lighting.

    And yes, as I mentinoed the terrain is very very flat, so I don't know why its generating that many triangles, but still seems excessive.

    I toggled Use U4 matierals on and off and saw little to know difference. I guess in this instance you saw it with it off. But it doesn't make a noticeable impact.
     
  23. Kivak

    Kivak

    Joined:
    Jul 13, 2013
    Posts:
    140

    Awesome!!! This totally worked! (not that I doubted you! ;)). I did find that

    Code (csharp):
    1. rt1.globalSettingsHolder.RefreshAll();
    Was MUCH slower than

    Code (csharp):
    1. rt1.globalSettingsHolder.Refresh(terrain.materialTemplate);
    In fact my game didn't seem to even run with the first one! But I am one very happy person because my water trickling down rocks during a rain storm is working beautifully!!

    Thanks again!
    -Mark
     
  24. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    649
    Hey,

    Brilliant work! You have both my respect, gratitude, and money :).

    Is there any chance you could show me how to add toon shading to the current shaders? I just want outlines on the terrain, but I'm not sure how to modify your code. I had been using a modified terrain shader ... but thats getting tossed in the garbage now :).

    I left a glowing review ... I'll be sure to update it if your able to help me with this. Again, thanks!
     
  25. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    649
    I realized I could just use an edge detection effect if nothing else. If its easy enough let me know, if not, this should solve it!
     
  26. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Hi, to make output more toony you could use textures in such style (look for argosy_ops user works on the forum he used RTP for toony styled game). For edge detection you'll probably need to rely on postprocessing filters rather than trying to bake this functionality inside my shader.

    Tom
     
  27. Uzopoza

    Uzopoza

    Joined:
    Feb 26, 2013
    Posts:
    39
    Hi, Tom!

    I use RTP 3.1c in U4 mode and I have one problem and one question.

    Problem: At some distance 8th layer (green) is replaced by 7m. How I can fix it?


    If you look close - all ok!




    Question: I can not use ise "8Layer in first Pass" if in my terrains Control Texture Resolution is 2048?

    Best Regards, Igor!
     
    Last edited: Aug 15, 2014
  28. Becoming

    Becoming

    Joined:
    May 19, 2013
    Posts:
    781
    Hey, you should use normal & height maps.
     
  29. Uzopoza

    Uzopoza

    Joined:
    Feb 26, 2013
    Posts:
    39
    It necessarily? This may be the cause of failure 8th layer MIP?
     
  30. Becoming

    Becoming

    Joined:
    May 19, 2013
    Posts:
    781
    I think it is, it is one of the big reasons to use RTP in the first place, you might go without normal maps but i dont know that for sure. In your case i would add the normal maps and heightmaps for a quick test. If it still does not work you can at least narrow it down. Its definitely supposed to work with 8 layers also with 2k control tex.
     
  31. kaarme

    kaarme

    Joined:
    May 1, 2014
    Posts:
    177
    I set MaxLOD to POM_Soft Shadows from PM but it was way bright. When I set it back to PM and recompiled shaders it won't change.
     
  32. kaarme

    kaarme

    Joined:
    May 1, 2014
    Posts:
    177
    I can't recompile anything. : /
     
  33. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Problem - it's probably because you're using UV blend routing ("7 from 6" in LOD manager) and set UV blend replacement slider on 8th layer. This is normal RTP behaviour but you must be aware what controls mean.
    I don't know about control texture constraints. This can be any texture acceptable by Unity. So for desktops it can be also 4k. When trying to make atlas (in 8 layers mode) from hi res 2k detail textures you might run into memory problems, but I know users were able to make 4k atlas (from 2x2 2048 detail textures).

    Tom
     
  34. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Could you tell me more ? This is first time I hear about such problem. Which version of Unity do you use ?

    Tom
     
  35. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    515
    Tom,

    I'm getting a problem when saving color atlas in rtp 3.1.





    The second image shows the tiling problem after saving the color atlas and reassigning it back into the texture holder. When i drag the atlas back onto the texture holder or do it via script the textures appear tiled on the terrain. It only becomes corrected again when you refresh a texture layer which regenerates the atlases but this i can't do as i'm assigning it at runtime. Am i missing a step here or is this a bug?
     
    Last edited: Aug 16, 2014
  36. kaarme

    kaarme

    Joined:
    May 1, 2014
    Posts:
    177
    I disabled UV blend, but terrain is again too bright. When I tried to set it back and recompile it didn't change. This must be a bug. Unity 4.5.2f. Same problem with changing Max LOD.
     
  37. kaarme

    kaarme

    Joined:
    May 1, 2014
    Posts:
    177


    How do I fix this?
     
    Last edited: Aug 16, 2014
  38. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    I'm aware about this issue, but this in your case it looks drasticly :). When preparing atlas I'm padding textures and I blend borders for higher MIP levels, so the issue might be a problem for high MIP levels only (like MIP level 4 and higher). Unfortunately Unity can't save textures with modified mip levels. You would need to implement such functionality yourself or regenerate this runtime. Anyway - I see your saved atlas is of lower resolution, isn't it ? That's why RTP could select bad padding values in shader. You might send me your saved atlas via PM message, so I can check it. Example scene is also based on saved atlas and we don't see the problem that bad. That's why I think there must be something else in your case.

    I saw this problem before and this is very rare case. It's almost always experienced on Macs. When you use 2 passes (4 layers in first pass and 4 in 2nd) addpass is for unknown reason making such z-fight problems (your first screenshot). Therotetically Unity should use exactly the same geometry for first and addpass, but somehow sometimes it doesn't... To resolve this you can use workaround line in my code. Look at ReliefTerrain-AddPass.shader:

    Code (csharp):
    1.  
    2. //Offset -1,-1
    3.  
    and uncomment this line (should be line 28 in current RTP version).

    Also I see overbrighten parts that are most probably produced by deferred rendering and specularity on that layers. In deferred specularity is much constrained for addpass. I described this in my pdf. Can you tell me how many layers do you use ?

    For the 2nd issue. You need to select mesh blending in "LOD manager" when recompiling shader. Refresh All button. When edge is still visible, for the cave tunnel, use rebuild mesh button and paint coverage again (at edges to hide/blend them against the ground).

    Tom
     
  39. kaarme

    kaarme

    Joined:
    May 1, 2014
    Posts:
    177

    7 layers... it's TerrainScene demo. That didn't fix it. Setting offset to classic removed these black things but texture blending doesn't work in distance.
     
    Last edited: Aug 16, 2014
  40. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    RTP is not meant to use classic asthis is lowest fallback. First -use 8 layers as your problems might be related to this. Next week I'll try to prepare new tutorial with different modea desribed and 8layers setup.

    Tom
     
  41. Marcurios

    Marcurios

    Joined:
    Nov 19, 2012
    Posts:
    88
    Hi Tom,

    I've been looking at terrain shading solutions lately, but as far as i can tell they all make use of the Unity terrain
    engine (shaders), and from what i understand it is not doable (or very expensive) to use more then 4 to 8 textures on the terrain in Unity.
    I bought the colormap terrain shader from Lars, and it looks ok, but i really need to be able to use atleast 16 textures on my terrain, i want this so i can cut down on the amount of grass i use and still have abundant variety on my terrain while
    not straining the GPU too much by redrawing all those objects each pass.

    Is it true that your shaders can be used on a terrain mesh (from what i've read somewhere) and is it possible to use much more textures on that terrain mesh and that it then get's rendered only once ?
    So no Unity terrain shaders with more passes for more then 4-8 textures but a mesh, your shader attached and then have atleast 16 textures available on that mesh with most of the built-in possibilities of your terrain shader.
    Ofcourse detail and normal, but maybe parallax too ?

    If so i will definitely buy the pack.
     
  42. kaarme

    kaarme

    Joined:
    May 1, 2014
    Posts:
    177
    Thanks, works fine now.
     
  43. kaarme

    kaarme

    Joined:
    May 1, 2014
    Posts:
    177
    When Island Demo is ready?
     
  44. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    As far as I understand, no, 8 textures instead of 4 already require two passes instead of one and complicated mixing, and 16 textures are not supported at all. Although to be honest I have real trouble imagining a scenario where 16 ground textures are really required through the whole terrain area, no game does that. If it's local, specific stuff like pebbles to smooth edges of a particular rock mesh, or road stones to draw roads, then those are always better off included into the separate meshes and blended with terrain using blend shaders RTP provides - this makes your terrain more performant and allows for much more than 16 textures.
     
  45. Marcurios

    Marcurios

    Joined:
    Nov 19, 2012
    Posts:
    88
    Fallout 3 and New Vegas use 60 terrain textures.
    Gamebryo doesn't need to render these in multiple passes.

    Just because you have trouble imagining things does not mean someone else does.

    And i think you are talking about Unity's terrain, i was talking about the use of a mesh.
    As far as i understood you can have unlimited amount of materials on a mesh.
    And even if i could have only 8 materials on a mesh, i could use 8 atlases that each hold 4 textures,
    so then i would have 32 textures on my mesh, i've done this stuf with other meshes so.

    I'm not asking for an answer that says no you can't, i'm looking for a positive answer, so if one
    does not know a solution, don't reply, cause i'm not interested in a no.
    in my opinion everything is possible.

    I just want a solution that isn't as expensive as Unity's terrain engine does it with added passes each 4 textures.
     
  46. bac9-flcl

    bac9-flcl

    Joined:
    Dec 5, 2012
    Posts:
    829
    No terrain tile in Skyrim (Gamebryo) is using more than 4 simultaneously mixed textures and majority of additional surface types are simply pre-mapped geometry with transitions hidden by decals. That aside, it's technically impossible to mix 60 surface types together, look up DX9 shader limits on amount of texture samplers.

    You can, of course, use as many separate meshes with additional surfaces as you like, which is the point I'm making: that much variety is never achieved using pure terrain layering alone.

    RTP provides all tools necessary to use Skyrim-like setup with 4 or 8 layer terrains, smoothly blended meshes and smoothly blended/deformed decals, if that's what you're interested to know.
     
    Last edited: Aug 17, 2014
  47. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Actually RTP can use 8 layers in one pass using 2 atlases. More textures in single pass is possible only using bigger atlases which is not offered by RTP or using some twisted and unefficient techniques like using 3d textures. I'm talking about DX9. In DX11 there is texture array functionality but Unity does not implement this. That's why I don't think about using DX11 for RTP. Too little advantages for platform that's not that widely used (still - think that it's still impossible touse it all on Macs for example). When you'd like to use more textures you can organise your scene so single terrain object does not use more than 8 layers (but still have some common ones to resolve adjanced terrains borders). Like bac9-flcl said you can use RTP's geom blend to decorate your environment locally with virtually unlimited amount of features.

    Tom
     
  48. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    No date can be estimated now...
     
  49. Marcurios

    Marcurios

    Joined:
    Nov 19, 2012
    Posts:
    88
    OK, i think i understand, you mean use 8 layers on the main terrain, and use additional pieces of mesh with extra textures on it, that sounds reasonable, never thought about that.
    So your geom blend shaders also allow for 8 layers to be used on a separate mesh ?
     
  50. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    My geom blended meshes handles up to 4 layers on single mesh, but I think more efficient will be splitting this into separate meshes which uses 1-2 materials.

    Tom