satguru Posted December 30, 2016 Share Posted December 30, 2016 I am trying to use a dds file as diffuse texture for a mesh. Does not work. Texture is not applied properly. Comes up all garbled. If I convert the dds file to png it works perfectly Are there any restrictions on dds texture ? Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted December 30, 2016 Share Posted December 30, 2016 Probably power of 2, and possibly being square. Am in the process of re-designing compressed textures to also add the other types. Did some work on 2.5, but did not actually change babylon.tools.dds.ts. You might switch to 2.4, just to see if your DXT texture loads there, thus confirming my 2.5 engine changes or not. Quote Link to comment Share on other sites More sharing options...
satguru Posted December 30, 2016 Author Share Posted December 30, 2016 size is 256 * 256 have attached file does not work in 2.4 too hele_fishing_boat.dds Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted December 30, 2016 Share Posted December 30, 2016 Try replacing with each of these one at a time from https://github.com/toji/texture-tester/tree/master/textures shannon-dxt1.dds shannon-dxt3.dds shannon-dxt5.dds when I downloaded your file, file explorer did not show a thumbnail. I am getting thumbnails for these. Also double check your rig is set to go by running : Quote Link to comment Share on other sites More sharing options...
satguru Posted December 31, 2016 Author Share Posted December 31, 2016 file explorer shows thumbnail in my PC (windows 10) attached are two babylon files - "cube.babylon" and "boats.babylon" and two textures - .dds and .png "cube.babylon" works, "boats.babylon" does not work drag the file and texture into babylonjs sandox to see if I edit the boats.babylon and change the texture to .png it works boats.babylon cube.babylon hele_fishing_boat.dds Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted December 31, 2016 Share Posted December 31, 2016 I am noticing that the existing implementation of the s3tc / dds texture container is missing a number of compressed formats: DXT1 format with alpha ATC format ATC format with explicit alpha (ATCA) ATC format with interpolated alpha (ATCI) I have not figured out how to distinguish DXT1 from DXT1 with alpha in the dds container yet. My changes expand the number of compressed formats from 3 to 50. Also from a dds container, to dds, pvr, & ktx containers. If you can get properties for your file from the program you used to convert to PNG, see if the format is one of the missing ones. Will not be patching the existing code base. Making all new classes. Will see if your scene runs as getting closer to operational. Quote Link to comment Share on other sites More sharing options...
satguru Posted January 1, 2017 Author Share Posted January 1, 2017 I used one of the free online programs to convert DDS to png. But let me see if I can find some more info about it. "3 to 50" - impressive Do not know much about DDS myself. I was trying to use some assets from the 0AD RTS game. Its an impressive open source game with lots of free nice low poly assets.Many of them use DDS. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 1, 2017 Share Posted January 1, 2017 I have found a tool that will generate a wide variety of compressed textures in all 3 container formats, PVTTextTool. When I open your file from this tool it identifies the format as BC2. Here is where it gets confusing. There are multiple names for the same thing that overlap. In Wikipedia, s3tc / dds formats have FOURCC & DX 10 names. BC2 corresponds to: DXT2 & DXT3. WebGL only supports DXT1 (2 variations), DXT3, & DXT5. Since you say it worked, but was garbled, I think it was DXT3. DXT2 should generate an error in the console. Looks like existing code does not work. I am not surprised. The code looks very old, pre-typescript conversion. Quote Link to comment Share on other sites More sharing options...
satguru Posted January 1, 2017 Author Share Posted January 1, 2017 You are right. It is DXT3 format. If I open the file as a binary file I see dwFourCC set to DXT3 (see attached screenshot) I picked the structure info from https://msdn.microsoft.com/en-us/library/windows/desktop/bb943991(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/bb943982(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/bb943984(v=vs.85).aspx Quote Link to comment Share on other sites More sharing options...
satguru Posted January 10, 2017 Author Share Posted January 10, 2017 @JCPalmer Did some more testing. Looks like the DDS texture is being flipped along Y axis. Tested on a simple cube. Texture ended up being upside down on the cube face. If I replace the texture co-ordinates U,V with U,1-V the mapping works perfectly issue seems similar to this https://github.com/mrdoob/three.js/issues/4316 JCPalmer 1 Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 10, 2017 Share Posted January 10, 2017 Thanks, I have done the first implementation of the Multi-Platform Compressed Texture feature. Ended up only supporting Khronos Texture Containers (.ktx files). .ktx worked so well, seems no reason to dink with DDS or PVR containers. DDS is still there, but I did not touch it. Am working on automated batch scripts to create all the formats of .jpg & .png files in a directory. I converted the 100 images in the mansion demo, but when I ran the scene things looked out of place. Think this is the same problem as you. In Engine.createTexture(), there is an invertY arg. It value is set to true in the Texture constructor. Looking down this function, we could easily disregard this for DDS & KTX and hard code where it gets passed to false. It clearly needs to be true for image based textures. @Deltakosh, does this make sense? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 10, 2017 Share Posted January 10, 2017 Makes sense! But we could face backward compat issue so we have to be cautious JCPalmer 1 Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 10, 2017 Share Posted January 10, 2017 Thanks. We at least only need to be careful with .DDS, not .KTX Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 10, 2017 Share Posted January 10, 2017 Correct! Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 10, 2017 Share Posted January 10, 2017 Well, I hardcoded .ktx to be false, yet Clippy's grave is clearly upside down. Tomorrow I am going to have to double check, it is really running my changed code. I am sure I am using the DXT variant. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 10, 2017 Share Posted January 10, 2017 ok thanks! Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 11, 2017 Share Posted January 11, 2017 Upside, I can generate the .ktx files pre-inverted. Looks like no matter the value for gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, ...) it is effectively ignored. I see others have reported the same thing. I re-generated the dxt mansion textures Y flipped, and they now work as expected. The gl call is still ignored. On to the next problem, on iOS what happens when pvrtc textures are not square. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
satguru Posted January 11, 2017 Author Share Posted January 11, 2017 in my case, as i have no control on the dds file, I am flipping the UV map - replacing V with 1-V Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 11, 2017 Share Posted January 11, 2017 You do as you wish. Should point out for historical purposes, that PVRTextTool also reads / writes .dds files. Link above. Once file opened, you can goto Edit->Encode. Pick bc2 & linear RGB after filtering for DirectX. Check generate Mipmaps & Vertical Flip down at the bottom. Click Encode button. You will get 2nd picture, save that one with a .dds extension. FYI, you should also include the .png when you publish. If scene is loaded from Android, OSX, or iOS, it should fall back to the .png. This was incorrectly changed in 2.6-alpha. Fix will be part of my cleanup PR. satguru and GameMonetize 2 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.