1. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  2. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  3. We’re giving 2017.1 beta testers a chance to win t-shirts and a Nintendo Switch. Read more on the blog.
    Dismiss Notice
  4. We want to know how you learned Unity! Help us by taking this quick survey and have a chance at a $25 gift card
    Dismiss Notice
  5. Are you an artist or level designer going to Unite Europe? Join our roundtables there to discuss artist features.
    Dismiss Notice
  6. Unity 5.6 is now released.
    Dismiss Notice
  7. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice

Relief Terrain Pack (RTP) v3 on AssetStore

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

  1. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    256
    @tomaszek Is there an ETA for the directional light cookie issue?
     
  2. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,282
    Soon
     
    buttmatrix likes this.
  3. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    256
    So the 'floating tree' issue can be resolved if we place trees based on the original terrain heightmap data, then downscale and tessellate?
     
  4. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,282
    To solve it solid way - use 2 separate terrain data objects. One with original (hi-res) heightmap - will be used as terrain collider and vegetation (trees) renderer. For this terrain uncheck rendering in Unity terrain settings. The other terrain will render terrain surface with RTP and tessellation. This terrain data you can downscale and use high pixel error. RTP shader will refine terrian mesh using tessellation.

    Cookie problem. There is something weird I've noticed in Unity5.6 and up. On U5.5 cookies worked. Now, when inspecting rendering process in frame debugger I've noticed Unity render terrain this way (we're talking about forward rendering, in deferred cookies work):

    1. Terrain is batched to depth for shadow collecting - that's good for optimization to init depth buffer and optimize further overdraw caused by expensive terrain shader.
    2. Terrain is drawn to get ambient/GI light only - that's bad - we don't have realtime light defined (causing screwed results in shader) and this step is pure bad because we have additional pass that's not necessary at all (could be rendered with directional light together!)
    3. Terrain is drawn once again to add directional light with cookie

    Don't ask me why Unity does it like this. Anyway - beware about performance drawback.

    I will submit/upload new RTP version today, but will take sometime until it's available on AssetStore. Meantime you can fix it manually. RTP_Base.cginc and RTP_AddBase.cginc. Find this part:

    Code (csharp):
    1.  
    2. #if defined(UNITY_PASS_PREPASSFINAL) || defined(UNITY_PASS_DEFERRED) || defined(LIGHTMAP_ON)
    3. uniform float4 _WorldSpaceLightPosCustom;
    4. #endif
    5.  
    and simplify into this:

    Code (csharp):
    1.  
    2. uniform float4 _WorldSpaceLightPosCustom;
    3.  
    Then find myObjSpaceLightDir function and replace it with better one:

    Code (csharp):
    1.  
    2. inline float3 myObjSpaceLightDir( in float4 v )
    3. {
    4.    float4 lpos = _WorldSpaceLightPos0;
    5.    #if defined(DIRECTIONAL) || defined(DIRECTIONAL_COOKIE)
    6.        if (abs(dot(lpos, lpos) - 1.0) > 0.01) {
    7.            // _WorldSpaceLightPos0 undefined
    8.            lpos = _WorldSpaceLightPosCustom;
    9.        }
    10.    #endif
    11.    float3 objSpaceLightPos = mul(unity_WorldToObject, lpos).xyz;
    12.    #ifndef USING_LIGHT_MULTI_COMPILE
    13.        return objSpaceLightPos.xyz * 1.0 - v.xyz * lpos.w;
    14.    #else
    15.        #ifndef USING_DIRECTIONAL_LIGHT
    16.        return objSpaceLightPos.xyz * 1.0 - v.xyz;
    17.        #else
    18.        return objSpaceLightPos.xyz;
    19.        #endif
    20.    #endif
    21. }
    22.  
    Save, recompile shaders - should work. There are also some inconsistency moments in scripts due to conditional compilation where U2017 is not taken into account and I will fix it as well, so - you might simply wait a week for RTP3.3h to be available (these "alphamap..." errors in console are caused by the mentioned conditional compilation problem).

    ATB, Tom
     
    buttmatrix and Dwight_Everhart like this.
  5. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    256
    @tomaszek I appreciate that RTP is not officially supported in 2017.x, but I can confirm that RTP is not working as expected in 2017.1.0b1 and 2017.b1.09.

    In previous versions of Unity, after adding RTP component - Engine Terrain or Mesh, the terrain updates from the Built-In Standard material to a custom RTP material. This does not occur in 2017.x. Is there a workaround, e.g. assign custom material / shader manually to terrain? Manually assigning ReliefTerrain - First Pass shader does not overcome this issue.

    For example, 2017.1.0b1 the console prints the following error when trying to compose splats:
    *this error does appear in 2017.1.0b9

    Code (CSharp):
    1. OutOfMemoryException: Out of memory
    2. ReliefTerrainGlobalSettingsHolder.RecalcControlMaps (UnityEngine.Terrain terrainComp, .ReliefTerrain rt) (at Assets/ReliefPack/Scripts/ReliefTerrain/_Internal/ReliefTerrainGlobalSettingsHolder.cs:3082)
    3. ReliefTerrain.RecalcControlMaps () (at Assets/ReliefPack/Scripts/ReliefTerrain/ReliefTerrain.cs:451)
    4. ReliefTerrainEditor.OnInspectorGUI () (at Assets/ReliefPack/Editor/ReliefTerrain/ReliefTerrainEditor.cs:2033)
    5. UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1218)
    6. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
    Other issues:
    • Terrain2geometry workflow; splat map from terrain does not fit low poly terrain mesh UVs
    • Importing RTP terrain into existing scene with RTP causes imported terrain textures to become overexposed (broken gamma correction?)
    • terrain2geometry workflow; Unity only handles meshes with less than 65,000 verts, can RTP handle multi-subobject meshes?
    • Separate terrain data sets are affecting each other; adjusting RTP script on one terrain affects RTP settings on another terrain unexpectedly?
     
    Last edited: Jun 19, 2017
  6. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,282
    I have submitted RTP3.3h which I adjusted for Unity2017.1.0b9. I hope it will resolve most of your problems, still:

    1. Out of memory - checked in U2017 in example scene and 1k input control masks - it doesn't seem to take unrealistically high amount of RAM and I was able to compose splats for 8 layers. Can you give me more details ? How big are your input masks ?
    2. terrain2geometry workflow - you need to take care your model has 0..1x0..1uvs spanned topplanar across the rectangle mesh - like Unity terrain mesh has. Then it should make it. I believe that the issue you're refering to is not much RTP vs. Unity 2017 related. It's the way RTP shader on mesh object works.
    3. textures overexposed - hard to say. You might check sRGB flags for all textures used by RTP shader.
    4. It's up to user to provide RTP with mesh. The way you do it doesn't matter. When you export terrain to obj and reimport it as mesh Unity i9s supposed to split it into submeshes - if RTP doesn't apply the same material for all submeshes - do it yourself (copying RTP material to all of them as all submeshes shall share the same material).
    5. This is feature, not bug. If you'd like to keep it independent - place separate terrain/RTP objects into separate anchor transforms to break grouping.

    Tom
     
  7. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    256
    @tomaszek Everything is working so far since the 3.3 update, I'll keep you posted (thank you!)

    EDIT: got terrain2geometry working (9 draw calls - incredible), thank you so much!
     
    Last edited: Jun 20, 2017 at 12:01 PM
  8. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    859
    My terrain is black after lightmapping. I am in forward and tried both Enlighten and Progressive. What have I missed? I'm sure it's one check box or another. Where should I start debugging? Thanks.

    RTP_lightmap_01.PNG
     
  9. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    256
    You can see the discrepancy between the control map on the terrain versus on the low poly geo. I keep getting the following warning, "source control alpha maps should have 1024 size". I'm assuming the lower resolution splatmap (originally 2048) is responsible for this quality loss.

    Is there a workaround?

    EDIT: I can copy the RTP component on the original (high poly) terrain, paste it to geo (low poly) terrain, and compose the splats to achieve the same result. However, this will replace the composed splats on the high poly terrain, which is undesirable, but acceptable (in my case) because I'm not actually drawing the terrain. Nevertheless, I'm curious what the correct way to do this is.

    _terrain.png _geo.png
     
    Last edited: Jun 20, 2017 at 11:14 PM
  10. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,282
    This is due to lack of realtime light. As it is supposed to take the same render complexity you can add proxy/dummy light (with low intensity like 0.02) in the scene after lightmapping. I believe that RTP3.3h you can download since yesterday might solve your problem out of the box as soon as you add this light script to main directional light (either before or after baking it) - refer to my example scene to see the script attached to main directional light.

    Tom
     
  11. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,282
    Compose splatmaps for terrain, save them (they are accessible under coverage tab in RTP inspector) and reuse for mesh. I'd say different look is rather matter of detail heightblending not working the same way on mesh. Attach RTP component to mesh separately (don't copy it) and setup (reuse combined then saved detail heightmaps or drag&drop them on mesh again to rebuild combined textures used in shader).

    Tom
     
    buttmatrix likes this.
  12. buttmatrix

    buttmatrix

    Joined:
    Mar 23, 2015
    Posts:
    256
    Posting this here because the savings are incredible

    Terrain (left), geo (right). Thanks Tom!

    Screenshot (375)_terrain.png Screenshot (376)_geo.png
     
    hopeful likes this.
  13. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    354
    Im getting this error since the update.

    Assets/ReliefPack/Editor/ReliefTerrain/ReliefTerrainEditor.cs(4991,53): error CS0029: Cannot implicitly convert type `Tool' to `UnityEditor.Tool'

    this is on unity version 5.6.1f1.
     
  14. tomaszek

    tomaszek

    Joined:
    Jun 18, 2009
    Posts:
    3,282
    I remember checking newest RTP3.3 against U5.6.1 and don't have this problem. You might have installed yet another class that's named Tool which confuses compiler? Should be simple to fix (qualifying/replacing Tool occurences in script with parent UnityEditor.Tool).

    Tom
     
  15. Hynopsis

    Hynopsis

    Joined:
    Oct 25, 2012
    Posts:
    48
    So I just updated from 3.2 to 3.3e and things are quite a bit different. Mostly for the better. I'm using Unity 5.4.1. The shader options are awesome now, and good logical arrangement. I use the Standalone/Parallax Mapped Triplanar - PolyBrush shader to color my custom voxel terrain through vertex colors. For testing it just applies the 4 colors based on slope, no blending on my part (ex: Color(255,0,0,0)). In the example scene everything works fine. In my larger scene there is a weird issue, where the meshes flicker. They keep their correct texture based on there vertex color, but the appearance changes. As I move the camera around the textures change, pop and flicker. This is the same image, just after turning the camera just a little bit. At first I thought it was just the normals changing, but the actual texture positioning changes too. I reviewed the example scene and made sure every setting was exactly the same. I checked the texture settings to make sure they were identical. I made sure the deferred script was on the light, and that the triplanar script is on the parent gameobject for all terrain tiles. Am I missing something?

    Sample1.jpg
    Example.jpg
     
  16. BonsaTech

    BonsaTech

    Joined:
    Dec 22, 2015
    Posts:
    23
    Hi @tomaszek , I´ve a question about the integration between RTP and my meshes that use UBER shaders.

    Is it possible to use the geometry blend feature between a RTP terrain and a UBER mesh?
     
  17. Hynopsis

    Hynopsis

    Joined:
    Oct 25, 2012
    Posts:
    48
    I uninstalled and reinstalled everything a couple times, then played with the texture tiling and that seemed to fix it. I had it set to really high values (20) which I thought looked better. If I set it down to 12-16 to seems to make the issue go away. A question though, what does the blend UVs do on a model that doesn't have any UVs? If I use this option it starts doing the flicker again so I'm not using it even though it looks a lot better. Also I'm assuming I shouldn't use the LOD Manager script if using this shader correct?