Search Unity

Relief Terrain Pack (RTP) v3 on AssetStore

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

  1. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    I can't remember out of my head where is paced the part for global wetness code. Maybe Try calling RefreshAll(). Best would be probably to look at my Refresh() and RefreshAll() code and see where and how the variable is set. Then you can modify globally this parameter alone w/o necessity to pay extracost for refreshing all parameters that actually haven't changed.

    Tom
     
  2. Saevax

    Saevax

    Joined:
    Nov 3, 2012
    Posts:
    58
    I'm currently doing some profiling and I came across some garbage allocation and random performance issues maybe you can point me in the right direction.

    ReliefShaders_applyLightForDeferred.Update() is constantly allocating 1.2 KB for garbage collection.
    Coming from Component.GetComponent()


    Solved

    Unity3D allocates memory for garbage collection on null return values from GetComponent(). This however only happens in Edit mode so this is a non-problem for built games.
     
    Last edited: Sep 2, 2015
  3. KuRouZu

    KuRouZu

    Joined:
    Aug 8, 2013
    Posts:
    27
    If I use RefreshAll() it works, but the framerate drops considerably. As you suggested I checked refreshAll() function and I did some tests, calling rts[i ].RefreshTextures() seems the only place where wetness is refreshed, but this function is responsible for the low framerate too.

    EDIT: I finally found a call to UpdateBasemapDistance() inside RefreshTextures(), and there are three lines that update the materialTemplate value. This combined with a Refresh() call is what makes it work. Even still consume resources, but fewer that directly call RefreshAll(). This is the code that I'm using:

    Code (CSharp):
    1.  
    2. private ReliefTerrain[] rts;
    3. void Start(){
    4.        rts=GameObject.FindObjectsOfType(typeof(ReliefTerrain)) as ReliefTerrain[];
    5. }
    6.  
    7. public void RefreshWetness(){
    8.  
    9.         for(int i=0; i<rts.Length; i++) {
    10.             if (rts[i].globalSettingsHolder!=null) {
    11.            
    12.                 Terrain terrainComp = (Terrain)rts[i].GetComponent(typeof(Terrain));
    13.            
    14.                 Material ter_mat=terrainComp.materialTemplate;
    15.                 terrainComp.materialTemplate=null;
    16.                 terrainComp.materialTemplate=ter_mat;
    17.            
    18.                 rts[i].globalSettingsHolder.Refresh(terrainComp.materialTemplate);
    19.             }
    20.         }
    21.     }
    I was modified the global wetness from an Update() function using math.lerp, now I'm using a coroutine to waiting for some miliseconds before updating.
    There is a more correct way to do this?

    Regards and thanks for your support.
     
    Last edited: Sep 3, 2015
  4. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Check whether global wetness is part of material property in ReliefTerrain-FirstPass.shader. If it is (property name is TERRAIN_GlobalWetness) you could comment it out, in script use something like:

    Shader.SetGlobalFloat("TERRAIN_GlobalWetness", yourGlobalWetnessValue);


    should work w/o any performance hickup.

    Tom
     
  5. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    Hi Tom,

    I found the setting I needed and applied it. It looks much better now. Thank you! (although still trying to work out some kinks with it). The setting in case others have the same question is: "First-Pass Triplanar" in the "Additional Features" section of the RTP manager. Here was my question though:


    *** Solved ***


    So, follow-up question: Using the Tri-Planar option, I'm now noticing some texture flickering at certain spots where the terrain is somewhat jagged or where there seems to be a terrain "seam" along hills and mountains mainly. It only occurs at semi-far distances though, and never up close. Any idea if there's a way to get rid of this flickering effect at medium-far distances?
     
    Last edited: Sep 3, 2015
  6. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    I'm trying hard to imagine the type of flickering you're refering to. Could you give me a screenshot (if it's possible to catch the glitch). ?

    Tom
     
  7. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    It's very hard to reproduce in a still image, as the flickering only occurs while moving around. Here is a screenshot though, and I've outlined in white one of the areas that is flickering (while moving and at medium distance to the area in question).



    It kind of seems like it's wherever the "4th" texture I'm using (the 4th texture slot in the layers) connects to another layer, is where i seem to get the worst flickering. Also, smoothing the area as much as possible (with the terrain smoothing tool) seems to help reduce it to some extent.

    Also it seems to be related to where the "Near distance values" are set. So, for example if I increase my "Distance start" value in the main settings, the texture flickering will occur, but not as soon -- if you get what I mean. So, if I had the option to set the "Distance start" to a huge number (lets say 500000), it would solve the problem. But I'm limited to a distance start of 50 I believe.

    Hope some of that might help you. Let me know if you have any ideas.
     
  8. KuRouZu

    KuRouZu

    Joined:
    Aug 8, 2013
    Posts:
    27
    TERRAIN_GlobalWetness does not exist in ReliefTerrain-FirstPass.shader
    I tested Shader.SetGlobalFloat from a Coroutine, but is not working.

    With latest version of RTP I'm getting a warning value under terrain settings, after material value: "Can't use materials with shaders which need tangent geometry on terrain, use shaders in Nature/Terrain instead".
    Could this have something to do? or I can ignore it.

    Regards.
     
    Last edited: Sep 4, 2015
  9. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Does it appear only on transition between near and far only, or everywhere faraway ? I'm wondering if this is not related to triplanar - do you use it ? You could also check this fake heightblend AO features as you told it is present between layers (4th and the others).

    Tom
     
  10. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    It doesn't work probably for the reason I'm writing into material property as well. It might block global param then. I see no other explanation here. That's the part of globalwetness in global settings holder script:

    SetShaderParam("TERRAIN_GlobalWetness", TERRAIN_GlobalWetness);
    Shader.SetGlobalFloat("TERRAIN_GlobalWetness", TERRAIN_GlobalWetness);

    So, SetGlobalFloat doesn't work, but in your case you could get terrain component from your terrain object. Get materialTemplate variable and set the shader property for this material

    terrainMaterial.SetFloat("TERRAIN_GlobalWetness", wetnessRequired);

    Tom
     
  11. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437

    Hey Tom, thanks for the reply. The issue appears everywhere far away, at all distances (not just in a near to far transition state). It does appear to be an issue with the Triplanar setting -- because when I disable Triplanar the problem disappears. But that's the whole point for me, is that I'd like to be able to use the Triplanar setting to fix the texture stretching on heights -- but then I see the texture flickering/glitching issue. I can live without using Triplanar, but it would be nice to have of course.

    I've tried unchecking and recompiling the shaders for a lot of settings while using Triplanar (including the "fake heightblend AO" setting) and nothing has seemed to work yet to get rid of it. I thought it was a UV Blend issue for awhile, but nothing in the UV Blend settings fixed the issue (including disabling it).

    Some textures mask the issue more than others, but if I look really hard I can still notice it. For now, I can't use Triplanar until I figure out whats causing the issue.
     
  12. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Could you privde me with small project (terrain only) where issue exists ? You could send me link to zipped archive on private message on forum. Give me also your Unity version (PC or Mac ?) together with RTP order number and purchase date.

    Tom
     
  13. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,437
    Ok it might take me a day or two to have time to do it. I will try though :) Thanks.
     
  14. eteeski

    eteeski

    Joined:
    Feb 2, 2010
    Posts:
    476
    Hi Tom,
    Lately I've been trying to learn more about your shader, particularly tessellation. I'm using the "ReliefTerrainPMTriplanarStandalone Tessellation(Phong)" and so far I think I've worked out all the kinks, my only problem in that the terrain looks pretty flat. The Phong par of the tessellation looks great! It smoothed out all the low-poly edges of my terrain.

    Is there a way I can also add a height tessellation effect to this shader? Like shown in the example in this video at 8:11


    I'm not sure if it's possible, but I would like to tile an effect like this over the whole map. Thank in advanced if you know a solution :)
     
  15. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    RTP3 doesn't have such feature - heightmaps displacement - for standalone meshes (PMTriplanar phong smoothed).

    Tom
     
  16. KuRouZu

    KuRouZu

    Joined:
    Aug 8, 2013
    Posts:
    27
    Maybe I'm doing something wrong, but is not working. Here is my mode, without the refresh call it does not work either:

    Code (CSharp):
    1. public void RefreshWetness(){
    2.         for(int i=0; i<rts.Length; i++) {
    3.             if (rts[i].globalSettingsHolder!=null) {
    4.                
    5.                 Terrain terrainComp = (Terrain)rts[i].GetComponent(typeof(Terrain));
    6.                
    7.                 //Material ter_mat=terrainComp.materialTemplate;
    8.                 //terrainComp.materialTemplate=null;
    9.                 //terrainComp.materialTemplate=ter_mat;
    10.  
    11.                 terrainComp.materialTemplate.SetFloat("TERRAIN_GlobalWetness", m_GlobalWetness);
    12.                 rts[i].globalSettingsHolder.Refresh(terrainComp.materialTemplate);              
    13.             }
    14.         }
    15.     }
     
  17. robymv

    robymv

    Joined:
    Oct 28, 2013
    Posts:
    74
    Hi, Tom! Thank you for RTP. It is a very wonderful asset.
    I have a question: How can I create a simple puddle?
     
  18. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    I thought the bug has been fixed in Unity, but maybe not. I believe that this might work (a bit of pseudocode):

    Code (csharp):
    1.  
    2. Material tmpmat=rt.materialTemplate;
    3. tmpmat.SetFloat(...);
    4. //rt.materialTemplate=null; // uncomment this line if it still doesn't work
    5. rt.materialTemplate=tmpmat;
    6.  
    Tom
     
  19. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    By using wetness feature on terrain together with mask. This will however apply wetness on whole terrain and might be overshoot if you need only a few puddles. Try to use sticked geom blend object then that would "mimic" underlying terrain and place puddle there (use one of the water geom blend shaders).

    Tom
     
  20. Kobaltic1

    Kobaltic1

    Joined:
    Jan 22, 2015
    Posts:
    183
    I am using Unity 5.1 and RTP 3.2. I created a new scene. Added a new terrain. I added 4 textures to the terrain. I then added the RTP to the terrain and my terrain disappeared. I tried recompiling shaders. I tried the refresh button. Nothing works. I tried this several times and each time the terrain vanishes. Any thoughts?

    EDIT: I have found out the terrain is still there and I can use it. However there are no textures displayed. I have traced the problem to the screen shot below. But I don't know how to fix it correctly. I can change it to a nature / terrain shader but I don't think that really solves the issue.

    error.JPG
     
    Last edited: Sep 6, 2015
  21. eteeski

    eteeski

    Joined:
    Feb 2, 2010
    Posts:
    476
    Hi Tom,
    Thank you for your quick reply. After looking around online, I found you also offer a shader pack called UBER? It looks like it has the triplantar/tessellation displacement functionality I'm looking for. The other shaders look very useful aswell. Would you recommend the triplantar/tessellation displacement UBER shader on a large terrain?
    -Thanks, Eric

    edit: I forgot to say, my terrain is separated into multiple meshes. I'd say a new mesh every 20 units or so. I'm not sure if that's helpful information.
     
    Last edited: Sep 6, 2015
  22. InfiniteDice

    InfiniteDice

    Joined:
    Jun 30, 2015
    Posts:
    44
    I have the exact same issue. I choose 'reliefterrainvertexblendtriplanar' and it seems to work then l select the terrain and everything goes black. If I zoom way in. I can see the terrain but everything seems snow-covered? I don't have the snow cover on.... plus I can't seem to affect the terrain by placing the textures at all.

     
  23. KuRouZu

    KuRouZu

    Joined:
    Aug 8, 2013
    Posts:
    27
    The only way that works is setting the materialTemplate to null before re-asign it. With your last solution is working without call to refresh() function, that seems is a bit more optimal. But putting the material to null continuously and re-asign it is what really affects the framerate. It is not a drastic framerate drop, but is noticeable. It would be nice get it working without performance issues because the resulting effect is very good.
    Is this related to a bug in unity? I guess there's no other solution that does not involve putting the material to null and re-assign it.

    Thanks again for your support.
    Regards.
     
  24. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Does the example scene terrain works after fresh RTP installation ? Do you use forward or deferred ? Do you use tessellation (disappearing terrain issue migth be caused by empty height&normals texture). Can you provide screenshot of what you get ?

    This is Unity bug (assigning nul then material again), I hoped they fixed this in 5.1.2 ot 5.1.3. Try to comment out line that sets material property in GlobalSettingsHolder script:

    SetShaderParam("TERRAIN_GlobalWetness", TERRAIN_GlobalWetness);

    comment out this line. Then remove material from terrain and refresh in RTP. Material will appear again. Then there is change Shader.SetGlobalFloat will start working.

    Tom
     
  25. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    UBER doesn't handle multilayers like terrain does.
    vertexblendtriplanar shader is meant to be used on meshes, not on the terrain. Terrain controls coverage by using a texture while that shader uses veteex colors (or covers it automatically by mesh normals). RTP added to terrain component (where you first adde 4 layers) will add a material which uses FirstPass-ReliefTerrain.shader

    Tom
     
  26. KuRouZu

    KuRouZu

    Joined:
    Aug 8, 2013
    Posts:
    27
    Now is working!, I no longer need to update the terrains one by one nor put terrainMaterial to null. Working perfectly without framerate issues.
    Thanks again, regards.
     
  27. Kobaltic1

    Kobaltic1

    Joined:
    Jan 22, 2015
    Posts:
    183
    1. The example terrain does work. However if I add my own terrain to the same scene and add the RTP it again looses all of its shaders and is see through.
    2. I am using Forward
    3. I am not using tessellation yet (although that is what I want to use) I added in height maps and normal maps anyway and it still didn't help.
    4. Here is a before RTP and after RTP shot.

    Before:
    before.jpg

    After:
    after.jpg
     
  28. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Huh ? Drop me your skype ID via private message. We need to inspect it then.

    Tom
     
  29. Kobaltic1

    Kobaltic1

    Joined:
    Jan 22, 2015
    Posts:
    183
    I started a brand new project and it worked correctly. I am going to start my project over and add in the stuff and see if I get the issue at any point, but I think I will start with RTP and then add in the other packages. Thanks for your help
     
  30. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    We load terrain prefabs into the game when each scene loads. I'm setting up RTP on those terrains, but when they are loaded at runtime:

    a) The terrain textures are black until I click on the terrain in the Hierarchy, and then there are several progress bars showing the textures loading.

    b) Heightmaps are not applied to terrain textures, so it looks like normal unity splats blending.

    Can you suggest how to fix both of these problems? Thanks much!
    Dave
     
  31. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    For prefabs you need that none of RTP internal (like texture or terrain material) object is reference to scene only. You need to save all textures of RTP (combined textures tab) before you make prefab. Also make a plain amkterial and assign to terrain. Assign ReliefTerrain-FirstPass.shader and let RTP refresh it. Then prefabs should work.

    Tom
     
  32. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Ah, thank you! I'm doing that now...but the Heights 0-3 slot is empty--how do I generate it?
     

    Attached Files:

  33. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    You've got either no hieightmaps on layers 0-3 or they are somehow problematic. The reason might be they've got no matching size. Unselect RTP. Check every detail heightmap carefully and match their sizes. Try to reassign them again to layer slots. Clicking refresh button over the heightmaps on RTP layers settings also forces combined heightmap to be rebuilt.

    Tom
     
  34. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Thanks, that fixed it! So a couple more questions:

    1) At low angles, the textures are blurry even just a few meters away. I've set aniso to 12 or higher on the textures and the atlases, but that doesn't make any difference. Is there a way to improve that?

    2) At close distances, the perlin (I guess) noise on the texture looks obviously artificial. Can I refine that somehow? EDIT: well, of course that must be the normal map, I suppose. So never mind this question, but how about #1?
     

    Attached Files:

    Last edited: Sep 9, 2015
  35. Mick21

    Mick21

    Joined:
    Dec 3, 2013
    Posts:
    11
    Hi,

    I have following problem with mapping slope terrain (trying on triplanar mapping). What am I missing?
     

    Attached Files:

  36. MightyCoop

    MightyCoop

    Joined:
    Dec 10, 2012
    Posts:
    2
    I've looked around quite a bit and have fiddled with settings but I have not found a solution to an issue with geometry blending I'm having.

    We're in the process of upgrading to Unity 5 and are switching to the new deferred rendering path. When we did the switch, it caused all the geometry blended objects to have turned white where ever the blending occurs. But this only happens when shadows are present on the directional light and the object is set to receive shadows.

    I have made sure the directional light included the Apply light for Deferred script and I have the RTP shader set as the deferred shader in the graphics options.

    The issue does not happen in Legacy Deferred or Forward rendering paths, only in the new Deferred.
    Using linear color space currently, but the issue still happens in gamma.
    The issue happens whether or not the Apply Light For Deferred is on the directional light.
    The issue does not happen with point lights or spot lights with shadows, only directional.

    I've included pictures of the effect on the example scene with shadows on and shadows off along with my RTP LOD settings.

    Shadows On:
    ShadowsOn.JPG

    Shadows Off:
    ShadowsOff.JPG

    Thanks for any help!

    -Coop
     
    Last edited: Sep 9, 2015
  37. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Go to geem blend shader code and comment out Fallback keyword at the very end of the shader. I can't do it automaticaly by scripts and don't like to dobule shaders only for deferred.

    Tom
     
  38. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    1. In atlased modes we don't have aniso filtering. You can try to conmpensate it using MIP bias slider in RTP main settings. This is no the equivalent though. So - in forward you can do it via 4+4 mode w/o atlases. In deferred you're forced to use 4 layers because add passes (4+4) doesn't work then

    2. it looks like parallax displacement is hight or your detail heightmap doesn't fit the actual detail dexture.

    Do you have proper global normalmap applied (if used as feature set in LOD manager) ? In triplanar w/o globalnormalmap this situation shouldn't happen. But if you use globalnormalmap world direction to pick the direction is taken from the global normal texture and might lead to such situations when it doesn't match (or global normal strength is set to wrong value like 0). I assume it's terrain shown.

    Tom
     
  39. Mick21

    Mick21

    Joined:
    Dec 3, 2013
    Posts:
    11
    Yes, it's globalnormalmap messing (value near 0.5 helps, but effect is barely visible). Maps seem fine. Is it possible to use both techniques? Any suggestions?

    Thank you!
     
  40. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Both of those helped a lot -- thanks so much!
     
  41. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Okay, one more question (I hope). Some splats have a weird motion-blur effect at close range--see screenshot. Can you tell me how to reduce that?
     

    Attached Files:

  42. MightyCoop

    MightyCoop

    Joined:
    Dec 10, 2012
    Posts:
    2
    That did it! Thank you very much!
     
  43. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    The question is - does your global normalmap matches the adtual terrain mesh geometry ? Global map strength is only an adjustement value, but global normalmap needs to follow mesh (terrain heights - try to achieve global normalmap from real heights that's placed on the terrain maybe). If your global normalmap doesn't have this "flat platform" we can't fix it effectively.

    Tom
     
  44. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    Experiment with parallax displacement values. It looks like we've got blended aniso and non-aniso values of colors.

    Tom
     
  45. FalconCGN

    FalconCGN

    Joined:
    Jan 18, 2014
    Posts:
    33
    Hi,

    I would love to use your plugin in a huge open world. We are currently using 12 textures per terrain on 256 chunks, which is a lot, I know. Performance drops siginifcantly if we use RTP though. Is there a way to implement RTP with a minimum feature set? If yes, what would give the best performance? How can we do this to 256 scenes at once?

    Regards,
    Sebastian
     
  46. reocwolf

    reocwolf

    Joined:
    Aug 1, 2013
    Posts:
    182
    Hi, so I guess this is a basic question but I can't seem to find a way to do it. How do I set up the size of the texture? I try doing it in the texture editor inside the unity terrain but RTP reverts it to 1x1 and when I edit the "tiling" in the RTP settings it does nothing. I want the texture to look like on the pic attached but RTP just makes it tile quite small like the sand texture in the pic. I remember that I did it right back on rtp 2 but now I just don't know.
     

    Attached Files:

    • RTP.png
      RTP.png
      File size:
      1.7 MB
      Views:
      922
  47. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    12 layers is performance dropper here. Just because you can't even use defered effectively (add pass doesn't work in deferred). For performance wise - avoid expensive features like POM, dynamic water, snow. Minimize your textures (heightmaps can be small). 256 chunks in Unity need some good custom culling system to not process them all by Unity.

    If you clip features at LOD manager they should affect all scenes because RTP shader is globalised over the project (unless you precompile your own variants and use on terrain material).

    Setting tile size in RTP/settings main should work. I see you've got independent tiling for every terrain object enabled. Do you select right terrain ?

    Anyway - in Unity5 the option for independent tiling for every terrain object is obsolete as you can use terrain materials and group your terrains in separate arents. This way every terrain can have separate parameters.

    Tom
     
  48. camel82106

    camel82106

    Joined:
    Jul 2, 2013
    Posts:
    304
    Now when Unity 5.2 is out. Is it already supported or when RTP will support it? Thanks for info.
    Camel
     
  49. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,862
    I imported newest RTP in U5.2beta (some of recent ones) and it worked for me. Anyway - new deferred reflections worked out of the box (so it's useless to enable IBL spec in LOD manager when you're in deferred - reflections will "just work" anyway).

    Tom
     
  50. jakes-du-preez

    jakes-du-preez

    Joined:
    Aug 14, 2013
    Posts:
    30
    Just want to know how the mobile version of RTP is coming on and if we can expect it this year still or only next year. Tx