Open ddutchie opened 5 years ago
Okay, I figured something out. Might be useful to convert to shader, but works quite well.
First, pass in old float array, create new float array from stamp (resize to right resolution) Apply float values.
Return the new float array
public float[] ApplyClamp(float[] map, Texture2D overlay)
{
Texture2D resized = Resize(overlay, (int)Mathf.Sqrt(map.Length), (int)Mathf.Sqrt(map.Length));
Color[] cs = resized.GetPixels();
for (int i = 0; i < cs.Length; i++)
{
map[i] *= cs[i].r;
}
return map;
}
public static Texture2D Resize(Texture2D source, int newWidth, int newHeight)
{
source.filterMode = FilterMode.Bilinear;
RenderTexture rt = RenderTexture.GetTemporary(newWidth, newHeight);
rt.filterMode = FilterMode.Point;
RenderTexture.active = rt;
Graphics.Blit(source, rt);
Texture2D nTex = new Texture2D(newWidth, newHeight);
nTex.ReadPixels(new Rect(0, 0, newWidth, newWidth), 0, 0);
nTex.Apply();
RenderTexture.active = null;
return nTex;
}
Could be a way to add peaks and stamp specific features. These could also be generated with noise. Or texture based.
Hello There.
I am looking to integrate this into a infinite runner type game. What I would like to do do is create a couple of base textures with a road in the middle.
And stamp/blend this into the overall result so I can have control over the ground level of my runner.
Is this currently possible or do I need to blit the images together with a custom shader?
Regards