[Guide] GTA V: Shaders materials and textures

GTA:V Modding with ZModeler3 discussion.

Moderator: madga182

[Guide] GTA V: Shaders materials and textures

Postby Oleg » Sat Aug 08, 2015 8:21 am

GTA V: Shaders and materials guide.

Each material you use in your mod must be configured to match needs of one of in-game shaders. An in-game shaders set can be found in common.rpf -> shaders -> win32_40_final. There is a lot of available shaders for most of cases you might need. Currently, only vehicle-specific shaders were ported into ZModeler, so the import/export filter as a build-in configuration code for a small subset of available shaders.

To specify an in-game shader on material you type its name in an Adaptation (or Adapt) field of material entry. Since shader configuration is quite complex and to help you configure material properly, I've made a material configuration script. You can pick your material and press configuration button to pick desired material preset in GTAV branch:

13_material_config_preset.jpg


After application, the adaptation is set to selected one and material options are set with respect to shader needs. This includes assignment of suitable shader among standard ZModeler shaders, configuring texture slots to use proper UV mapping, advanced colors are also configured and masked properly. Additionally, a set of user-defined options is added with respect to shader needs, so you can fine-tune some aspects of shader configuration on export.


The configuration script (GTAV.xml) is located in Config -> Materials folder inside ZModeler and can be updated via autoupdate as the rest of ZModeler modules.



Paintable materials.

Some of shaders support mesh paint with up to four paint colors supported. You can specify which color to use on material by using a [PAINT:1] suffix in material name where 1 could be replaced with 2,3 or 4. So, you specify the usage of primary, secondary etc. colors on a specific material. For example, material named deails_outerside [PAINT:1] will be exported as painted into primary color and if associated shader supports paint, this material will appear painted in game. Beside vehicle_paint* shaders, painting supported on vehicle_doorshuts, vehicle_mesh and probably on some other too.

Dirt mapping.

Most of in-game vehicle shaders support dirt mapping. Dirt map is usually assigned on MASK texture slot and is configured on Colors page in "Advanced Shader Colors" group. Dirt is masked by dirt-mask texture's Red channel, so the following configuration is quite common on materials:
14_dirt_config_on_paint1.jpg


This is a default configuration for dirt mapping on vehicle_paint1 shader. You can use standard "vehicle_genericmud_car.dds" texture for dirt-mapping. In case of vehicle_paint1, it requires UV#2 of the mesh to be mapped properly.

Burnt effect.

Vehicle shaders support burnt effect that is rendered by game engine when an object is burning and when it's burnt completely. This uses a transition of several stages (early burn, mid burn and full burnt state) and standard "vehicle_generic_burnt_int" or "vehicle_generic_burnt_out" texture is used by the game engine. Since this is generally hard-coded in shaders, there is no need to reproduce the same when making a mod, you just need to see how burnt state will appear on your mesh and whether it's Ok or not.

That is why I've made a compilation of burn texture and assigned it onto standard dirt-mapping texture's alpha channel. A burn state configuration on ZModeler relies on this scenario and configures burn to be masked by MASK.Alpha texture slot. Additionally, burn level is affected by per-vertex Blue color channel. This have been shown in GTA V: Scene hierarchy, compound objects, geometries topic in Geometries section. So, the following configuration is the most common for burnt state:

15_burn_config_on_paint1.jpg


A dirt-mapping texture with burnt effect compilation in alpha channel is attached to this post. You can use either a plain texture vehicle_genericmud_car.dds replacement if you've unpacked vehshare.ytd texture package (preferred solution), or use a texture pack replacement that already includes a compiled texture it (also attached to this post) below.

Vehicle lights, dashboard lights

Some shader includes a condition-lit code and will draw emissive/light elements when some criteria is met. For example, vehicle lights is a single material with single texture applied to a mesh where all light components are a single object. In order to determine whether certain elements are break lights, reversing lights or turn signal, a per-mesh IDs are used. By default, IDs are assigned to vertices, but this is not a comfortable way to deal with geometry. That is why the filter will deal with per-polygon IDs assigned and will transfer them to vertices on export, so the game shader code will read proper IDs from vertices when needed. Vertices IDs are also in use and, if assigned, they will suppress the ID specified on polygons.

I do not post a list of used IDs currently, as I work with buffalo2 model only. You are free to explore original vehicles and build a list of IDs for vehicle_lightsemissive, vehicle_dash_emissive and vehicle_dash_emissive_opauqe shaders.

Vehicle tires and rims

You are allowed to use only vehicle_tire shader adaptation/script for your vehicle wheels. This shader uses main texture, bump-map, specular map as a mask for specularity (red channel) and environment reflections level (green channel). So, it can produce you a wide range of surface feels from rubber to chromed metal. It supports painting, so you can specify [PAINT:1] or [PAINT:2] if you like. You can use several materials with different settings for your wheels, but they all have to be adapted to vehicle_tire.

GTA V: Textures.

Vehicle-specific textures should be stored in a textures package file associated with the model. For example, buffalo2.yft model uses textures from buffalo2.ytd textures pack, and buffalo2_hi.yft model will use both buffalo2.yft and buffalo2+hi.ytd if available. High detailed model will prefer textures from "+hi.ytd" pack if duplicates are met.

Additionally, you can force the exporter to store texture inside the exported yft model file by assigning a texture-container group in textures browser. When texture's group name matches the name of the exported file, such a texture is stored inside this model file. The screenshot below shows a texture "rgb32.bmp" assigned onto "buffalo2_hi.yft" texture container group:

16_embedded_texture_config.jpg


When exporting such a scene into buffalo2_hi.yft model, texture "rgb32" will be saved inside that model file. Thus, you can have a higher-resolution images stored inside high-detailed model file, so it will only be loaded when high-detailed model file is actually drawn. This is a part of memory optimization, as you don't need to store high resolution images in common model textures pack in such a case.

You can use wildcards ( * = match zero or more any characters, ? = match one any character) in texture group name to match different export file names. For example, using texture group "buffalo*.yft" will embed given textures while exporting buffalo.yft, buffalo2.yft, buffalo2_hi.yft and like this.
Attachments
vehshare_with_compiled_dirtburn_map.zip
vehshare.ytd with compiled dirt+burn texture included.
(2.9 MiB) Downloaded 5085 times
vehicle_genericmud_car.zip
Dirt+burn texture compilation (one DDS image only).
(896.82 KiB) Downloaded 3797 times
User avatar
Oleg
Site Admin
 
Posts: 7528
Joined: Fri Feb 06, 2004 3:54 am

Return to Grand Theft Auto V

Who is online

Users browsing this forum: No registered users and 1 guest