Page 1 of 3
Applying a texture to a custom model (SUCCESS)
Posted: Wed Dec 05, 2012 11:55 pm
by vorebane
Specifically, my complete inability to do so.
I believe I've got the script right - it looks like this:
Code: Select all
cloneObject{
name = "anvil",
baseObject = "altar",
uiName = "Anvil",
model = "mod_assets/models/crummyanvil.fbx",
normalMap = "mod_assets/models/crummyanvil_normal.dds",
diffuseMap = "mod_assets/models/crummyanvil_dif.dds",
specularMap = "mod_assets/models/crummyanvil_spec.dds",
glossiness = 0,
lighting = false,
anchorPos = vec(0, 0, 5),
anchorRotation = vec(0, 0, 0),
targetPos = vec(0, 2.0, 0),
targetSize = vec(50, 50, 50),
}
The dds files in question are just dungeon altar texture files that I've gone through every layer and filled with a single colour, using gimp. However they seem to have had no effect. It still looks like this:
http://imgur.com/mqrAm
I realize I have no idea what I'm doing. Should I be figuring out what my vertices and such for perfectly wrapping a texture around, even if I'm ok with a flat single colour object? Because I have no idea where to start doing that, or how to tell the script, model, or texture image what it's supposed to do. I hope someone can help me out, this is one of the things I want to fix before I release my dungeon to the wilds.
Re: Applying a texture to a custom model
Posted: Thu Dec 06, 2012 12:23 am
by montagneyaya
For applying a texture to a model you must add materials (define the texture) in your mod_asset/scripts/materials.lua file
For your crummyanvil
Code: Select all
defineMaterial{
name = "crummyanvil",
diffuseMap = "mod_assets/textures/env/crummyanvil_dif.tga",
specularMap = "mod_assets/textures/env/crummyanvil_spec.tga",
normalMap = "mod_assets/textures/env/crummyanvil_normal.tga",
doubleSided = false,
lighting = true,
alphaTest = false,
blendMode = "Opaque",
textureAddressMode = "Wrap",
glossiness = 30,
depthBias = 0,
}
You must have the file (texture) you define in your defineMaterial
Here you must have the mod_asset/textures/env/crummyanvil_dif.dds, mod_asset/textures/env/crummyanvil_spec.dds, mod_asset/textures/env/crummyanvil_normal.dds files.
With blender (or other 3D editor) you must map the texture (crummyanvil_dif.dds) on your model.
With Grimrock Model Toolkit you must applicate your defineMaterial on the model.
Create your object in your mod_asset/scripts/objects.lua
For your crummyanvil
Code: Select all
defineObject{
name = "crummyanvil",
class = "Altar",
model = "mod_assets/models/env/crummyanvil.fbx",
placement = "floor",
editorIcon = 52,
}
And have the mod_assets/models/env/crummyanvil.model file.
That's all I think.
Re: Applying a texture to a custom model
Posted: Thu Dec 06, 2012 1:23 am
by Mal85
Re: Applying a texture to a custom model
Posted: Thu Dec 06, 2012 2:35 am
by Kuningas
EDIT: The tutorial Mal posted is very good, I suggest you follow it, I didn't notice it at first.
If you are merely editing or making a new texture for an existing asset, the mapping phase is usually unnecessary. But it seems you are making a new model, and that is beyond my skill-territory. : D
Texture editing in a nutshell:
I -- Make the texture (I think you have this part covered ; D)
II -- Make a material for the said texture , that is a new entry in the materials.lua. It should work if you just get the file path right, so it'll be easiest to copy an existing one and change the file it points to. You can then experiment on the other values the material definition has, refer to the modding guide here on grimrock.net. Transparency is one worthwhile feature to learn, but it is not crucial when beginning.
III -- Get the Grimrock Model Toolkit made by JohnWordsworth. Fear not -- it is an amazing program and not even very complicated for just changing the material. Then open the model you are changing the texture for in the model toolkit, take the replace material option from the menu, and type in the name of your custom material. Remember to press the replace material button and save the model afterwards. Note that if you want to preserve the original within your mod, don't overwrite the original model. It'll still use the old material then and you'll have both. (just make sure the newly textured object you use points to the edited model)
IV -- Do a victory dance (phase highly optional, especially in public)
All in all, editing the assets is juggling with the lua files and changing the material with the Toolkit. It'll become highly automated and you'll learn to recognise where you made mistakes really fast, thanks to the helpful error messages the editor gives. It is actually a relief for me to see a familiar error report, because I know I can fix it in a jiffy. Simple naming conventions will also make things much easier.
Re: Applying a texture to a custom model
Posted: Thu Dec 06, 2012 2:38 am
by vorebane
Thanks both of you for responding. I think my current sticking point is mapping the texture in blender. I found some cool tutorials at blendtut.com but I think the programs changed since because the supposedly magical unwrapping menu on the u key mentioned in 'UVs and Textures part 1' now does something else entirely. I am painfully aware this is all very basic stuff please help me out anyway.
Edit: Thanks all three of you, I mean! Yah the tutorial is not quite what I'm after figuring out, I am taking a model I've made and hopefully giving it some kind of paint job.
Re: Applying a texture to a custom model
Posted: Thu Dec 06, 2012 3:07 am
by Skuggasveinn
Maybe this can help you, its a tutorial I made that goes through the steps of editing models for Grimrock using blender.
Around the 20min mark I go into UV mapping (not really deep) but perhaps enough so that you can continue with your model and give it some textures.
http://www.youtube.com/watch?v=tMrs7j2J354
The U key in blender brings up the Unwrapping options, that has not changed in years.
You just have to have your model selected, and you need to be in edit mode for it to bring up the UV options.
Skuggasveinn.
Re: Applying a texture to a custom model
Posted: Thu Dec 06, 2012 11:44 am
by vorebane
I'm making progress! My current problem is that I can't get LoG to recognize that the dds file that gimp made from a png file that was an exported map from blender. Just cutting out the middleman tells me LoG doesn't know what to do with pngs. Screenshots and your video, Skug, suggest to me showing textures in the Grimrock Model Toolkit are possible, but I have the newest version and haven't figured this out yet. I'm turning in for the night, hopefully something will make more sense in the morning.
Re: Applying a texture to a custom model
Posted: Thu Dec 06, 2012 1:02 pm
by Neikun
You can't use pngs to texture Grimrock Models, only .DDS. Otherwise they will not show up in game.
However, in your material definition, your file name should end with .tga (confusing, we know)
So if you have an image called my_thing_dif.dds
You'd define it with possibly, diffuseMap = "mod_assets/textures/my_thing_dif.tga",
Re: Applying a texture to a custom model
Posted: Fri Dec 07, 2012 3:24 am
by vorebane
That is confusing, and I'm glad I got it fixed but it seems like there's still something wrong. I've tried looking through the videos that have been suggested, but I'm still not getting it. I do much better with writing, so I would really extremely appreciate it if someone could break down exactly what the process is supposed to be to create a texture for a custom object. I've got a flattened map across a flat grey image (that's all i want, why is this so hard) export that into a png, use gimp to turn that into a dds, but it changes nothing. What am I missing here?
Re: Applying a texture to a custom model
Posted: Fri Dec 07, 2012 4:16 am
by Neikun
You have a model that has it's uvmapping correct for an image?
Perhaps if you could send me the files, I could write you a definition.
I theorize that if it is correctly mapped, the last step is to simple take that png and convert it to .dds and correctly define the material.
Dunno if this was touched on, but none of your material definition should be inside of your object definition.
You need to define an object and material separately. In order to have the model recognize which images are to be loaded onto it, you have to open your model up with the GMT and replace the material with your newly defined one.
I do plan on making a texturing tutorial, but right now I am working too much at my day job.