[Tutorial] How To Find Material Textures For Objects
#1

Introduction
Materials are a great way to make an object look different with the same shape. This way, you can make your own customized objects with the textures you want. Those textures must be taken from an already existing object from the San Andreas world. Some objects are too complex, and may have over a dozen of different materials, so you don't know which one is which, and don't know which index to set.

This tutorial is directed to newbies who want to expand their knowledgement and assign different material textures to any object. San Andreas uses an UV mapping technique to give life to it's objects. The textures are contained in a .TXD file (which is stored in your typical gta3.img file). This txd file is the main storage unit of textures, which can be stored in a .BMP, .PNG or .TGA format.

This tutorial may be obsolete for people who use filterscripts or in-game applications to create maps. For those who prefer to use 3rd party software (most of people use map editor), or those who don't want to make a large map, rather a system which uses a specific, re-textured object, this tutorial is fine.

For this tutorial, we will need two lightweight programs: TXD Workshop and Map Construction, both made by JernejL.

How To Find The Correct Material Index
This tutorial isn't an introduction to mapping techniques. I will be teaching you how to find the materials of an object. For this tutorial, I'll be using the horse races betting machine. I want to change the texture of the screen, and the texture of the panel. As you can see in the image, each side of the object has a different texture, because each side is a different material. I've numbered them below, so you can appreciate the difference between each side of the object representing a different texture.


If you place this object anywhere in the game world, then double click this object in the map editor, you will see this window:


I've only highlighted 3 important items, which are what we need to progress. If we want to change the panel and the glass, we must find which materials belong to the panel and to the glass. For this, we will use our beloved TXD Workshop. In the program, we must open an IMG file in which the texture is contained. For objects in INTERIORS, this file will always be gta_int.img. Otherwise, always open gta3.img. If you can't find your texture in gta3.img, look in other .img files.


In the bottom left of the program, there's a search bar. Paste there the TXD name (the "Texture" box from the window that came in the map editor) and add the .txd extension at the end (to not look for .dff models). Select it, and immediately at the right you will see all the raw, texture images contained in this .TXD file. Here, you can match those results with the window from map constructor.

If you look back at the map editor window, it says that "Material: 0 split: 0 Tex: ab_shinyPanel". If you look for "ab_shinyPanel" in the texture list, you will easily identify it. Now, you know that material 0 belongs to the shiny panel at the bottom of the object. But, in this tutorial, we want to find the material index for the glass and the coloured purple panel. How? Using the same method, we can easily deduce that "otb_mural3" is the texture for the panel, and "ap_screens1" is for the glass. So, we match those results with the map editor, and we can know the materials for them:
Code:
Material: 2 split: 2 Tex: otb_mural3  (panel)
Material: 4 split: 4 Tex: ap_screens1 (glass)
How To Re-Texture An Object With That Material Index
Now we know that material 4 belongs to the glass, and material 2 belongs to the colored panel. All other materials will be disregarded, since we don't want to change the texture in this tutorial. Now, all we have left for us is to find what new texture we want to assign. Luckily, the job has been made easier because the game textures are available as samples in this website. We simply search for a new texture, and we will find it. If you want, you can use map editor and TXD Workshop to find every other texture, using the same method I've explained here. I found a cool new screen texture, and a new texture for the panel.

Clicking on a texture in the website will come up with this window:


It will offer you a ready PAWN code. You can use that if you want, but you will have to change the second argument (the material ID) for the material ID we found earlier for the glass. Otherwise, you can also match the arguments from the native function SetObjectMaterial yourself with the given information (model ID, texname and txdname, which is what the function asks for).

At the end of the day, I ended up with this:
Code:
SetObjectMaterial(objectid, 4, 9818, "ship_brijsfw", "ship_greenscreen1", 0xFFFFFFFF);
SetObjectMaterial(objectid, 2, 9241, "sfn_helipad", "helipad_basepanel", 0xFFFFFFFF);
Remember how we found material 4 is for the glass, and 2 is for the panel? We simply put that index in the function, and put the textures we found in the other arguments. That way, we will have this:


Looks much better!

Thanks for reading this quick small tutorial.
Reply
#2

Prior to reading this, I never knew how to actually use SetObjectMaterial. However, your tutorial cleared this up for me! I will be using this as a tool for my script in the future. Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)