[DONE] Grimrock Model Tookit

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
Zo Kath Ra
Posts: 931
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: [DONE] Grimrock Model Tookit

Post by Zo Kath Ra »

wagtunes wrote: Fri Apr 30, 2021 6:51 pm So my question is this. Is the items.dds file part of the base game and located somewhere else? I did a complete hard drive search and the only place this file shows up is in the asset pack which I do not have in the path of my dungeon anyway.
The files in the asset pack (plus a few that aren't) are part of the base game, and contained in grimrock.dat

An item
* must have a gfxIndex
* can optionally have a gfxAtlas

If an item has no gfxAtlas, then the default gfxAtlas is used.
The default gfxAtlas consists of these files, chained together:
* assets/textures/gui/items.dds
* assets/textures/gui/items2.dds

The indices in a gfxAtlas are calculated automatically.
Index 0 is the leftmost icon in the top row.
Index 1 is the icon directly to the right of icon 0.
When you reach the rightmost icon in a row, increasing the index by 1 goes to the leftmost icon in the next row.

The item icons are 75x75 pixels each, but the width and height of a DDS file must both be a power of 2.
(not necessarily the same power of 2, AFAIK)
That's why items.dds is 1024x1024, even though only 975x975 are actually used.

If an item has a gfxAtlas:
See Isaac's explanation.

http://www.grimrock.net/modding_log1/cr ... om-assets/
has a section on "Using Custom Graphics"
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: [DONE] Grimrock Model Tookit

Post by Isaac »

A file location inside the asset pack is typically the same as the location in grimrock.dat; so you can use the path from the asset pack, and at runtime, your scripts will see it in grimrock.dat.
wagtunes
Posts: 316
Joined: Sun Feb 04, 2018 11:04 pm

Re: [DONE] Grimrock Model Tookit

Post by wagtunes »

minmay wrote: Fri Apr 30, 2021 8:25 pm This particular question is covered in the official modding guide in the Asset Definition Reference page:
gfxIndex: index of the item graphics in texture atlas.
gfxAtlas: filename of the texture atlas containing the item icon. The filename must be a valid asset reference ending with “.tga”.
Here is another concrete example:

Code: Select all

defineObject{
	name = "armour_scale_greaves",
	class = "Item",
	uiName = "Scale Greaves",
	model = "assets/models/items/leather_greaves.fbx",
	slot = "Legs",
	armorSkill = "light_armor",
	armorSet = "steel_light",
	gfxAtlas = "mod_assets/textures/items.tga",
	gfxIndex = 20,
	protection = 6,
	weight = 2.0,
}
wagtunes wrote: Fri Apr 30, 2021 6:51 pmSo my question is this. Is the items.dds file part of the base game and located somewhere else? I did a complete hard drive search and the only place this file shows up is in the asset pack which I do not have in the path of my dungeon anyway.
Everything in the asset pack is part of the base game.

You might also find it helpful to look at the source code for some existing dungeons that have released source code, like The Mine of Malan Vael or The Sunset Gate

Thanks. Much appreciated. I actually have the source files for the following dungeons.

Master Quest (the remake)
One Room Round Robin 2

ORR2 is quite complex. My head spins just looking at it. But I think if I slog my way through it I can learn an awful lot. The learning curve for coding this game is off the charts. If the game was this hard to play (thank God it's not) I would have given up after a week.
wagtunes
Posts: 316
Joined: Sun Feb 04, 2018 11:04 pm

Re: [DONE] Grimrock Model Tookit

Post by wagtunes »

Zo Kath Ra wrote: Fri Apr 30, 2021 8:32 pm
wagtunes wrote: Fri Apr 30, 2021 6:51 pm So my question is this. Is the items.dds file part of the base game and located somewhere else? I did a complete hard drive search and the only place this file shows up is in the asset pack which I do not have in the path of my dungeon anyway.
The files in the asset pack (plus a few that aren't) are part of the base game, and contained in grimrock.dat

An item
* must have a gfxIndex
* can optionally have a gfxAtlas

If an item has no gfxAtlas, then the default gfxAtlas is used.
The default gfxAtlas consists of these files, chained together:
* assets/textures/gui/items.dds
* assets/textures/gui/items2.dds

The indices in a gfxAtlas are calculated automatically.
Index 0 is the leftmost icon in the top row.
Index 1 is the icon directly to the right of icon 0.
When you reach the rightmost icon in a row, increasing the index by 1 goes to the leftmost icon in the next row.

The item icons are 75x75 pixels each, but the width and height of a DDS file must both be a power of 2.
(not necessarily the same power of 2, AFAIK)
That's why items.dds is 1024x1024, even though only 975x975 are actually used.

If an item has a gfxAtlas:
See Isaac's explanation.

http://www.grimrock.net/modding_log1/cr ... om-assets/
has a section on "Using Custom Graphics"
Okay, here's my question. This is what I'm confused about.

I know that index 0 from the base game is Sword of Nex. If I create a custom atlas with just one icon, which would be index 0 and designate that atlas in the script file on load, you're saying that the game will load my custom icon instead of the Sword Of Nex. Correct?

Next question. In loading the items.dds file, I see that the items themselves are one after another, row by row. But there doesn't seem to be any actual separator between icons. So how does the software know where one icon ends and the next icon begins? How exactly was items.dds constructed so that each icon is in fact separate? Somehow I( think if I open up a 1024x1024 blank file in Photoshop and place images, one after another in a row, that the software is going to recognize each one as a separate icon. There has to be something we have to program so that the software knows where each icon is. Yes, no?

What am I missing?
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: [DONE] Grimrock Model Tookit

Post by Isaac »

wagtunes wrote: Fri Apr 30, 2021 9:54 pmORR2 is quite complex. My head spins just looking at it. But I think if I slog my way through it I can learn an awful lot. The learning curve for coding this game is off the charts. If the game was this hard to play (thank God it's not) I would have given up after a week.
Not just the scripts, examine some of the models too. ;)
*Buttons were the only way to add complex animations to [non-monster] objects in LoG1. LoG2 changes the way scripts need to be written, but it improves over LoG1's scripting by a great deal, and makes trivial some of the tasks that we had to jump through hoops to manage in LoG1. 8-)
wagtunes wrote: Fri Apr 30, 2021 10:02 pmIf I create a custom atlas with just one icon, which would be index 0 and designate that atlas in the script file on load, you're saying that the game will load my custom icon instead of the Sword Of Nex. Correct?
Yes; it will use icon #0 of the custom atlas.
Next question. In loading the items.dds file, I see that the items themselves are one after another, row by row. But there doesn't seem to be any actual separator between icons. So how does the software know where one icon ends and the next icon begins?
75 pixels per square icon.
How exactly was items.dds constructed so that each icon is in fact separate? Somehow I( think if I open up a 1024x1024 blank file in Photoshop and place images, one after another in a row, that the software is going to recognize each one as a separate icon. There has to be something we have to program so that the software knows where each icon is. Yes, no?
Careful manual layout is needed to build an atlas from scratch by hand. You might be able to use Photoshop's built in Contact Sheet script to align a folder of icons into an atlas, but The Grimrock Atlas Toolkit handles the layout perfect, and automatically. 8-)
Last edited by Isaac on Fri Apr 30, 2021 11:21 pm, edited 2 times in total.
wagtunes
Posts: 316
Joined: Sun Feb 04, 2018 11:04 pm

Re: [DONE] Grimrock Model Tookit

Post by wagtunes »

Isaac wrote: Fri Apr 30, 2021 10:06 pm
wagtunes wrote: Fri Apr 30, 2021 9:54 pmORR2 is quite complex. My head spins just looking at it. But I think if I slog my way through it I can learn an awful lot. The learning curve for coding this game is off the charts. If the game was this hard to play (thank God it's not) I would have given up after a week.
Not just the scripts, examine some of the models too. ;)
*Buttons were the only to add complex animations to [non-monster] objects in LoG1. LoG2 changes the way scripts need to be written, but it improves over LoG1 scripting by a great deal, and makes trivial some of the tasks that we had to jump through hoops to manage in LoG1. 8-)
wagtunes wrote: Fri Apr 30, 2021 10:02 pmIf I create a custom atlas with just one icon, which would be index 0 and designate that atlas in the script file on load, you're saying that the game will load my custom icon instead of the Sword Of Nex. Correct?
Yes; it will use icon #0 of the custom atlas.
Next question. In loading the items.dds file, I see that the items themselves are one after another, row by row. But there doesn't seem to be any actual separator between icons. So how does the software know where one icon ends and the next icon begins?
75 pixels per square icon.
How exactly was items.dds constructed so that each icon is in fact separate? Somehow I( think if I open up a 1024x1024 blank file in Photoshop and place images, one after another in a row, that the software is going to recognize each one as a separate icon. There has to be something we have to program so that the software knows where each icon is. Yes, no?
Careful manual layout is needed to build an atlas from scratch by hand. You might be able to use Photoshop's built in Contact Sheet script to align a folder of icons into an atlas, but The Grimrock Atlas Toolkit handles the layout perfect, and automatically. 8-)
Ah, okay, So it really is a matter of placing 75x75 graphics one after another and the software does the job of delineating everything. But yeah, some kind of template that helps align things would make it a lot easier.

Okay, I think I can take it from here. I certainly have a lot of material to go through.

Thank you again for everything. I really appreciate it.
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: [DONE] Grimrock Model Tookit

Post by Isaac »

Tip In Photoshop, before the Atlas toolkit, I would place colored [single] pixels at the corners of the 75x75 pixel icons. This makes it easier to align the icons, and won't show in the game if the icon alpha channel is black at the corners.
wagtunes
Posts: 316
Joined: Sun Feb 04, 2018 11:04 pm

Re: [DONE] Grimrock Model Tookit

Post by wagtunes »

Okay, here is where I am. I thought I had this but now I'm totally confused.

I found an image of runes laid out in icon format. I brought it into photoshop, made sure everything lined up with the items.dds and saved as a PNG file. I then imported the PNG file into Graphics Atlas, which assigned each rune an index perfectly, and then exported as a DDS file.

I then went into my script and defined my runes.dds file as my atlas file, making sure I made the file type tga.

When I start up the dungeon, I get this error message.

[String "item.lua"]:0: Unknown uncompressed DDS pixel format in file mod_assets/textures/items/runes.dds

Why?

When I bring items.dds into photoshop, every icon is crystal clear. When I bring runes.dds into photoshop, it's almost just a black photo. You can't make out anything.

So the atlas program didn't create the DDS file properly. What I don't understand is why? What could have possibly been wrong with the file I imported? Everything looked good in the atlas program and every icon was given an index.

Help.
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: [DONE] Grimrock Model Tookit

Post by Isaac »

There are various DDS compression modes, and uncompressed modes.

The one used for GUI icons is D3DFMT_A8R8G8B8 ; or... A8R8G8B8

Link: http://www.grimrock.net/modding_log1/cr ... 20Graphics

(This link might scroll to the intended paragraph, but if not... scroll down to the section on "Using Custom Graphics".)

Try changing the compression mode to A8R8G8B8 when exporting.

Also: There is this thread from a while back:

http://www.grimrock.net/forum/viewtopic ... ion#p96967
wagtunes
Posts: 316
Joined: Sun Feb 04, 2018 11:04 pm

Re: [DONE] Grimrock Model Tookit

Post by wagtunes »

Isaac wrote: Sat May 01, 2021 3:33 am There are various DDS compression modes, and uncompressed modes.

The one used for GUI icons is D3DFMT_A8R8G8B8 ; or... A8R8G8B8

Link: http://www.grimrock.net/modding_log1/cr ... 20Graphics

(This link might scroll to the intended paragraph, but if not... scroll down to the section on "Using Custom Graphics".)

Try changing the compression mode to A8R8G8B8 when exporting.

Also: There is this thread from a while back:

http://www.grimrock.net/forum/viewtopic ... ion#p96967
I went into Photshop and tried every format that was even close to what you have above. The closest I come to making this work (and this is really weird) is the rune icon texture wraps around the sword of nex. So you see a yellow colored sword.

I am out of ideas.
Post Reply