I want to extract textures from a texture array as I want to edit them (the array comes with an asset bought from the asset store so I don't have the original textures).
The only way I can think to to it is to use the TextureArray class to scroll through each texture and each mip level of the texture and send the data to a render texture.
Is there another way?
Related
I have a for loop, where I iterate and load each texture into an array of [MTLTexture?]. However, now it's just one MTLTexture whose type is set to MTLTextureType.type2DArray. What's the cleanest way to load textures from files into this texture 'array?'
Create the texture2d_array, then loop and load the individual array slice data with replace, where slice is your array index. That's the way to do things so that Metal (or any other graphics API in fact) can apply certain optimisations to the memory layout, for example. On GPU, texture data is usually stored different than plain data so that common operations such as sampling are quicker.
I have some texture - a square picture with the painted bricks. And I want to create the element I will use as an obstacles - usual platformer's walls - in my game. So, I can't understand, how can I create this game object? For example, in 3D I can jus to create an object - for example, cube - and drag'n'drop my texture to this object. But in 2D I can't do the same steps. In 2D, as I understand, I need to create a new game object - sprite - and... what next? Drag'n'drop in this case doesn't work, sprite renderer has some fields I think I need to use - 'Sprite' and 'Matherial", but I can't understand, what exactly I need to do with my texture to have the ability use it here and how exectly I need to use it.
You mean this?
public Texture2D myTexture; // Assuming that it has been linked to a texture imported into your project by drag-n-dropping that texture onto this property using Inspector window
void Start ()
{
gameObject.renderer.material.mainTexture = myTexture;
}
In the image/texture import settings you can choose between many different options, for example: Texture or Sprite.
Sprite takes in sprite image
RawImage takes in pure texture
Image takes in sprite image.
Once you put the image to sprite mode in the import setting, you can then drag the image/sprite to the sprite.
I have a large 3d model in .obj format with a large 20000*20000 texture. (it was generated by photogrammetry) I need to keep all the texture detail but want to use it with the Unity game engine. Unity only supports textures up to 8192*8192 so i think i need to break the model into smaller pieces and generate smaller textures(below 8192) from the original file.
How can i do this so i get separate textures for each piece? i.e. each model doesn't use the same large texture? I have access to 3DS Max
This is not the website to get those kind of answers. Autodesk has their own websites for asking these types of questions.
I am making a unity 2D RTS game and I thought of using a big texture for the tiled map (instead of a lot of textures - for the memory reasons...).
The tiled map is supposed to generate randomly at runtime so I don't want to save a texture and upload it. I want the map to be generated and then build it from a set of textures resources.
so, I have a little tiles textures of grass/forest/hills etc. and after I generate the map randomly, I need to draw those little textures on my big map texture so I will use it as my map.
How can I draw a texture from my resources on other texture? I saw there is only a Get/SetPixel functions... so I can use it to copy all the pixels one by one to the big texture, but there is something easier?
Is my solution for the map is OK? (is it better from just create a lot of texture tiles side by side? There is other better solution?)
The correct way to create a large tiled map would be to compose it from smaller, approximately-screen-sized chunks. Unity will correctly not draw the chunks that are off the screen.
As for your question about copying to a texture: I have not done this before in Unity, but this process is called Blitting, and there just happens to be a method in Unity called Graphics.Blit(). It takes a source texture and copies it into a destination texture, which sounds like exactly what you're looking for. However, it requires Unity Pro :(
There is also SetPixels(), but it sounds like this function does the processing on the CPU rather than the GPU, so it's going to be extremely slow/resource-intensive.
Well, after more searching I discovered the Get/SetPixel s
Texture2D sourceTex = //get it from somewere
var pix = sourceTex.GetPixels(x, y, width, height); // get the block of pixels
var destTex = new Texture2D(width, height); // create new texture to copy the pixels to it
destTex.SetPixels(pix);
destTex.Apply(); // important to save changes
Im new to OpenGL ES and wanted to create a bunch of triangles that would represent a grid of squares that i could map map tiles to. Is it possible to map separate textures on the same shape in OpenGL ES or would i have to make every square of the grid its own object? Thanks.
For efficiency (read: to minimize texture binds) you probably want a texture atlas.
Bind your atlas texture, pass in your grid geometry with the proper texture coordinates, and you're good to go.