Home Unity

High Res Terrain Painting on Low Res Terrain

iRoller
vertex
Offline / Send Message
iRoller vertex
I watched a video about WoW's engine from the latest blizzcon. They showcased their terrain painting features and I was really curious as to how they were able to paint textures onto very low res terrain in high detail. With Unity, as far as I know you can only really paint terrain in square tiles. In their engine, they painted the textures with a circular brush and they could do it at a very low scale. Here's the video of it, on the right side - at about 20:13 there's a fairy decent view of it. https://youtu.be/eYDd3T_s1zo?t=1213 if anyone has any insight as to how this is done that'd be great. Thanks.

Replies

  • Eric Chadwick
    I do this in Unity for my day job. Have you tried the Terrain tools in Unity?

    You can paint with a variety of brush shapes; circle is only the default.

    You're painting the transitions between textures, which are being tiled across the terrain.

    In our game, we use a custom terrain shader I made that uses the tiled textures to add detail in the transition areas. Ordinarily it's a linear blend, but that looks boring, and unnatural.

    Anyhow some pics in my sketchbook.
    http://polycount.com/discussion/160691/sketchbook-eric-chadwick
  • iRoller
    Offline / Send Message
    iRoller vertex
    How would I go about getting alpha blending like seen in this tutorial http://www.blog.radiator.debacle.us/2013/09/hacking-blend-transition-masks-into.html with ShaderForge? The code there is outdated and doesn't seem to work. I'm trying to get a result like seen in the video above. Does using heightmaps like they show in that video allow for you to make completely circular paints of a small scale? Example of it at 7:59 where he paints sand over it and it does not paint in chunks like unity does..
  • Eric Chadwick
    The circular painting brush is there in the default Unity terrain painting system, and I can paint smoothly with it. It depends on the brush settings Opacity and Transfer.

    Maybe your computer is too slow to paint properly?

    And are you using a tablet or a mouse? Tablet makes a huge difference in control and subtlety.

    I put screenshots in my thread about how to setup Shader Forge to make a modulated heightblend shader.

    Though I went a slightly different route than the blog you linked... I don't use an alpha channel. I use only one texture to store four terrain textures, in red green blue and alpha channels. Then I use each one for both color and height.
  • iRoller
    Offline / Send Message
    iRoller vertex
    I'm using a mouse and my computer being too slow is certainly not a problem. If you were to paint at a brush size of 1, using any of the circular brushes, it would show up as a circle of texture painted onto the terrain? Because I can only paint in squares with a circle brush and a circle brush only shows up as a square for me at a small scale.. thanks
  • Eric Chadwick
    Ah. It sounds like you've hit the resolution limit of your splat map. You're painting individual pixels of it. You need to increase the resolution of your terrain, if you want really small circles. That's "Control Texture Resolution" in the terrain settings.

    But ultimately this is not what you want, if you're making a terrain for an actual game. You don't want a super high-resolution splat map, because that will be too expensive in memory, and also balloon your download size.

    The trick is to use as low resolution as you can, and still make it look good. The never-ending game art quandry.

    So to that end, the heightmap modulation shader is a good solution. You use a fairly low-res splatmap, and rely on the heightmaps to provide detail in the blends. The downside of this is you can't get 1-pixel control for your terrain painting. You just have to do as good as you can, and let the textures do the rest. Lightmapping helps a lot, good material colors, etc.

  • iRoller
    Offline / Send Message
    iRoller vertex
    It just doesn't make sense to me how WoW's engine is allowing them to paint as if a pixel limit didn't exist... It seems as if they can paint circular sections with a very low brush size and not have to worry about anything like control texture resolution. Also, I'm very new to Shader Forge and I have no clue where to start setting up a shader that will allow me to do heightmap blending for terrain. 
  • Eric Chadwick
    The circle brush in the video did not look that small, relative to the size of a character. I bet their splatmap is no more than 10 pixels per meter, or thereabouts.

    The shader is in my sketchbook thread.
  • iRoller
    Offline / Send Message
    iRoller vertex
    I tried using the shader from http://www.blog.radiator.debacle.us/2013/09/hacking-blend-transition-masks-into.html, and something is certainly happening but not as intended. The grass texture (alpha channel) has a yellowish outline on it when it's painted.
    https://gyazo.com/e40157bfea9285b7f321cf2b213b1dd9
    and here's what the shader's properties are set as:
    https://gyazo.com/62c95d9a65e23bf1adc9670ec349c168 The terrain palette is properly setup as well with grass being 4th or alpha. Any help would be appreciated
    Here's the shader code:
    <div>Shader "Nature/Terrain/Standard" {</div><div>Properties {</div><div>&nbsp; [HideInInspector] _Control ("Control (RGBA)", 2D) = "red" {}</div><div>	[HideInInspector] _Splat3 ("Layer 3 (A)", 2D) = "white" {}</div><div>	[HideInInspector] _Splat2 ("Layer 2 (B)", 2D) = "white" {}</div><div>	[HideInInspector] _Splat1 ("Layer 1 (G)", 2D) = "white" {}</div><div>	[HideInInspector] _Splat0 ("Layer 0 (R)", 2D) = "white" {}</div><div>	// used in fallback on old cards & base map</div><div>	[HideInInspector] _MainTex ("BaseMap (RGB)", 2D) = "white" {}</div><div>	[HideInInspector] _Color ("Main Color", Color) = (1,1,1,1)</div><div>}</div><div>	</div><div>SubShader {</div><div>	Tags {</div><div>		"SplatCount" = "4"</div><div>		"Queue" = "Geometry-100"</div><div>		"RenderType" = "Opaque"</div><div>	}</div><div>CGPROGRAM</div><div>#pragma target 4.0</div><div>#pragma surface surf Lambert</div><div>struct Input {</div><div>	float2 uv_Control : TEXCOORD0;</div><div>	float2 uv_Splat0 : TEXCOORD1;</div><div>	float2 uv_Splat1 : TEXCOORD2;</div><div>	float2 uv_Splat2 : TEXCOORD3;</div><div>	float2 uv_Splat3 : TEXCOORD4;</div><div>};</div><div><br></div><div>sampler2D _Control;</div><div>sampler2D _Splat0,_Splat1,_Splat2,_Splat3;</div><div><br></div><div>void surf (Input IN, inout SurfaceOutput o) {</div><div>	fixed4 splat_control = tex2D (_Control, IN.uv_Control);</div><div>	fixed3 col;</div><div>	col &nbsp;= splat_control.r * tex2D (_Splat0, IN.uv_Splat0).rgb;</div><div>	col += splat_control.g * tex2D (_Splat1, IN.uv_Splat1).rgb;</div><div>	col += splat_control.b * tex2D (_Splat2, IN.uv_Splat2).rgb;</div><div>	col = col * clamp(pow(1 - splat_control.a * 1.1 - splat_control.a * tex2D (_Splat3, IN.uv_Splat3).a, 3.4), 0, 1) + tex2D (_Splat3, IN.uv_Splat3).rgb * clamp(splat_control.a * 3.0 + splat_control.a * tex2D (_Splat3, IN.uv_Splat3).a * 4, 0.0, 1.0);</div><div>	o.Albedo = col;</div><div>	o.Alpha = 0.0;</div><div>}</div><div>ENDCG &nbsp;</div><div>}</div><div><br></div><div>Dependency "AddPassShader" = "Hidden/TerrainEngine/Splatmap/Lightmap-AddPass"</div><div>Dependency "BaseMapShader" = "Diffuse"</div><div>Dependency "Details0" &nbsp; &nbsp; &nbsp;= "Hidden/TerrainEngine/Details/Vertexlit"</div><div>Dependency "Details1" &nbsp; &nbsp; &nbsp;= "Hidden/TerrainEngine/Details/WavingDoublePass"</div><div>Dependency "Details2" &nbsp; &nbsp; &nbsp;= "Hidden/TerrainEngine/Details/BillboardWavingDoublePass"</div><div>Dependency "Tree0" &nbsp; &nbsp; &nbsp; &nbsp; = "Hidden/TerrainEngine/BillboardTree"</div><div><br></div><div>// Fallback to Diffuse</div><div>Fallback "Diffuse"</div><h2><pre class="CodeBlock"><code>}

  • Eric Chadwick
    The blog post is more than 3 years old. The shader might not work properly with the current version of Unity, as a lot of tools and such do tend to break between version upgrades, and need to be fixed by the authors to work properly again.

    You could try using the Unity version that was current then, or you could contact the author and ask for help, or you could make your own shader and use the current Unity build (this is what I did for my own terrain).
Sign In or Register to comment.