GIMP Plugins for dds conversion, BMP + Alpha to DDS merging, forest map editing

Moderators: Uros, OXO, JBr

Post Reply
solidxsnake
Posts: 12
Joined: Sat Apr 18, 2020 10:38 pm

GIMP Plugins for dds conversion, BMP + Alpha to DDS merging, forest map editing

Post by solidxsnake » Tue May 26, 2020 5:07 am

https://github.com/solidxsnake/condorv2 ... r_utils.py

I wrote a couple GIMP plugins that I've used during v2 scenery development, and have put them up in case others want to try and make use of them. The Python file in the above link has a couple plug-ins.

The first two are batch-mode only (command-line invoked using gimp's script-fu interface). They are easy ways to batch-convert folders full of image files directly to DDS, or to combine two sets of BMPs (RGB and alpha) into a single DDS file. I wrote these because the wateralpha tool didn't work the way I wanted, and using the NVIDIA Texture Tools was stripping the RGB information anywhere I had an alpha defined.

The other plug-ins are load/save plugins for a Condor .for and .tdm files.

The forest plug-in allows loading of the .for file from the installed scenery (i.e. in Program Files/Condor2/Landscapes....). It will load the base .dds texture corresponding to the forest tile and resize it to 512x512, then it will load the forest map into a second layer and map the bits into black (no trees), red (coniferous trees), and blue (deciduous trees) pixels. The second layer is set to a lower opacity to make for easy editing of the forest map while referring to the corresponding texture. The final plug-in is the opposite that will save the forest file after loading in and editing using the load plug-in.

The thermal plug-in simply loads the input .tdm map file as a grayscale image for easy editing, and exports it back out in the correct format. Much faster than making a bmp and using the Landscape Editor to convert it into the .tdm file.

Install the plugin by placing into your %APPDATA%/GIMP/2.10/plug-ins folder (%APPDATA% can be typed directly into a Windows explorer window, but otherwise it is located in C:\Users\<your username>\AppData\Roaming).

If I make any more scripts/plugins, they'll appear in the github repository linked above. Hope people may find this useful.

Edit: Looks like something in the newer versions of GIMP breaks compatibility with the forest map editing plug-in. For that to work, stick with GIMP 2.10.14.
Last edited by solidxsnake on Sat Jul 11, 2020 7:11 pm, edited 2 times in total.

bluefang
Posts: 53
Joined: Thu Jun 11, 2015 2:55 am
Location: South East, USA

Re: GIMP Plugins for dds conversion, BMP + Alpha to DDS merging, forest map editing

Post by bluefang » Mon Jun 15, 2020 7:30 am

solidxsnake wrote:
Tue May 26, 2020 5:07 am

I wrote a couple GIMP plugins that I've used during v2 scenery development, and have put them up in case others want to try and make use of them. The Python file in the above link has a couple plug-ins.


Hey solidxsnake... thanks for publishing this gimp plugin. I wanted to do something similar, and initially tried with Photoshop plugins, but I couldn't find any documentation on scripting the NVIDIA Texture Tools plugin - so I took your idea of using GIMP's built-in .dds feature and making a plugin which does some extra steps.

My plugin will take a 32-bit .png file named in Condor Terragen format (CCRR.png) and will split the Terragen sized tile into the 4x4 grid of tCCRR.dds texture patch files required by Condor - and automatically name the files based on the input Terragen file name. Similar to how WaterAlpha works, except this has some advantages over WaterAlpha:
  • This doesn't require separate images for texture and water. The water is the alpha layer of input Terragen tile. This saves one step when masking the water in Photoshop or GIMP or any app that natively supports alpha layers. You can simply save the image with alpha layer built in - as a .png for direct use by the plugin.
  • This seems much faster than WaterAlpha. I am not sure why WaterAlpha is so slow - it might be because it splits the texture and water tiles up first before doing the merge - not sure. But surprising this plugin is a lot faster than WaterAlpha.
  • There is no size limit to the input Terragen tile. I have used this with 16384 x 16384 Terragen tiles with no problem. WaterAlpha is limited to 8192 Terragen tiles.
It borrows quite a bit from the ofn-tiles plugin, but has some extra steps that are specific to making Condor texture patches. Here is a link to the plugin source:

https://github.com/johnny-fantastic/con ... r_tiles.py
Image

User avatar
dingetje
Posts: 5
Joined: Sun Dec 21, 2008 4:00 pm

Re: GIMP Plugins for dds conversion, BMP + Alpha to DDS merging, forest map editing

Post by dingetje » Tue Jun 30, 2020 11:29 pm

Excuse me, GIMP newbie here, I've downloaded and installed your forest script. But how to use it? :?:

User avatar
dingetje
Posts: 5
Joined: Sun Dec 21, 2008 4:00 pm

Re: GIMP Plugins for dds conversion, BMP + Alpha to DDS merging, forest map editing

Post by dingetje » Tue Jun 30, 2020 11:39 pm

Got it, the python script was saved with the wrong extension.

User avatar
dingetje
Posts: 5
Joined: Sun Dec 21, 2008 4:00 pm

Re: GIMP Plugins for dds conversion, BMP + Alpha to DDS merging, forest map editing

Post by dingetje » Wed Jul 01, 2020 7:04 pm

@solidxsnake

While I can open and edit .for files with the plugin, how do I save my results? GIMP complains about an unknown file format?

User avatar
dingetje
Posts: 5
Joined: Sun Dec 21, 2008 4:00 pm

Re: GIMP Plugins for dds conversion, BMP + Alpha to DDS merging, forest map editing

Post by dingetje » Wed Jul 01, 2020 10:06 pm

Found the root cause, your script doesn't work with the latest version of GIMP (2.10.20-1), I have downgraded to 2.10.14-3 and it worked!

mebarg
Posts: 15
Joined: Sat Jun 15, 2019 9:20 pm

Re: GIMP Plugins for dds conversion, BMP + Alpha to DDS merging, forest map editing

Post by mebarg » Wed Jul 01, 2020 11:00 pm

hi can you share the correct way of ussing the script i never used scripts for gimp and it works under windows?

the files are the same as for wateralpha? water in black and terrain in white? it split the final dds and names it?

solidxsnake
Posts: 12
Joined: Sat Apr 18, 2020 10:38 pm

Re: GIMP Plugins for dds conversion, BMP + Alpha to DDS merging, forest map editing

Post by solidxsnake » Sun Jul 05, 2020 4:33 pm

dingetje wrote:
Wed Jul 01, 2020 10:06 pm
Found the root cause, your script doesn't work with the latest version of GIMP (2.10.20-1), I have downgraded to 2.10.14-3 and it worked!
Huh, you're right. What a shame. I couldn't find anything in the changelogs that would indicate why the newer versions of GIMP don't work. It loads fine, but the save plugin doesn't appear to correctly appear (even though it is indeed loaded and registered with the GIMP Procedure Browser).

Thanks for the heads up. I'll make a note of it in my original post.

solidxsnake
Posts: 12
Joined: Sat Apr 18, 2020 10:38 pm

Re: GIMP Plugins for dds conversion, BMP + Alpha to DDS merging, forest map editing

Post by solidxsnake » Sat Jul 11, 2020 7:09 pm

Added an update to my original plugin file. I've added another command-line function to downsize a .dds file with cubic interpolation (useful to downsize large texture files to a smaller size), as well as load/save handlers for the Thermal map .tdm files.

bluefang
Posts: 53
Joined: Thu Jun 11, 2015 2:55 am
Location: South East, USA

Re: GIMP Plugins for dds conversion, BMP + Alpha to DDS merging, forest map editing

Post by bluefang » Sun Jul 12, 2020 12:59 am

I have also updated my plugin with a new feature - there is now an option to save the input .png file as a .bmp file - it deletes the alpha layer without applying it to the RGB channels and saves it as a 24bpp BMP file - this is usefully if you want to import the condor sized tile into Landscape Editor. Warning - as with WaterAlpha - do not then re-export the scenery tiles using Landscape Editor - as you will lose your water layer. Use the .dds files created by the plugin directly in your Textures folder. Importing into LE is only usefully to update the Landscape Editor with textures.
Image

bluefang
Posts: 53
Joined: Thu Jun 11, 2015 2:55 am
Location: South East, USA

Re: GIMP Plugins for dds conversion, BMP + Alpha to DDS merging, forest map editing

Post by bluefang » Mon Jul 13, 2020 6:29 am

Weekend update...

I have added a new menu item to my plugin. It basically takes a forest tile .png file as input - and based on values you give in the dialog for forest density, deciduous density, deciduous color, coniferous color - will automatically generate bXXXX.bmp and sXXXX.bmp terragen tiles for import into Landscape Editor.

This is what the dialog looks like:
plugin-dialog.jpg

The way it works is it takes a 2048x2048 ".png" file as input - where any non transparent pixel is treated as a possible forest pixel. The Tree Density value determines the "chance" that that any non transparent pixel will have a tree there. Most of the time, you will keep this at 100%. Secondly, you can choose the ratio of Deciduous vs Coniferous density of this pixel, i.e., what is the chance this tree is a Deciduous tree vs a Coniferous tree. In Condor, tree types can not overlap, so the Coniferous density is always the inverse of Deciduous density. Lastly, you can assign color values to use for each tree type - but I don't think these matter - they just can't be the same color.

It will then iterate through all CCRR.png files in the source folder and create the appropriate bXXXX.bmp and sXXXX.bmp files in the /forest directory.

Here is an example of a forest tile input - where non transparent pixels are trees and transparent pixels are not trees.
tree-input-file.jpg


And here is what the resulting output would look like:
results.jpg

If you want only Deciduous trees, then use 100 for the Deciduous density - if you want only Coniferous trees then use 0 do the Deciduous density. It is that easy!

This is included in the same plugin file as the water alpha - texture splitter plugin mentioned previously, and can be found here:

https://github.com/johnny-fantastic/condorv2-tile
You do not have the required permissions to view the files attached to this post.
Image

Post Reply