Code for texconv

Programming related discussions related to game research
noire90
Posts: 4
Joined: Sun Feb 14, 2021 1:01 pm

Code for texconv

Post by noire90 »

A batch code line for texconv to remove the alpha channel inside my .dds files, Luigi please. I need to remove the transparency from them. A code line that remove the transparency please, for texconv or for another... you have the skills to help me... I have spend days to read on line and try to find the solution but I failed.
Last edited by noire90 on Mon Feb 15, 2021 7:32 pm, edited 1 time in total.
Shokoniraya
Posts: 416
Joined: Sat Sep 15, 2018 5:22 am

Re: Code for texconv

Post by Shokoniraya »

if you want to do some changes in a image channel, you should convert it to a raw-32bit and then start to messing with RGBA blocks (or 64bit, 16-bit? 8-bit? i hope 64-bit color dream never came true for black future!)

if you want to deal with a picture, you have to use a photo editor, paint.NET is a free one

you can convert your image with texconv.exe

Code: Select all

"texconv.qgp" -y -ft TGA -m 1 "my_image.png" -o "output_folder"


normal transparency (full, i mean no alpha) is 0xFF (255)
and alpha colors are between 00 (full alpha) and 0xFF (full color)

use below script on 32-bit tga files to make transparency colors to full colors

Code: Select all

get FILE_NAMER filename
string FILE_NAME = ""
string FILE_NAME + "transparency_fixer"
string FILE_NAME + \
string FILE_NAME + FILE_NAMER
get SIZER asize
xmath PIXEL_COUNT "(SIZER - 18) / 4"
log MEMORY_FILE1 0 SIZER
goto 18 MEMORY_FILE1
for i = 0 < PIXEL_COUNT
get RGB_COLOR threebyte MEMORY_FILE1
get ALPHA_CODE byte MEMORY_FILE1
if ALPHA_CODE > 0x00 & ALPHA_CODE < 0xFF
savepos CURRENT_LOCATION MEMORY_FILE1
math CURRENT_LOCATION - 1
goto CURRENT_LOCATION MEMORY_FILE1
put 0xFF byte MEMORY_FILE1
endif
next i

log FILE_NAME 0 SIZER MEMORY_FILE1
noire90
Posts: 4
Joined: Sun Feb 14, 2021 1:01 pm

Re: Code for texconv

Post by noire90 »

Thanks for your answer but those codes don't worked in my case. I know that I can modify them with gimp one by one (adding inside them a white layer) but it's a lot of work... :( My .dds are 5GXT maybe this is the reson that those codes don't worked... I don't know.
Shokoniraya
Posts: 416
Joined: Sat Sep 15, 2018 5:22 am

Re: Code for texconv

Post by Shokoniraya »

noire90 wrote:Thanks for your answer but those codes don't worked in my case. I know that I can modify them with gimp one by one (adding inside them a white layer) but it's a lot of work... :( My .dds are 5GXT maybe this is the reson that those codes don't worked... I don't know.


my script just works on 32-bit TGA files
convert your file with this batch code (with texconv.exe)

Code: Select all

md "output_folder"
"texconv.qgp" -y -ft TGA -m 1 "my_image.png" -o "output_folder"
noire90
Posts: 4
Joined: Sun Feb 14, 2021 1:01 pm

Re: Code for texconv

Post by noire90 »

I need a code for dds file please because my importer recognize just the dds textures
Shokoniraya
Posts: 416
Joined: Sat Sep 15, 2018 5:22 am

Re: Code for texconv

Post by Shokoniraya »

noire90 wrote:I need a code for dds file please because my importer recognize just the dds textures

convert your texture to tga and do your job and convert it to dds when you finish it

let me tell you something, if you want to edit texture files, you have to learn about color codes, texture encodings, mipmaps, block types, bit depth and many other things...
noire90
Posts: 4
Joined: Sun Feb 14, 2021 1:01 pm

Re: Code for texconv

Post by noire90 »

Thanks again for your answer Shokoniraya, you are so kind... but this still don't work. 1)I converted my .dds to .tga with xnConvert. 2) I created a batch file with your code(md "output_folder" "texconv.qgp" -y -ft TGA -m 1 "my_image.png" -o "output_folder"). 3) I have placed texconv.exe and batch file in the .tga folder and I have double-clicked on bach file... whats happened was... texconv don't started to process and convert them just an empty output folder was created.
Shokoniraya
Posts: 416
Joined: Sat Sep 15, 2018 5:22 am

Re: Code for texconv

Post by Shokoniraya »

this is a bat file code
replace texconv.qgp to texconv.exe
and replace my_image.png to your image file name (texconv can supports most of popular image formats)

Code: Select all

md "output_folder"
"texconv.qgp" -y -ft TGA -m 1 "my_image.png" -o "output_folder"