Search Unity

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:
    39
    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,206
    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:
    39
    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:
    315
    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:
    315
    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,206
    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:
    315
    Sorry, I have stopped using TC2 in favor of Gaia.
     
  8. Seneral

    Seneral

    Joined:
    Jun 2, 2014
    Posts:
    1,206
    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,206
    Quick fix for above problem: Add
    RenderTexture.active = null;
    before the return in PaintUpdate (Core/Painting.cs, line 1703)
     
  10. led_bet

    led_bet

    Joined:
    May 5, 2015
    Posts:
    83
    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,206
    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
     
    led_bet likes this.
  12. djanssen

    djanssen

    Joined:
    Dec 10, 2014
    Posts:
    2
    Hello,

    I install Painter and get the following error, can you help me? TC2 Version 2.81.

    Assets\Node Painter\Scripts\Core\NodePainter.cs(26,47): error CS0117: 'TC_Area2D' does not contain a definition for 'current'

    Greeting, Denis
     
  13. Seneral

    Seneral

    Joined:
    Jun 2, 2014
    Posts:
    1,206
    Thanks for the mail, missed your post.
    Have finally submitted a new version fixing all of the issues mentioned here since the last update (sorry it took so long).
    Should be live sometime in the next week(s) - not sure how long it takes these days.
    Please update TC2 with this update if you have not already, the recent TC2 update renamed somthing and without preprocessor compiles I could only break compability with older TC2 versions (however it's easy to revert, added some notes in case you get an error).

    As always, here's the changelog:

    Version 1.2.2 (27.09.2020)

    - Fixed TC2 compability error due to rename (revert for older versions of TC2)
    - Added support for custom UI scaling in 2019.3 and upward
    - Changed gaussian brush to completely fall down to 0 at edges to prevent seams after prolonged painting
     
    led_bet likes this.
  14. vlastan

    vlastan

    Joined:
    Nov 15, 2015
    Posts:
    49
    @Seneral First of all, thanks for your wonderful addition to tc2.
    I am using node painter a lot, however i have a small problem i'd like to find out how to solve:
    The realtime brush preview in the editor view is not showing up in my project.
    I can click and paint over the terrain with the proper results, however i can't see the area of the brush.

    Are there any common scenarios that may prevent the preview brush to not appear in scene view?
     
    Last edited: Jul 14, 2021
  15. Seneral

    Seneral

    Joined:
    Jun 2, 2014
    Posts:
    1,206
    Hi, had a similar report previously but I wasn't able to reproduce it and it went stale.
    Can you test if canvas visualization works - click on the eye button next to the title above the canvas preview. Make sure you have a lot painted to be able to see it clearly.
    If that works that should most likely rule out any kind of shader incompability, although that shouldn't be the case here since the other case was on DX12 and I am too.
    Also can you test the actual brush projector prefab at Node Painter/EditorResources/Visualization/BrushProjector? It should have parameters to make it appear after you scale the projection volume and project it on meshes / terrain.
    Just to make sure, which Unity version are you using? Though in the other case we used the same version so it's likely not involved.
     
  16. Markklarsen

    Markklarsen

    Joined:
    Aug 28, 2016
    Posts:
    8
    Hello @Seneral any plan to make a URP brush to tc2 note painter?
     
  17. Seneral

    Seneral

    Joined:
    Jun 2, 2014
    Posts:
    1,206
    This tool works independently of what render pipeline you use to render the terrain, it only helps create it
     
  18. Markklarsen

    Markklarsen

    Joined:
    Aug 28, 2016
    Posts:
    8
    Yea i know i works independently of what render pipeline you use, but the brush visual/ preview on the terrain is using projector component to show the brush, but the projector component only works in the build in render pipeline, there is Decal Renderer Feature for URP but then the shader and scripts need to be changed to work with that
     
    Last edited: Apr 7, 2022