- Home /
Terrain Grass Detail Texture Atlas
Hello,
Is there a way to get access to the texture atlas of terrain details (grass textures) ?
I already figured out that I can access every detail texture separately by terrain.terrainData.detailPrototypes[index].prototypeTexture,
but I want to know the Rects on the texture atlas that is send by the terrain to the shader.
I tried to make my own Texture Atlas using Texture2D.PackTextures method but textures are layout different than in the original texture atlas.
This is how looks detail texture atlas made by Unity Terrain:
And this is how looks texture atlas made by me using Texture2D.PackTextures:
As you can see this does not line up (I care about the sizes not the color).
There is the script I wrote to generate the Texture Atlas:
DetailPrototype[] prototypes = terrain.terrainData.detailPrototypes;
Texture2D atlas = new Texture2D(terrain.terrainData.detailWidth,
terrain.terrainData.detailHeight);
Texture2D[] atlasTextures = prototypes.ToList().Select(x =>
new Texture2D(x.prototypeTexture.width, x.prototypeTexture.height)
).ToArray();
Rect[] rects = atlas.PackTextures(atlasTextures, 1, terrain.terrainData.detailWidth);
Your answer
Follow this Question
Related Questions
Terrain Grass texture transparancy not working 0 Answers
Problem with Terrain.SampleHeight 0 Answers
Hide Grass Details 1 Answer
Custom Terrain Details Shader,Custom Detail Shader In 2019.2 2 Answers
How Do I Fix My Grass? 2 Answers