public static Texture CreateDummyHeightTextureDependentOnPixelPosition(SegmentInformation segmentInformation, float offset, float stepMultiplier) { var tex = new Texture2D(240, 240, TextureFormat.RFloat, false); float[] rawTextureData = new float[tex.width * tex.height]; for (int x = 0; x < tex.width; x++) { for (int y = 0; y < tex.height; y++) { rawTextureData[x + y * tex.width] = offset + ((x + y * 4) / 400f) * stepMultiplier; } } tex.LoadRawTextureData(CastUtils.ConvertFloatArrayToByte(rawTextureData)); tex.Apply(); return(tex); }
public static Texture CreateDummyHeightTextureDependentOnWorldSpacePosition(MyRectangle worldSpaceRectangle, float repreatLength) { var tex = new Texture2D(240, 240, TextureFormat.RFloat, false); float[] rawTextureData = new float[tex.width * tex.height]; for (int x = 0; x < tex.width; x++) { for (int y = 0; y < tex.height; y++) { var uvInTexture = new Vector2(x / 240f, y / 240f); var worldSpacePosition = worldSpaceRectangle.SampleByUv(uvInTexture); rawTextureData[x + y * tex.width] = Mathf.Repeat(worldSpacePosition.x + worldSpacePosition.y * 4, repreatLength) / repreatLength; } } tex.LoadRawTextureData(CastUtils.ConvertFloatArrayToByte(rawTextureData)); tex.Apply(); return(tex); }