Landscape, grass and snow Lerpa cities: Skaliny

I am working on season patterns for cities: Skylines. My path is good and I found a way to change the texture of the earth to snow using

mat.SetTexture("_TerrainGrassDiffuse", grassTexture); 

So this is normal, but I do not want a hard cut between the seasons. So I came up with this idea: flying between the snow and the texture of the grass. I searched a lot, but I did not come up with anything that works. So I want the lerp to disappear in the snow texture and fade out the grass texture for a certain amount of time, so I think there is a puppy here. I do not have access to the shader, its mod, and I will need decompilation for this. I tried to use

 someMat.Lerp(); 
but I don't know which material I need to use for the someMat. Thanks for help!
+5
source share
1 answer

First of all, I would like to note that someMat.Lerp(); - this is not a solution to the problem. The material Lerp() function is used to change colors while preserving the original shader and textures. Since you want to mask the texture, this is not the case.

Moreover, I do not think that there is a way to build textures in unity. But it looks like you can use a shader to get around this problem. After a short trip to Google, I found this UnityScript source solution, with a simple and nice example of a solution implemented in a shader

The shader and related code example can also be seen below.

 public void Update () { changeCount = changeCount - 0.05; textureObject.renderer.material.SetFloat( "_Blend", changeCount ); if(changeCount <= 0) { triggerChange = false; changeCount = 1.0; textureObject.renderer.material.SetTexture ("_Texture2", newTexture); textureObject.renderer.material.SetFloat( "_Blend", 1); } } } 

and the sample shader indicated on the blog:

 Shader "TextureChange" { Properties { _Blend ("Blend", Range (0, 1) ) = 0.5 _Color ("Main Color", Color) = (1,1,1,1) _MainTex ("Texture 1", 2D) = "white" {} _Texture2 ("Texture 2", 2D) = "" _BumpMap ("Normalmap", 2D) = "bump" {} } SubShader { Tags { "RenderType"="Opaque" } LOD 300 Pass { SetTexture[_MainTex] SetTexture[_Texture2] { ConstantColor (0,0,0, [_Blend]) Combine texture Lerp(constant) previous } } CGPROGRAM #pragma surface surf Lambert sampler2D _MainTex; sampler2D _BumpMap; fixed4 _Color; sampler2D _Texture2; float _Blend; struct Input { float2 uv_MainTex; float2 uv_BumpMap; float2 uv_Texture2; }; void surf (Input IN, inout SurfaceOutput o) { fixed4 t1 = tex2D(_MainTex, IN.uv_MainTex) * _Color; fixed4 t2 = tex2D (_Texture2, IN.uv_MainTex) * _Color; o.Albedo = lerp(t1, t2, _Blend); o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); } ENDCG } FallBack "Diffuse" } 
+1
source

Source: https://habr.com/ru/post/1236235/


All Articles