Texture Cooker (in-game PNG to DDS converter)

Discussion in 'Content Creation' started by Nadeox1, Apr 17, 2021.

  1. Nadeox1

    Nadeox1
    Expand Collapse
    Spinning Cube
    BeamNG Team

    Joined:
    Aug 5, 2012
    Messages:
    14,681
    Hello,

    Sometime around 0.20 we added a extra-useful feature into the game called Texture Cooker, which is nowadays a fundamental tool we use in our assets creation workflow.

    What?

    This tool lets the game automatically convert PNG textures files into the most appropriate DDS format.

    Why?
    DDS is a texture format optimized for 3D applications, and is optimized for GPUs allowing them to use less memory.
    Not many image editing software support these format natively, and some require plugins/addons that are often not up to date.
    The texture cooker removes this issue by allowing you to keep working with PNG and leaving to the game the conversion.


    More?
    You can find this feature fully documented here:
    https://documentation.beamng.com/modding/materials/texture_cooker/


    Feel free to ask for any questions, doubts or etc. in regards :)
     
    • Like Like x 17
  2. Sithhy™

    Sithhy™
    Expand Collapse

    Joined:
    Apr 5, 2017
    Messages:
    3,341
    Is that the reason why there are textures in .png format in the official game vehicles? Pretty cool if I don't have to fiddle around with exporting them the correct way in .dds
     
  3. Nadeox1

    Nadeox1
    Expand Collapse
    Spinning Cube
    BeamNG Team

    Joined:
    Aug 5, 2012
    Messages:
    14,681
    If you mean why, in some of our materials files, we point to .png textures, yes! We have used the texture cooker in those cases, working with .png files on our end, but releasing the converted .dds files when done.

    Even though the texture paths are pointing to .png file, the game automatically uses the converted .dds files if they are detected.

    In general with this you can export textures as .png while we are working on content and let the game care about the .dds conversion.
     
    • Like Like x 4
  4. Artistterrymartin

    Artistterrymartin
    Expand Collapse

    Joined:
    May 5, 2019
    Messages:
    710
    After the last update the console shows more in detail what I did that did not jive with the texture cooker. Apparently all textures need to be to the power of 2. Assuming that is 1024x1024 or 4096x4096 for example and not some odd ball 1937x846. I made a new object with the correct dimensions and it worked as it should. Worked great ! upload_2021-4-29_13-8-10.png
     
    #4 Artistterrymartin, Apr 27, 2021
    Last edited: Apr 29, 2021
  5. Artistterrymartin

    Artistterrymartin
    Expand Collapse

    Joined:
    May 5, 2019
    Messages:
    710
    I read the documentation and I can find the DDS in the temp folder that are converted, however I can not select the static mesh and be allowed to modify the material any further on imported DAE's from Blender. Things like alpha blend, animation, lighting or adding other textures to the other locations like normal reflection, cutout ect. This only is for materials the Texture Cooker has converted PNGS for. I export from Blender with only a color map being I read T3d handles all other types of textures in engine.
    If I make new material it says one is already created in the console for material converted which is obvious but If I type the texture in the search box it does not yield a result. This is where I have all my models and pngs stored. C:\Users\Terry\Desktop\TM\0.22\levels\Crater
    Should they be in a subfolder to "Crater" in say the art folder or other ?
    Thanks.
    I am thinking I can delete that temp folder and clear up some issues. Will back my level folder up first.
    I am going to make a new test level to get a fresh take thinking I may have done something wrong to an item or material JSON file somewhere along the way editing them.
    Hate to be a pain in the end side but appreciate the time to read this or respond.
     
  6. ltntai

    ltntai
    Expand Collapse

    Joined:
    Mar 18, 2017
    Messages:
    656
    Sometimes the cooker does a lousy job compared to manual conversion. Transparency issue, perhaps?

    png_49_8KB_no_xcf.jpg cooked_dds_341KB.jpg manual_BC7_sRGB_256KB.jpg Terrys_enhanced_4k_21MB.jpg cooked_1024_133.jpg
    1. Original decal png 512x512, 49.8 KB, xcf file removed from folder
    2. Cooked, 341 KB
    3. Paint.net conversion to BC7 sRGB default, no mipmaps, 256 KB
    4. Terry's enhanced no4, 4k, 21.3 MB
    5. Terry's 1024x1024 cooked, 1.33 MB
     

    Attached Files:

    #6 ltntai, May 10, 2021
    Last edited: May 11, 2021
    • Like Like x 1
  7. Agent_Y

    Agent_Y
    Expand Collapse
    Jbeam/QA support
    BeamNG Team

    Joined:
    Jul 10, 2020
    Messages:
    10,053
    For me it honestly always works a lot better than manual conversion and it solves the transparency issues that can happen normally. The only weird thing I found out that it's very slow at cooking skins for the H-Series, it might just be me, but it takes like half a minute when it's supposed to be instant and works almost instantly for other vehicles.
     
    • Like Like x 1
  8. Artistterrymartin

    Artistterrymartin
    Expand Collapse

    Joined:
    May 5, 2019
    Messages:
    710
    That looks like compression artifacts, frustrating. Can you scale the image using bicubic smoother (best for enlargements) then let the texture cooker convert it. I am thinking the more pixels you are converting, the better the compression artifact will be. This is just the photoshop image scale, but any should work. Then resize to 512 x 512 if you have using Bicubic Sharper for the reduction. image sizes here do not reflect power of 2, its just the enlarge and reduction I mean to point out.
     

    Attached Files:

    • Untitled-1.jpg
    • Untitled-2.jpg
  9. Artistterrymartin

    Artistterrymartin
    Expand Collapse

    Joined:
    May 5, 2019
    Messages:
    710
    I made a few variations, from simply only scaled to 4k, to several other variations you might like to try. also converted one of them to a Normal map if you are familiar with what they do. Drop in the texture slot under the color map where it says normal map. Just rename the one that works for you to your file name.color. some are 1_ 2_ 3_ 4_ to let you know they are variations of the map. Just easier to say, whatever one you try, just rename to your file :) And leave the .normal on the normal map. Did some painting on those letters to try to clean them up some in a couple of them. One is an 8k, 8192x8192, but doubt it will make much more difference than the 4k ones.
    Hope it helps !
    -Terry

    Added the Photoshop format file if you get Photoshop Elements or Photoshop Regular. Elements is a cheaper version that usually ships as free included with cameras, or laptops. Not very much to buy it either.
    I use Gimp alot. Gimp does seamless tile maps and normal maps in the main filters. Gimp is Free.
    Remember to export to save as in gimp. Just saving saves as a gimp file. Exports DDS, but think its a different version or compression. upload_2021-5-11_12-43-12.png upload_2021-5-11_12-43-35.png
    --- Post updated ---
    Dam, hehe... It looks exactly the same before enlarging then shrinking. 512x512 would work if the font was larger for the bottom letters. They are so small that it is giving the artifacts. If you make any more signs or want to modify this one here is a link to a site with free Fonts. In photoshop or any editor you can type the font out as a vector instead of a rasterized. Think of a vector as meta data that no matter what size the font is, the raster will mathematically display it correctly. Only thing is it has to be rasterized to be flattened but I think it would give a better place to start from when shrinking. Sorry it took so long to get back. Also sent a 1024x1024 and a normal.png of the 512 x 512. Using a normal could give it a little more detail. You can make a normal for the side view of the hanger, and those 3d bars will apply to the sign too. You can have your metal hanger thing do same thing as the wood on the paint.
    upload_2021-5-11_16-22-57.png upload_2021-5-11_15-26-29.png Beer Fonts | FontSpace
     

    Attached Files:

    #9 Artistterrymartin, May 11, 2021
    Last edited: May 11, 2021
    • Like Like x 2
  10. ltntai

    ltntai
    Expand Collapse

    Joined:
    Mar 18, 2017
    Messages:
    656
    Thank you Artistterrymartin for your time and expertise. 1024 converted nicely. And just to make clear, that's not my map or textures. It's Ouerbacker's Las Colinilas de Vapor, which I thought was worth to future proof with new files.
     
  11. Artistterrymartin

    Artistterrymartin
    Expand Collapse

    Joined:
    May 5, 2019
    Messages:
    710
    Thanks, not an expert but learning as I go. Glad I could help... The more people share knowledge the more the community can benefit. I will keep eye out for any maps or mods you make. My next project will be next month, want to learn the Jbeams and Nodes. I want to make mods after my map is done. More destructible objects is where my interest is focused.
     
    • Like Like x 2
  12. thomatoes50

    thomatoes50
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 31, 2013
    Messages:
    722
    for .color texture we always use BC7. it take a bit more time to convert to it as it tries multiple schema for all the compression blocks.
    when you use the in-game texture cooker we use the fast preset so it tries a lot less schema (speed up compression).
    if there is too many compression artifact you can try to overwrite the dds with an external tool that will try to get better results.
    @ltntai try to use mipmaps all the time. else you will have the granny effect when the texture is far away
     
    • Like Like x 2
  13. ltntai

    ltntai
    Expand Collapse

    Joined:
    Mar 18, 2017
    Messages:
    656
    I promise.
    Could the cooker also convert dds files that give "unsupported non-RGB format" console errors to its preferred form? Is there quality loss if I turn those to pngs and then cook them? Feels safer than raffling my own dds settings.
     
    • Like Like x 1
  14. thomatoes50

    thomatoes50
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 31, 2013
    Messages:
    722
    for now the texture cooker expect all source to be 8bit.
    .color need to have 3 or 4 channel.
    .data can have 1, 3, 4 channels but should not be used for diffuse as it's not using the same color space.
    for now the engine doesn't convert anything if the channel are missing.
    that means you need to export the png in the right format

    there is a bit of quality loss because of the dds compression, especially when using the game because it use the fast preset.
    during testing it was not noticeable.
     
  15. Artistterrymartin

    Artistterrymartin
    Expand Collapse

    Joined:
    May 5, 2019
    Messages:
    710
    Why when the game does convert to DDS, I am unable to go back to the material editor and make any more changes ? It is as the material does not exist.
    Thanks
     
  16. thomatoes50

    thomatoes50
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 31, 2013
    Messages:
    722
    while converting texture you may experience lag.
    it should happen when you load the mesh that uses it.
    if you can reproduce the issue can you please provide steps or video recording
     
  17. Artistterrymartin

    Artistterrymartin
    Expand Collapse

    Joined:
    May 5, 2019
    Messages:
    710
    Thanks yeah, I am aware of the lag, and I will make a short video. Thank You.
    --- Post updated ---
    Here is my video of the typical problem I encounter. I made the test image a 1024x1024 png saved from photoshop. SAved as test.color.png. Had to change the texture in Blender to be also called test.color . Earlier test block was red when Blender object was only called test in the texture name.
    Even when the game does not crash and I just browse for the texture it is not listed, but the DDS is in the temp folder.
    Thanks for any time analyzing this I know everyone is likely busy !
    I am reinstalling game, going to make new location for the user folder than where it was. And see without doing anything else if the problem still happens. I am also getting the user interface vanishing when using the forest tools in the editor.
    (1) Texture Cooker Problem for Me Test - YouTube
     
    #17 Artistterrymartin, May 27, 2021
    Last edited: May 28, 2021
  18. Artistterrymartin

    Artistterrymartin
    Expand Collapse

    Joined:
    May 5, 2019
    Messages:
    710
    Maybe this explains your logo, upload_2021-6-3_20-1-53.png
     
  19. ltntai

    ltntai
    Expand Collapse

    Joined:
    Mar 18, 2017
    Messages:
    656
    • Like Like x 1
  20. Artistterrymartin

    Artistterrymartin
    Expand Collapse

    Joined:
    May 5, 2019
    Messages:
    710
    I have not tried these two tools, but will later, google Nvidia Texture Tools. I remember you did not have photoshop, but ones a plug in for it, and the other
    I installed Nvidia texture tools for my very old photoshop elements, and could not figure out how to use them or where they where. NVidia also has a stand along Texture Tools and maybe I am to dumb to use them, could not figure them out. Glad the 1024 helped.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice