.png sprite loading removed from OpenTTD

Discuss, get help with, or post new graphics for TTDPatch and OpenTTD, using the NewGRF system, here. Graphics for plain TTD also acceptable here.

Moderator: Graphics Moderators

User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: .png sprite loading removed from OpenTTD

Post by GeekToo »

Update of the script, I played with the result, and the coast tiles are OK, did not check every graphic yet.

Removed the change of the grf version, I saw it was 08 in Rubidiums header and thought it was needed.
Further, solved the problems with the pcx in the trains subdir (don't forget to copy those pcxs too).
Attachments
32b_extra_2_info32_sh.txt
(4.71 KiB) Downloaded 619 times
Vector
Engineer
Engineer
Posts: 15
Joined: 02 Feb 2012 02:48

Re: .png sprite loading removed from OpenTTD

Post by Vector »

Thanks, now it works. But when I try to make it static, the game complains that it's unsafe.

@FooBar:
Thanks, I tried that before previous posting and it didn't take for some reason, so I undid the change. Thanks to you, I've tried again and it worked. Nothing done differently, so no idea what made it not work the first time around.
OpenTTD zombie: "Tra-a-a-ains!"
knuckles88
Engineer
Engineer
Posts: 34
Joined: 08 Jan 2012 08:48

Re: .png sprite loading removed from OpenTTD

Post by knuckles88 »

Michi_cc wrote:
Vector wrote:An average Joe/Jane, especially using Win, would not be able to make much use of it.
If the average Joe wanted extra zoom graphics before, he had to download and install a special executable, find a working pack of graphics, set a specific blitter in a config file and load a special NewGRF for his games. Looking at older threads in this forum, the average Joe failed quite often with that, so I can't see that much difference to the situation now.

-- Michael Lutz
I am average Joe Windows user! I actually did manage to jump through all the hoops and get working 32bpp graphics back in the days of png loading, but I'm now stumped by this script. As far as I can tell, I need to place create.txt, empty.pcx, and apparently grfcodec all in the same folder as the old 32bpp .png's and then... do something? As an average Joe Window user, I don't understand how to "run" a text file. Anyone patient enough to walk me through this?

Note: I already have python installed.
User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2369
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: .png sprite loading removed from OpenTTD

Post by Lord Aro »

basically, you can't :)

The simplest way (IMO) would be to install some sort of bash emulator
Try the tutorial on MinGW and see if that helps: http://wiki.openttd.org/Compiling_On_MinGW
Then, remove the .txt file extension, navigate (in MinGW) to the file, then "./<filename>" and voila :)
AroAI - A really feeble attempt at an AI

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
knuckles88
Engineer
Engineer
Posts: 34
Joined: 08 Jan 2012 08:48

Re: .png sprite loading removed from OpenTTD

Post by knuckles88 »

OK... I have access to another computer with Ubuntu installed. Is there an easier way if I use that computer?
User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2369
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: .png sprite loading removed from OpenTTD

Post by Lord Aro »

i would guess so

just put the file in the correct place, then run it (in terminal)
AroAI - A really feeble attempt at an AI

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
knuckles88
Engineer
Engineer
Posts: 34
Joined: 08 Jan 2012 08:48

Re: .png sprite loading removed from OpenTTD

Post by knuckles88 »

Lord Aro wrote:i would guess so

just put the file in the correct place, then run it (in terminal)
So what command am I running? "bash create.txt" or something? I'm very new to linux.

Also, do I need anything in the folder other than the script, the .pcx, and the sprites? Is grfmaker/pngcodec also required?
User avatar
Lord Aro
Tycoon
Tycoon
Posts: 2369
Joined: 25 Jun 2009 16:42
Location: Location, Location
Contact:

Re: .png sprite loading removed from OpenTTD

Post by Lord Aro »

umm, yes

i think you need: grfcodec, pngcodec, PIL, PLY (i'm not sure if thats all)

You'll need to make it executable - you can do this by going to properties of the file (for simplicity)
and then run by : "./<filename>" (although i think "bash <filename>" would work)
AroAI - A really feeble attempt at an AI

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: .png sprite loading removed from OpenTTD

Post by GeekToo »

PIL and PLY are not needed, only if you want to nml stuff, but the create.txt creates an nfo. Furthermore all the pngs are needed, and one or more pcx's. If the ./create.txt (put it in the directory where all the graphics are, and cd to it) does not work, try chmod 744 create.txt to make it executable.
knuckles88
Engineer
Engineer
Posts: 34
Joined: 08 Jan 2012 08:48

Re: .png sprite loading removed from OpenTTD

Post by knuckles88 »

Ok, thanks :)

Which png's are supposed to be in this folder? In my old openttd data/sprites folder I have un-tar'd to get:

32bpp_extra
ogfx1_base
ogfxc_arctic
ogfxe_extra
ogfxh_tropical
ogfxi_logos
ogfxt_toyland

...and a few others related to grf's I installed. Can I use the script to make grf's out of each of these folders separately, or was it designed for only one?
knuckles88
Engineer
Engineer
Posts: 34
Joined: 08 Jan 2012 08:48

Re: .png sprite loading removed from OpenTTD

Post by knuckles88 »

OK so further to my previous post... I'm actually trying this right now and I'm getting a few errors.

-I was able to install grfmaker but I don't understand what I'm supposed to do with pngcodec. "sudo apt-get install pngcodec" does nothing - I can download a compiled binary from the pngcodec website, but I don't know where to put it so that I can call "pngcodec" in terminal and not have it fail. Right now I've placed pngcodec in the same folder as all the .png's, but when I run the script it repeatedly says "pngcodec: command not found"

-I think I need some other libraries? I installed both PIL and PLY, but when I run the script it says "ImportError: No module named Image"

-I'm still confused about what .png's go in the folder with the script. When I un-tar'd 32bit-gfx-nightly-megapack-2011-04-16 it contained all those subfolders I mentioned earlier. Trying to run create.txt from the parent folder failed, saying there were no images, so I extracted some of the files out of a subfolder, but I don't understand how the script can assign the correct meaning to each sprite this way - doesn't the subfolder provide important information about which graphics the .png's are to replace?
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: .png sprite loading removed from OpenTTD

Post by GeekToo »

knuckles88 wrote:OK so further to my previous post... I'm actually trying this right now and I'm getting a few errors.
-I was able to install grfmaker but I don't understand what I'm supposed to do with pngcodec. "sudo apt-get install pngcodec" does nothing - I can download a compiled binary from the pngcodec website, but I don't know where to put it so that I can call "pngcodec" in terminal and not have it fail. Right now I've placed pngcodec in the same folder as all the .png's, but when I run the script it repeatedly says "pngcodec: command not found"
You don't need grfmaker, but grfcodec for the create.txt script. Pngcodec can be forgotten about in the future, but is needed now in the conversion to decode the offsets in the png text chunks, so they can be used in the new format. That new format is created by grfcodec, and it needs png files and a text file (the nfo file, with information about the sprites, like the filename and offsets) as input.
So the scripts loops over all the png (that contain an encoded offset) in the old format, grabs the offset and creates and nfo file out of it. And then renumbers the lines in the nfo file (one more thing you need: nforenum) and finaly uses grfcodec to encode the nfo file and the pngfiles to make a .grf file that can be loaded by the game.
Your pngcodec problem can be solved by putting pngcodec in a directory that is included in your path, or by changing the script to call ./pngcodec if it is in the current directory.
knuckles88 wrote: -I think I need some other libraries? I installed both PIL and PLY, but when I run the script it says "ImportError: No module named Image"
Check that you installed PIL correctly. I forgot about this in the previous post, but the script checks some palette stuff etc and needs PIL for that.
knuckles88 wrote: -I'm still confused about what .png's go in the folder with the script. When I un-tar'd 32bit-gfx-nightly-megapack-2011-04-16 it contained all those subfolders I mentioned earlier. Trying to run create.txt from the parent folder failed, saying there were no images, so I extracted some of the files out of a subfolder, but I don't understand how the script can assign the correct meaning to each sprite this way - doesn't the subfolder provide important information about which graphics the .png's are to replace?
Perform the process per subfolder (except the 32bpp_extra folder, that one needs different handling). The most useful one to start with is the ogfx1_base folder. Go to this directory, check it contains several png files, and copy the necessary things: the pcx file and the script. The information about which graphics are replaced, is in the png file numbering (for the base sets, except for the extra grf, that is the reason why that one needs different handling). Start the script, if all goes well it will create a .grf file, that you can put in the newgrf directory of one of your recent game installs. And you can activate it ingame in the newgrf settings.
knuckles88
Engineer
Engineer
Posts: 34
Joined: 08 Jan 2012 08:48

Re: .png sprite loading removed from OpenTTD

Post by knuckles88 »

Is it normal for the script to report "Fudging palette of ..." and various sprite numbers? If so, I got it to run without any errors (note to anyone interested in trying this: installing PIL correctly with PNG support gave me a LOT of difficulty).

GeekToo, you say that the script should create a .grf, but as far as I can tell it's just creating a .nfo. I've never compiled a .nfo to .grf before, so I'm not sure if I'm doing it right. I have grfcodec in the same parent folder to ogfx1_base, and I run "grfcodec -e grf_32bpp.grf ogfx1_base". The result of this is "Cannot read ogfx1_base/grf_32bpp.nfo: No such file or directory" - which confuses me because the file definitely exists. Poking around has given me two things that confuse me:

1) although I've downloaded grfmaker 6.0.0 from http://www.openttd.org/en/download-nforenum , running "grfcodec" returns "GRFCodec 5.1.2 - Copyright (C) 2000-2005 by Josef Drexler" - do I have the right version?

2) the .nfo file contains the header:

Code: Select all

// Automatically generated by GRFCODEC. Do not modify!
// (Info version 32)
// Format: spritenum.pngfile xpos ypos compression ysize xsize xrel yrel
..is the period between "spritenum" and "pngfile" supposed to be there?

Assuming those 2 issues are little things... what is the right way to convert this .nfo into a .grf?
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: .png sprite loading removed from OpenTTD

Post by GeekToo »

Code: Select all

nforenum grf_32bpp.nfo
grfcodec -f -e -g2 grf_32bpp.nfo .
Mind the dot at the end
knuckles88
Engineer
Engineer
Posts: 34
Joined: 08 Jan 2012 08:48

Re: .png sprite loading removed from OpenTTD

Post by knuckles88 »

GeekToo wrote:

Code: Select all

nforenum grf_32bpp.nfo
grfcodec -f -e -g2 grf_32bpp.nfo .
Mind the dot at the end
Running those command in the ogfx1_base folder where the .nfo was generated gives me:

Code: Select all

nforenum grf_32_bpp.nfo
NFORenum 5.1.2 - Copyright (C) 2004-2011 by Dale McCoy
Could not open "grf_32_bpp.nfo" specified on the command line.

Code: Select all

grfcodec -f -e -g2 grf_32bpp.nfo .
grfcodec: invalid option -- 'g'
GRFCodec 5.1.2 - Copyright (C) 2000-2005 by Josef Drexler
Does this have to do with it being version 5.1.2? I don't understand why it's not version 6... I downloaded grfcodec-6.060-linux-generic-amd64.tar.gz from http://www.openttd.org/en/download-grfcodec
User avatar
GeekToo
Tycoon
Tycoon
Posts: 961
Joined: 03 Jun 2007 22:22

Re: .png sprite loading removed from OpenTTD

Post by GeekToo »

try: which grfcodec
to find out if you have an older version hanging around
knuckles88
Engineer
Engineer
Posts: 34
Joined: 08 Jan 2012 08:48

Re: .png sprite loading removed from OpenTTD

Post by knuckles88 »

Awesome! I did indeed have and old version of grfcodec installed, and with it removed I finally made a working .grf :) :) :) I wasn't able to make nforenum work (edit: tried again and it did; presumably made a typo).

What are the limitations of this script? Does it only work on the nightly packs? What about the larger nightly dev packs? I believe I have some graphics (saved in ogfx1_base or whatever) which I collected from the forums and used myself even though they weren't in the nightly builds - if they're in the correct folders and they've got correctly coded pngcodec offsets, can the script incorporate them into its grf?

Also, what happens if I run this in each of the folders (ogfx1_base, ogfxc_arctic, etc.) - will it be able to produce a series of grf's which can all be used in-game at the same time, or will they all have the same grfid and be incompatible or something.

Thanks to everyone who's gotten me this far :)
knuckles88
Engineer
Engineer
Posts: 34
Joined: 08 Jan 2012 08:48

Re: .png sprite loading removed from OpenTTD

Post by knuckles88 »

How does the company colours mask work for this blitter? When I applied this script to all the 32bpp graphics I'd collected in my own ogfx1_base folder, a lot of them ended up having non-indexed masks. I indexed the mask files using a GIMP script, but it seems that a lot of the files now have odd colouration (e.g. massive white areas), which seems to be a problem with the masks.

The only documentation I can see on masks is on this wiki page: http://wiki.openttd.org/How_to_Create_3 ... Extra_Zoom . It says that areas of the mask which have colour indices between 196 and 203 will have company colours applied. From playing around and trying to fix the massive white spots, it seems that changing the colour of the mask changes how company colours area applied. Is this observation correct? Does the colour displayed in-game depend on the value of the mask colour's index (but not the actual colour this represents in the palette) or does it depend on the actual colour (i.e. on both the index and the palette used)?

The other information on the wiki page above is:
Mask files add company colour to the sprites depending on the HSV values of the sprite's regular colour in the affected areas. That's Hue (the colour), Saturation (the "colourfulness") and Value (the lightness/darkness). There are two pincipal company colours (although that shouldn't be confused with the 2nd company colour) in each colour scheme, that are alternated for every 60 degrees of hue. Confused? It simply means that the primary colours red, green and blue (RGB model, remember?) get the first colour, while the "mixed" colours yellow, cyan and magenta get the second colour. A colour in between these causes mixing of the first and second.
...plus a statement that the S and V of the original image influence the S and V of the image after company colours are applied. Is the paragraph above supposed to be an explanation of what Hue is, or is it something specific to OpenTTD that I'm misunderstanding?
emaluzer
Engineer
Engineer
Posts: 12
Joined: 17 Jun 2012 01:11

Re: .png sprite loading removed from OpenTTD

Post by emaluzer »

If you figure this out and can help....I want to do the same as you....maybe if you are successful can you email the new grf file to me?
Michi_cc
OpenTTD Developer
OpenTTD Developer
Posts: 619
Joined: 14 Jun 2004 23:27
Location: Berlin, Germany
Contact:

Re: .png sprite loading removed from OpenTTD

Post by Michi_cc »

knuckles88 wrote:Does the colour displayed in-game depend on the value of the mask colour's index (but not the actual colour this represents in the palette) or does it depend on the actual colour (i.e. on both the index and the palette used)?
The GRF itself only stores the colour indices which are interpreted using the fixed, built-in TTD DOS palette. Thus in the source mask file only the indices are relevant, but nml and grfcodec are supposed to tell you if the palette in the PNG doesn't match the OTTD palette.

For the second point, the recolour algorithm in trunk (1.2) is different than the one in the ez-zoom patch, because that one was very complicated and expensive. For each pixel, trunk will calculate the brightness from the RGB values (which is simply max(R,G,B)) and use it to modulate the colour corresponding to the mask colour index (brightness == 64 means no change, 128 means double brightness and 32 half and so on). There's some trickery involved to avoid numeric overflow, but that's the basics. The result is similar to the ez recolour, but not identical.

-- Michael Lutz
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: Amazon [Bot] and 8 guests