A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate
in the Unity community.
Discussion in 'External Tools' started by ivanmoen, Jun 28, 2009.
Is there any way to edit the mipmaps generated by Unity, or create them manually?
Unfortunately there is no way to edit the mipmaps, or import pre-authored mipmaps.
Sounds like a request for the Wish List.
Support for importing DDS files would handle the ability to import mips, support for exporting images as DDS files from unity. including the generated mips, would handle the ability to edit the mips.
Full I/O support for DDS files would suffice nicely.
Unity is no DX engine, its a crossplatform engine, making DDS a little bit troublesome.
Oh, but Unity already supports that! (since Unity 2.1)
So DDS files are one way to get in custom mipmaps. Another way would be to manually editing them in a texture import post-process script. This can be quite cumbersome though.
DDS is just a file format that is documented and very simple. It originated from DirectX, but there's nothing in the file format that makes it unusable elsewhere.
I was under the impression (don't ask me why), that not the full set of capabilities it offers are usable outside of DX (where at least from what I've experience so far, especially the NVIDIA provided loader is beeing used)
But thats potentially related to the fact that I've so far not seen any OGL engine that supports all those things in textures that DDS would have to offer.
thank you for the clarification
I don't know anything about Unity...
But if Unity eat the DDS, the mimapping subject is a Graphical-Card's work, isn't it?
Basicaly I edit my mimap level with this Nvidia pulgins :
Does unity have to access to the DDS information for getting mipmap level or the graphical card do all the work?
I know some rumor saying, if the graphical card get a Jpg, png, etc file, it will uncompress the picture like a BMP file...
... but if the graphical card get a DDS file, the graphical card doesn't need to uncompress the picture data and will take the mimap level on the same way in the dds...
Does I have wrong? ? Does Unity have to do all this work?
(I'm not a programmer but this is an interesting subject to me ^_^ )
Unity will read the mip levels from the DDS file. So yes, if you want to use NVIDIA's plugin to do custom mipmaps levels, just save the DDS with mip levels and it will work.
Thank you, you exactly answer to the question as well! ^_^
... at least for you.
Mac users still don't get the NVidia tools for Photoshop. And I also still don't know of any (free) comparable Plugin toolset or standalone.
Good to know that about Unity and DDS files, though
Oh S***... I just remember an important thing... Game will be on iPhone -_____-......
Then what about the iphone's graphical card? haha...
Seriously, does it works on iPhone?
I recently heard some rumor saying the dds was working on PSP for 2 years... the iPhone plateform seems to be similar on the spec...
Does someone know more about it?
"Does the DDS file working correctly on iPhone with the mipmapping level?"
Thank you by advance!
Alright I just got my answer..
Modifying the mipmap level on Photoshop, Unity is more intelligent than Maya and will use it...
But once the iPhone will only accept this kind of texture file :
Then I can't modify the mimpmap level...
Or maybe... Does someone else know a good tips of that?
Just a note that Gimp 2.6.8p now includes the DDS plugin, even on Mac OSX. However, I so far have not found a way to actually save my own custom mipmap levels into a single DDS file. It can generate levels for you which is not what I want, and it can do some kind of `volume texture` but I don't think that's the same thing. It seems pretty comprehensive otherwise. It can load mipmap levels into layers but maybe not the other way around? If anyone knows otherwise please let me know.
Dunno on mac...
But in Photoshop with Nvida plugin on PC, I can modify mipmap level manually and it will keep it.
Problem is about Unity.
And if you work with iphone it will erase your mipmap and create his own.
I am not sure about it... but maybe Unity generate new mipmap level too from the beginning... We spoke about it last July then...
But on Unity-iPhone we didn't find any issue to resolve this problem yet.
the iphone does not support DXT at all so having DDS is of the least use of all actually. The iphone native format would be pvr, for which imagination technologies offers a tool for at least windows to do such stuff (on osx you have apples command line converter) but I doubt Unity loads these pvrs actually
I think what I'm going to do is make a dummy texture and let Unity mipmap it, then get the mipmaps and write out my own pixels with SetPixels. Hopefully that should work.
Ok. So now what I want to do is basically generate my own mipmaps within Unity using scripting and drawing operations. I'll be using Texture2D.ReadPixels to grab the initial full-size texture. Then I will render the texture at a scaled down size (using bilinear interpolation or whatever) and grabbing those as mipmap levels. I could grab each of these into individual textures. However, I want to be able to grab directly into the actual mipmaps of a texture, OR be able to very quickly assign a texture to be used as a mipmap at a given level. I do NOT want to use SetPixels() as that involves copying pixels which is not what I want.
Is there any way to do this or does Unity not have this functionality?
An additional question.. if I let Unity recalculate the mipmap levels after the initial grab, does it generate those levels using the GPU to scale down and grab, or does it do it all with the CPU/re-uploading of textures like you would do with SetPixels (ie the slow way)?
Sorry to bring up an old thread. I tried doing this, but it didn't work. I could write the mip map levels if "Generate mip maps" was enabled, but nothing happened. But when I wrote the mipmap level 0, the write went through, but it seems that the mipmaps are generated (again?) after that - so all the mipmap levels got the same modification as the mip map level 0.
Is there truly a way to have custom mipmap generation or is this feature broken/unavailable?
I would like to add, since this topic is brought back, that I'm also looking for a way to cap the mip map level to 5 max (another voxel engine guy here). I've looked into DDS files, but apparently they aren't going to work for iOS and I'm also using a Mac. And I'm not sure how to handle this via shader. Any help would be appreciated.
I just run into this problem too. I had to combine some textures to atlases to reduce draw calls, and that of course creates the mipmap problems...also working on mac and targeting iOS? Wanted to cap the mip map levels at first...any clever solutions around?
I've been attempting to do this, and I do not think it to be possible in a broad approach.
I set it up so that theres a seperate folder next to assets, where the directory names match the file path of the texture, then you would place in 1,2,3,4 ect .png in a folder named after the original file.
The problem is that theres no way to supply the custom mip levels in OnPreprocessTexture, before conversion to the format (which may not always be modifiable) or the texture being marked as non readable.
As far as the dds approach, it works but its painful. DDS textures do not have a TextureImporter applied to them, so you have to rely on the format they were saved as, plus no sprite generation and everything is marked as readable which in my case is pointless memory usage. Basically, unity does some magic with DDS textures and you're unable to actually configure them because the .meta has no import settings to modify any modifications to the texture which unity imports are not saved.
So I deeply hope that one day unity will properly support custom mip maps that work in any format and support marking as non readable/sprite generation.
The only way to do it right now would be making editor scripts which involve AssetDatabase.Create("Assets/bla.asset", blaTex); after configuring a texture. Again, I do not think it to be possible to set up a asset post processor to do this without limiting the formats used.
For anyone else that ends up here, here's a link to a github repo that can manage custom mip map creation, via filenaming. Just add in filenames like this and it'll handle the rest, I can confirm it working with standard shader
texture.png (the base mip0)