SpiderPig Posted August 31, 2018 Share Posted August 31, 2018 I've started creating a large texture atlas for my terrain so that I can use more textures with less slots. The problem is the default mip-map generation creates bleeding on lower mip levels, and from what it says here, I need to create each mip-map separately and then combine them. Does anyone know of a way to manually set each mip-map level into a texture? Can I perhaps make a .dds texture with the mip-maps I want and will the editor then convert it to .tex format using those mip-maps? Quote Link to comment Share on other sites More sharing options...
Josh Posted August 31, 2018 Share Posted August 31, 2018 Yeah, it looks like you could make your own DDS file and the mipmaps would be retained when converted to TEX. 1 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted August 31, 2018 Author Share Posted August 31, 2018 Awsome thanks ? Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted September 1, 2018 Author Share Posted September 1, 2018 The .tex files doesn't seem to retain the mipmaps in the .dds file. I've attached the test files I used. Also I used this code to extract the mipmap level then later draw it to the screen; //On Load Texture* t = Texture::Load("Terrain/Textures/beach_dirt_b.tex"); char* buffer = new char[t->GetMipmapSize(1) * 4]; t->GetPixels(buffer, 1); Texture* tex = Texture::Create(t->GetWidth(1), t->GetHeight(1)); tex->SetPixels(buffer); //On Run context->DrawImage(tex, 100, 100); Here is what the second mipmap should like; Using gimp to load and edit the dds file, I can see that it is defiantly saving the second mipmap with the edit I did. It just not showing up in the conversion to tex. Is it possible to add a command to the texture class; SetMipMap(Texture* texture, int level)? Provided of course it has the right resolution for that level... beach_dirt_b.tex beach_dirt_b.tex.meta beach_dirt_b.dds Quote Link to comment Share on other sites More sharing options...
macklebee Posted September 1, 2018 Share Posted September 1, 2018 I wonder if its due to the default settings for the editor when converting an image to TEX that it automatically saves it as DXT1 and with the 'Generate Mipmaps' option selected? Is it overwriting your mipmaps because of this? These have always been settings i wish we had control over instead of them just being hard-written as the defaults. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
SpiderPig Posted September 1, 2018 Author Share Posted September 1, 2018 I think it might be. I just tested it again and this time exported the dds with only 5 mipmaps. After converting to TEX and loading in game the mipmap count was at 10. It would be nice to have more control over the import settings. Quote Link to comment Share on other sites More sharing options...
macklebee Posted September 1, 2018 Share Posted September 1, 2018 Just a quick and dirty script to view the mipmaps saved inside a TEX file: window = Window:Create("texture detail example",0,0,800,600,Window.Titlebar+Window.Center) context = Context:Create(window) world = World:Create() camera = Camera:Create() tex = Texture:Load("Materials/beach_dirt_b.tex") mips = tex:CountMipmaps() while window:KeyDown(Key.Escape)==false do if window:Closed() then break end Time:Update() world:Update() world:Render() context:SetBlendMode(Blend.Alpha) for i = 0, mips-1 do Texture:SetDetail(i+1) if i <= 4 then context:DrawImage(tex,155*i,150,150,150) else context:DrawImage(tex,155*(i-5),305,150,150) end end context:DrawText("Number of Mipmaps: "..mips,2,2) context:SetBlendMode(Blend.Solid) context:Sync(true) end 1 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Josh Posted September 1, 2018 Share Posted September 1, 2018 Okay, so the way Leadwerks supports DDS is it just loads it with FreeImage and regenerates mipmaps. Here is a little program you can use to convert a DDS into a TEX file and save the same mipmap data. dds2tex.zip Just drag the DDS file onto the EXE and it will convert it. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
macklebee Posted September 1, 2018 Share Posted September 1, 2018 hmmm. This still seems to be saving the same way as the Editor does where it overwrites the existing mipmaps. I am not seeing a difference when viewing with the above program. The second mipmap should look like this: 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Josh Posted September 1, 2018 Share Posted September 1, 2018 I will check this out. I looked at the source code and it does read the DDS mipmaps and write them out, I thought. 1 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted September 1, 2018 Author Share Posted September 1, 2018 I tried the converter on my DDS that has only 5 mipmaps and got this when loading into the editor. So I guess it's trying to calculate them still...? Error: Texture mipmap count (5) does not match calculated mipmap count (10). Error: Failed to load texture "G:/Leadwerks/Projects/TestingGrounds/Materials/beach_dirt_b.tex" As a general rule are all mipmaps supposed to present? Right down to the lowest size? (2x2 or 1x1)? 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted September 1, 2018 Share Posted September 1, 2018 Should be mipmap-complete, down to 1x1. 1 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted September 27, 2018 Author Share Posted September 27, 2018 Any idea when this could be fixed? Quote Link to comment Share on other sites More sharing options...
Josh Posted September 27, 2018 Share Posted September 27, 2018 If the DDS only contains five mipmaps it will not work. Textures must be mipmap-complete. The way you calculate this is to keep dividing the width and the height until they both equal 1. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted September 27, 2018 Author Share Posted September 27, 2018 Okay, I got it working with the tool you posted thanks. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.