Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

TC2 Node Painter - The TC2 extension for painting the world!

Discussion in 'Assets and Asset Store' started by Seneral, Feb 5, 2017.

  1. CoughE

    CoughE

    Joined:
    Oct 26, 2015
    Posts:
    24
    Correct, the maximum height is visual only, it doesnt paint that height onto the node. On refresh the node appears as normal, as if it painted the new height correctly.


    Undo and redo does not appear to work reliably. I can paint some on the node,and when it happens I can undo to remove the maximum height. But clicking undo again selects the terrain I am currently drawing on.

    This is the example I am drawing on, I deleted the textures a while back since unity kept annoyingly creating a terrainupgrade folder in my hiearchy, but it happens with other terrain textures too, so dont think thats a problem.

    Painting directly on the node does not produce the issue.

    Only other asset I have that might affect it is RealtimeCSG (it is turned off though)

    If you need me to make any more gifs of it just let me know!

    Unity version is 2019.1.0f2


    I am getting this error when it paints like that.
    Code (CSharp):
    1. IndexOutOfRangeException: Index was outside the bounds of the array.
    2. TerrainComposer2.TC_Generate.ComputeHeight (UnityEngine.Rect generateRect) (at Assets/Plugins/TerrainComposer2/Scripts/Generate/TC_Generate.cs:1144)
    3. TerrainComposer2.TC_Generate.Compute (TerrainComposer2.TCUnityTerrain tcTerrain, System.Int32 outputId, UnityEngine.Rect generateRect) (at Assets/Plugins/TerrainComposer2/Scripts/Generate/TC_Generate.cs:267)
    4. TerrainComposer2.TC_Generate.GenerateOutput (TerrainComposer2.TCUnityTerrain tcTerrain, System.Int32 outputId, System.Boolean instantGenerate, UnityEngine.Rect generateRect) (at Assets/Plugins/TerrainComposer2/Scripts/Generate/TC_Generate.cs:507)
    5. TerrainComposer2.TC_Generate.GenerateHeight (TerrainComposer2.TCUnityTerrain tcTerrain, System.Boolean instantGenerate, UnityEngine.Rect generateRect, System.Boolean disableTerrain) (at Assets/Plugins/TerrainComposer2/Scripts/Generate/TC_Generate.cs:527)
    6. TerrainComposer2.TC_Generate.Generate (TerrainComposer2.TCUnityTerrain tcTerrain, System.Boolean instantGenerate, UnityEngine.Rect generateRect) (at Assets/Plugins/TerrainComposer2/Scripts/Generate/TC_Generate.cs:449)
    7. TerrainComposer2.TC_Generate.Generate (System.Boolean instantGenerate, UnityEngine.Rect generateRect, System.Int32 outputId) (at Assets/Plugins/TerrainComposer2/Scripts/Generate/TC_Generate.cs:423)
    8. TerrainComposer2.TC_Generate.MyUpdate () (at Assets/Plugins/TerrainComposer2/Scripts/Generate/TC_Generate.cs:186)
    9. UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:200)
    10.  
    11.  
    edit
    I can perform resize or undo modifications but am unable to undo them
     
    Last edited: Jul 16, 2019
  2. Seneral

    Seneral

    Joined:
    Jun 2, 2014
    Posts:
    1,192
    Ah yes Undo is NOT integrated into the default undo system. So in order to undo, you need to use the buttons, Ctrl-Z does not work unfortunately. Reason being that I'm handling potentially large textures here and I'd rather manage them myself and not have unity crash after 50+ undos because you ran out of memory.
    There would be an alternative way of using custom undo with Ctrl-Z which I might actually integrate. It would add several hundred lines of not-so-nice code though, since it's a bit hacky (see my script UndoPro).
    Anyway, that on the topic of undo, if there's interest I'll try to add Ctrl-Z undo.

    Ok so painting in the scene view causes a scene redraw at unwanted times (generally not a problem as GUI drawing also causes a scene redraw). That in turn causes some unwanted values in the visualization textures. And for some reason, it is way more severe for you than normal.
    I'll try to test and adjust the timing of everything, but even with unfavourable timing it should not interfere. I'm pretty sure I double-checked that all RenderTextures's are handled correctly. Was a while ago though so I guess I'll have to triple-check.
    Thanks for reporting!
     
  3. CoughE

    CoughE

    Joined:
    Oct 26, 2015
    Posts:
    24
    No worries, the undo style makes sense. Now that I know it's no big deal to just use the buttons!

    Thanks for being so fast in your response and willing to help out! If you need me to guinie-pig anything when you have time, just give me a holler!
     
  4. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    169
    Frequently getting this error. Caused by creating a node, adding NodePainter, then painting on the terrain.

    IndexOutOfRangeException: Index was outside the bounds of the array.
    TerrainComposer2.TC_Generate.ComputeHeight (UnityEngine.Rect generateRect) (at Assets/TerrainComposer2/Scripts/Generate/TC_Generate.cs:1144)
    TerrainComposer2.TC_Generate.Compute (TerrainComposer2.TCUnityTerrain tcTerrain, System.Int32 outputId, UnityEngine.Rect generateRect) (at Assets/TerrainComposer2/Scripts/Generate/TC_Generate.cs:267)
    TerrainComposer2.TC_Generate.GenerateOutput (TerrainComposer2.TCUnityTerrain tcTerrain, System.Int32 outputId, System.Boolean instantGenerate, UnityEngine.Rect generateRect) (at Assets/TerrainComposer2/Scripts/Generate/TC_Generate.cs:507)
    TerrainComposer2.TC_Generate.GenerateHeight (TerrainComposer2.TCUnityTerrain tcTerrain, System.Boolean instantGenerate, UnityEngine.Rect generateRect, System.Boolean disableTerrain) (at Assets/TerrainComposer2/Scripts/Generate/TC_Generate.cs:527)
    TerrainComposer2.TC_Generate.Generate (TerrainComposer2.TCUnityTerrain tcTerrain, System.Boolean instantGenerate, UnityEngine.Rect generateRect) (at Assets/TerrainComposer2/Scripts/Generate/TC_Generate.cs:449)
    TerrainComposer2.TC_Generate.Generate (System.Boolean instantGenerate, UnityEngine.Rect generateRect, System.Int32 outputId) (at Assets/TerrainComposer2/Scripts/Generate/TC_Generate.cs:423)
    TerrainComposer2.TC_Generate.MyUpdate () (at Assets/TerrainComposer2/Scripts/Generate/TC_Generate.cs:186)
    UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:303)
     
  5. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    169
    50% of my clicks in the scene view go straight to max value, although clicking that same spot again fixes the issue

    upload_2019-9-24_15-57-27.png
     
  6. Seneral

    Seneral

    Joined:
    Jun 2, 2014
    Posts:
    1,192
    The error is known to pop up sometimes, but I can never consistently reproduce it. It is harmless though.
    That is odd - sounds like it is not an error in painting (as it pops back after another update/paint, if I understand correctly).

    Still, you seem to be painting in singular pixels here with a pretty high intensity. When painting with such a small brush size compared to pixels I can confirm that it will only paint when you paint over the center of the pixel - this can occur as jumping to a very high value suddenly while not painting at all otherwise. Is it correct that it is definitely not that issue?

    When it jumps to such a high value, do you see it as a bright spot in the preview as well? What if you only regenerate TC2 now, is it still there?
     
  7. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    169
    Sorry, I have stopped using TC2 in favor of Gaia.
     
  8. Seneral

    Seneral

    Joined:
    Jun 2, 2014
    Posts:
    1,192
    Btw have been able to reproduce this now on a new install, will try to fix this asap.
     
  9. Seneral

    Seneral

    Joined:
    Jun 2, 2014
    Posts:
    1,192
    Quick fix for above problem: Add
    RenderTexture.active = null;
    before the return in PaintUpdate (Core/Painting.cs, line 1703)
     
  10. ledbetterman

    ledbetterman

    Joined:
    May 5, 2015
    Posts:
    75
    Hey Seneral, TCNode is sweet! This is the best of both worlds - procedural generation and hand painting. Thanks for all of your hard work.

    Wanted to give you a heads up about a small issue I've encountered. After painting continuously for a few seconds, the brush begins cutting square shapes into the terrain. TC2 appears to be updating, just not accurately. I have "auto" set to on in the TC2 and in the TC2 node settings. Turning Auto off in TC2 prevents incremental updates, though I know TC2 Node is pushing update requests because the Auto button blinks red in the layer panel when I paint. Manually generating from the TC2 layer panel cleans up any of these square artifacts and the terrain reflects the height maps as expected. Turning off Continuous Painting appears to fix this issue.

    One small question about TC2 in general. I've always struggled to add valleys to TC2. I think because the terrain starts at absolute zero by default (even when giving the terrain creation a positive Y value). Is there a way to set it so that the terrain sits in the middle of its highest and lowest value? I know this is probably outside the scope of TC2 and I should ask Eagle555 for their input, but I figured you might also know considering the nature of TC2 Node Painter.
     
  11. Seneral

    Seneral

    Joined:
    Jun 2, 2014
    Posts:
    1,192
    Hey, thanks for the nice words!
    Seems that is caused by the gaussion function that is used as a brush. On one side, the brush value never truly goes to zero, but on the other side a tight rectangle around the brush to limit the area TC2 needs to generate is an important part of optimizations. So I just modified the gaussian brush to always stay within the blue circle, the way it is supposed to be.
    For a quick fix, modify these two lines in Shaders/Painting/PaintUtility.cginc respectively:
    Code (csharp):
    1. // Shaders/Painting/PaintUtility.cginc l. 167
    2. brushValue += testEquals(_brushType, 1) * max(0, gaussian(calcFalloff(uv * 4)) - gaussian(1.9f*1.9f-_brushFalloff));
    3. // Shaders/Painting/PaintUtility.cginc l. 230
    4. return max(0, gaussian(calcFalloff(uv * 4)) - gaussian(1.9f*1.9f-_brushFalloff));

    As for valleys, there are some workarounds but they depend on your situation. Given the height painting example scene, here's how to make a valley extending 250 below the terrain as it is now:
    First Extend the terrain downwards (so that existing terrain stays in same world space position, but it is lower):
    - Consider increasing the size by the extended amount in "Terrain Area/Size" tab by 250 and apply
    - Set Terrain Area position to -250 and you'll see the terrain go up by 250 (why? idk. But it doesn't reset on generate, unlike Terrain transform)
    - Now set the node height of the height painting node to -250 (or use a constant node to fix the offset)
    Then extend the height painting node down in a similar fashion:
    - Use Modifications to add height (if you input 0.25 and the node size y is 1000, you'll add 250 units) and apply (beware of hitting the ceiling, if that happens, scale down at the same time and increase node scale to compensate).
    - Now modify the node height once more and substract 250 (if you modified it before, it should now be -500)
    You should now once more have the original terrain you started with. But now both the terrain and the painter have been extended downwards. Now you can use the painter to create a 250 unit deep valley.

    Hope that helps.
    Seneral
     
unityunity