Unity 2018.1.2f1 doesn't apply textures to material if I use HDRenderPipeline.
I have been following the tutorial series for procedural landmass generation by Sebastion Lague, but I've ran into an issue, the textures the scripts create won't apply into my material, HOWEVER it works without the High Definition Render Pipeline, but if I have that on it doesn't apply the textures to the material, I guess it's something to do with the shader changing from Standard to HDRenderPipeline/Lit, so does the HDRenderPipeline/Lit use some other method to set textures, than this:
public Renderer textureRenderer;
public MeshFilter meshFilter;
public MeshRenderer meshRenderer;
public void DrawTexture(Texture2D texture)
{
textureRenderer.sharedMaterial.mainTexture = texture;
textureRenderer.transform.localScale = new Vector3(texture.width, 1, texture.height);
}
public void DrawMesh(MeshData meshData, Texture2D texture)
{
meshFilter.sharedMesh = meshData.CreateMesh();
meshRenderer.sharedMaterial.mainTexture = texture;
}
public static Texture2D TextureFromColorMap(Color[] colorMap, int width, int height)
{
Texture2D texture = new Texture2D(width, height);
texture.filterMode = FilterMode.Point;
texture.wrapMode = TextureWrapMode.Clamp;
texture.SetPixels(colorMap);
texture.name = "Map";
texture.Apply();
return texture;
}
public static Texture2D TextureFromHeightMap(float [,] heightMap)
{
int width = heightMap.GetLength(0);
int height = heightMap.GetLength(1);
Color[] colorMap = new Color[width * height];
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
colorMap[y * width + x] = Color.Lerp(Color.black, Color.white, heightMap[x, y]);
}
}
return TextureFromColorMap(colorMap, width, height);
}
Your answer
Follow this Question
Related Questions
Material.SetTexture doesn't work if not "_MainTex" 0 Answers
Changing color on specific tile in texture at runtime 0 Answers
How to make a 'Simple Texture 2D LOD' infinite using a Shader Graph ? 0 Answers
How do I get smooth edges for a voxel game? 1 Answer
How to add texture to a cube sphere? 0 Answers