Search Unity

Terrain Hole System

Discussion in 'Assets and Asset Store' started by Venryx, May 13, 2013.

  1. BattleSheep94

    BattleSheep94

    Joined:
    Sep 7, 2019
    Posts:
    3
    Hey Guys, sorry for my Grammar, my English is not the Best.
    I have a Game with a Base Building System Luke in Rust and i want that the players can build a cellar/basement or a bunker under the Base.
    I think about to add a Block to Cut out These Block in the Terrain, is this possible with this asset?
     
  2. alex_1302

    alex_1302

    Joined:
    Aug 20, 2019
    Posts:
    54
    Hi. i have a question about the shader. When i imported the hole terrain shader, i noted that the default unity builtin shader (FirstPass.shader) was renamed. I watched that in the new shader no longer exists the line:
    col = splat_control.r * tex2D (_Splat0, IN.uv_Splat0).rgb
    The problem is that i want to change the firstPass.shader according to this thread:
    https://forum.unity.com/threads/improved-terrain-texture-tiling.116509/
    in order to reduce the terrain tiling, and i dont want to loose the transparency effect (coming back to the original shader). Is that possible?. How ?
    Thanks in advance.
     
  3. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    I'm sorry, but I don't have the time/motivation to upkeep the plugin anymore. (haven't done significant work in Unity for years)

    Since the plugin appears to have issues in the latest versions of Unity (as per the last two posts on page 4), I've now added a note to the plugin's store page mentioning it. (awaiting review)

    As for your specific question @unity_ap6_UEv3h46J3A: I don't have a clear answer for how to merge the transparency shader with the tiling shader, but if you have some basic experience with shader editing, you may be able to manually merge the two by following some hints, as present in the "Terrain Hole System/Documentation/ShaderMerging.txt" file. It's for an older version of the shader, but it provides some comments that might be helpful.

    Sorry for the inconvenience. That said, there appear to be some other extensions available nowadays for making holes in terrain, such as:
    1) https://assetstore.unity.com/packages/tools/terrain/microsplat-terrain-holes-97495
    2) https://assetstore.unity.com/packages/tools/terrain/relief-terrain-pack-v3-3-5664
    3A) https://assetstore.unity.com/packages/tools/terrain/cts-complete-terrain-shader-91938
    3B) https://assetstore.unity.com/packages/tools/terrain/cts-2019-complete-terrain-shader-140806
     
  4. alex_1302

    alex_1302

    Joined:
    Aug 20, 2019
    Posts:
    54
    HI. thanks for your reply. maybe you can help me to solve my problem:
    inside your shader (firstPass.shader) is a line:
    o.Smoothness = mixedDiffuse.a;

    I see the problem is that i modified the splatmapmix function located inside terrainsplattmapcommon.cginc in such way that the value of mixedDiffuse has changed from this:

    mixedDiffuse += splat_control.r * tex2D(_Splat0, IN.uv_Splat0) * half4(1.0, 1.0, 1.0, defaultAlpha.r);
    mixedDiffuse += splat_control.g * tex2D(_Splat1, IN.uv_Splat1) * half4(1.0, 1.0, 1.0, defaultAlpha.g);
    mixedDiffuse += splat_control.b * tex2D(_Splat2, IN.uv_Splat2) * half4(1.0, 1.0, 1.0, defaultAlpha.b);
    mixedDiffuse += splat_control.a * tex2D(_Splat3, IN.uv_Splat3) * half4(1.0, 1.0, 1.0, defaultAlpha.a);

    to this:

    mixedDiffuse += splat_control.r * .5 * (tex2D(_Splat0, IN.uv_Splat0) + tex2D(_Splat0, IN.uv_Splat0 * -.25));
    mixedDiffuse += splat_control.g * .5 * (tex2D(_Splat1, IN.uv_Splat1) + tex2D(_Splat1, IN.uv_Splat1 * -.25));
    mixedDiffuse += splat_control.b * .5 * (tex2D(_Splat2, IN.uv_Splat2) + tex2D(_Splat2, IN.uv_Splat2 * -.25));
    mixedDiffuse += splat_control.a * .5 * (tex2D(_Splat3, IN.uv_Splat3) + tex2D(_Splat3, IN.uv_Splat3 * -.25));

    clearly that is affecting the above o.smoothness line. so my question is: how can i make that the expression o.smoothness dont be affected ?

    Thanks in advance.
     
  5. Venryx

    Venryx

    Joined:
    Sep 25, 2012
    Posts:
    444
    Are you sure that the changes shown above are the cause of the transparency not working?

    From what I can see of that code block, all it's doing is changing the texture-lookup from reading from a single location, to instead reading from two locations and averaging the values. That is: 0.5 * (ValAtPosA + ValAtPosB) = "average vals at pos a and b"

    So I think the transparency not working is from some other cause within the shaders.
     
    halcyonideals likes this.
  6. halcyonideals

    halcyonideals

    Joined:
    Nov 10, 2013
    Posts:
    16
    thankyou Venryx for giving me so much capability that I didn't have before in Unity! I've used your system for years and it's been greatly appreciated.
     
  7. Recon03

    Recon03

    Joined:
    Aug 5, 2013
    Posts:
    845
    also you can do in Unity your self in 2019.3 as well.