Forums » Modern Era - Air Combat » F-22 Total Air War » SURFACE Textures Colors Shaders

Page 1 of 3 1 2 3 >
Topic Options
Rate This Topic
Hop to:
#2877944 - 10/11/09 02:40 PM SURFACE Textures Colors Shaders
DrKevDog Offline
SimHQ Member

Registered: 06/27/06
Posts: 596
I have been working on multiple TAW upgrade projects, however, there are two which are considered major projects. I will discuss one of them, the Surface Texture Solution Project, here.

This project started out as a simple desire to solve one of the problems of TAW, visual target acquisition and to upgrade the graphics, at least temporarily until we can get some more permanent model upgrades.
In an effort to define the problem some of you were having with the difficult target acquisitions issue, I identified one major obstacle to obtaining improved targets was the muted default textures which are often difficult to see, especially against the background of the bright new terrain colors in 2.0.

In order to accommodate for that problem I attempted to modify the code in the .3D object files but was frustrated by the inflexibility of the coding. Therefore I discovered a method to exploit the channels used for texture mapping.

In general, the .3 file determines the texture or the color of the specific object as Mikew previously explained:

Originally Posted By: mikew

Finally, we have lines 0019 to 0033 which describe the polygons.
Lines 0019 & 0020 should be treated as a pair:
0047001D00030000008900B70089000E007B
002F0003000500020006

This can be broken down as follows:
0047 This is the opcode for a textured polygon
001D Index number of texture from the file 'redXXXX.ini' in the 3 folder (cam3_7)
0003 Three sided figure, ie triangle
0000 0089 Texture coordinate of vertex 5 (taken from 002F line)
00B7 0089 Texture coordinate of vertex 2
000E 007B Texture coordinate of vertex 6

The texture coordinates are referenced to the top left corner of the texture, with an X coordinate between 0-255dec, and a Y coordinate in the range 0-191dec.

Lines 0021 to 0026 describe 3 more textured polygons.

Then comes 3 shaded polygons in lines 0027 to 0032. The following must be trated as a pair:
004CBABAC000
0080000500060004

The '004C' opcode is for shaded triangle, and taken together with the following '0080' line, can be interpreted thus:

Vertex 0005 uses palette colour BA
Vertex 0006 uses palette colour BA
Vertex 0004 uses palette colour C0

In this case,vertices 0005 and 0006 will be the same colour and there should be a smooth gradient across the triangle to the colour at vertex 0004.

The following lines can be treated similarly, noting that the 004E/0081 opcode combination relates to 4 sided polygons.



In TAW Texture mapping of building textures is switched on or off in Game.cfg using the key “BUILD_TEXTURE =1” or 0. If the textures are off (0), then the indexed texture is not used, in this case, the program uses the color determinants for the vertex indices which are given after the palette index in that string. If the texture is off in options the executable will only use the colors coded. Until now, these were the only options a player was priviledged to use. Now that has changed and a great many new options are going to be made available as I have determined that, if the Textures are ON the executable calls the time appropriate Redxxxx,ini file [surface] section which is where I found a way to intercept and manipulate the process for graphically improved targets. The [surface] section will accommodate, and defaults to, texture mapping. It will now also however accommodate a total of four types of surface treatments:

1.) Textures: txtr
2.) Colors: colr
3.) Flat Shading: flat
4.) Gourard Shading: gour

I have developed a number of full Templates to facilitate the efficient import of texture shader transitions into the redxxxx.ini files. Below I have given the first few lines of several of my basic Templates.

Examples:
TAW DEFAULT TEMPLATE
[surface]
0=txtr 4,(0,0),(31,0),(31,31),(0,31);N CONCRETE
1=txtr 4,(32,0),(63,0),(63,31),(32,31) ;NE CONCRETE
2=txtr 4,(64,0),(95,0),(95,31),(64,31) ;E CONCRETE

GOURAUD SHADER TEMPLATE
[surface]
0=gour ;N CONCRETE
1=gour ;NE CONCRETE
2=gour ;E CONCRETE

COLOR TEMPLATE
[surface]
0=colr ;N CONCRETE
1=colr ;NE CONCRETE
2=colr ;E CONCRETE

FLAT SHADER TEMPLATE
[surface]
0=flat ;N CONCRETE
1=flat ;NE CONCRETE
2=flat;E CONCRETE



The colors and shades of the individual polygon (tris and quads) vertices can be individually and specifically implemented and controlled by describing the desired index value.

Example:

[surface]
0=flat 6,7,8,9 ;N CONCRETE

ie. Flat shading of polygons progressing from the palettes Dark red (index=6) to Bright light red (index=9).

Assigning vertex shading values can control the Lighting conditions within the graphics environment using the directional assignment keys (;N, NE:, etc). This is a marvelous way to simulate time of day conditions, sun, moon effects. (It must be kept in mind, however that 3D object rotational variations must be considered for proper lighting effects outcomes). Flat shading, while one of the earlier shading techniques, works well and can be advantageous for TAW because of its significant improvement when used in the modeling of boxy objects.

Example:

[surface]
0=flat 0,0,0,6 ;N CONCRETE
1=flat 0,0,0,6 ;NE CONCRETE
2=flat 0,0,0,7 ;E CONCRETE
3=flat 0,0,0,7 ;SE CONCRETE
4=flat 0,0,0,8 ;S CONCRETE
5=flat 0,0,0,8 ;SW CONCRETE
6=flat 0,0,0,9 ;W CONCRETE
7=flat 0,0,0,9 ;NW CONCRETE
8=flat 0,0,0,0 ;BOT CONCRETE
9=flat 0,0,0,0 ;TOP CONCRETE

The Gouraud Shader is the smoothest and most advanced of the shaders in this application. The volatility of the color transitions was initially difficult for me to control. Mostly as a result of the shaders color interpolations of the 3D models specular highlights. Because TAW surface objects have large polygons with low counts, Gouraud interpolates the specular highlights at the vertices and then produces the progression of the highlight across neighboring polygons with a “fade-in”, “fade-out” pattern that, with any rotation of the object or the viewers perspective, gives off an intense color barrage. I have been able to better control that volatile interpolation pattern but still working on a best solution.


Digital Image Design continues to impress (especially that Steve Hunt guy), with each discovery, the talent, skill and dedication they placed in this simulation. For reasons of their choosing, DID determined to use textures exclusively for their surface object solution. It was, apparently, the simplest practical solution to implement in 1997, given the state of PC power and graphics at the time.
It is important to note that truly good power resides within the TAW palette, as the colors have true functional affective capacity and can dictate events in the game experience. A part of the ongoing challenge is to discover the functional impact of all given colors, textures and shaders.

It would seem logical that a significant enhancement to TAW can now be had by implementing a hybrid solution upgrade. That is, using a combination of textures, colors and shaders.

I now submit to you the Power of the Palette…(textures colors and shaders included)

Any Questions?
WinkNGrin

Top Bookmark and Share
#2878108 - 10/11/09 09:20 PM Re: SURFACE Textures Colors Shaders [Re: DrKevDog]
HomeFries Online   cool
F22 Air Dominance Project
SimHQ Member

Registered: 01/01/01
Posts: 715
Loc: Greater Washington DC Area
Great stuff, DKD.

I noticed that the Gouraud shader uses the palette ever since I tweaked with the 4th row of the palettes for 2.0 and noticed that some of the ground targets looked kind of funny. I since move the colors that are not part of the original gradient to the top end of the row to minimize the effect on the graphical anomaly, but I was wondering if it was possible to limit the number of palette slots used in the gradient (i.e. using slots 48-56 instead of slots 48-63).
_________________________
-Home Fries

The average Naval Aviator, despite the sometimes swaggering exterior, is very much capable of such feelings as love, affection, intimacy, and caring.
These feelings just don't involve anyone else.

F-22 Air Dominance Project

Top Bookmark and Share
#2878722 - 10/12/09 07:52 PM Re: SURFACE Textures Colors Shaders [Re: HomeFries]
DrKevDog Offline
SimHQ Member

Registered: 06/27/06
Posts: 596
Originally Posted By: HomeFries


I noticed that the Gouraud shader uses the palette ever since I tweaked with the 4th row of the palettes for 2.0 and noticed that some of the ground targets looked kind of funny. I since move the colors that are not part of the original gradient to the top end of the row to minimize the effect on the graphical anomaly, but I was wondering if it was possible to limit the number of palette slots used in the gradient (i.e. using slots 48-56 instead of slots 48-63).


Can certainly work on a method to reduce the gradient slots. The colors you wish to eliminate are primarily for terrain textures so I'm a bit unsure of what you are refering to as "ground targets". Are you refering to ground mobiles or static targets? Are you saying that the code for those objects automatically applies the shader to the polygon colors? Do you recall which objects were effected?

Top Bookmark and Share
#2878797 - 10/12/09 11:49 PM Re: SURFACE Textures Colors Shaders [Re: DrKevDog]
HomeFries Online   cool
F22 Air Dominance Project
SimHQ Member

Registered: 01/01/01
Posts: 715
Loc: Greater Washington DC Area
for ground targets, I'm referring to mobile targets such as the M1, the T80, the trucks, as well as some of the aircraft (cargo birds come to mind).

Just go to the custom mission menu and tab through the ground and air targets to see what I mean. When they use a desert pattern, they use the full row 4 for the gradient.
_________________________
-Home Fries

The average Naval Aviator, despite the sometimes swaggering exterior, is very much capable of such feelings as love, affection, intimacy, and caring.
These feelings just don't involve anyone else.

F-22 Air Dominance Project

Top Bookmark and Share
#2880923 - 10/16/09 08:04 AM Re: SURFACE Textures Colors Shaders [Re: HomeFries]
mikew Offline
SimHQ Member

Registered: 02/26/01
Posts: 1703
Loc: UK
Very impressive DKD, any chance of some screen shots showing this in action?

Originally Posted By: HomeFries
Great stuff, DKD.
....I was wondering if it was possible to limit the number of palette slots used in the gradient (i.e. using slots 48-56 instead of slots 48-63).
Yes, just replace the 63 with 56 in the appropriate lines.

In this example of the shaded triangle:
004CBABAC000
0080000500060004 two of the vertices have a colour of BA(186) and the other C0(192).

This can be visualised by stretching the palette into two dimensions and plotting the palette positions of the colours:

Top Bookmark and Share
#2880932 - 10/16/09 08:13 AM Re: SURFACE Textures Colors Shaders [Re: mikew]
HomeFries Online   cool
F22 Air Dominance Project
SimHQ Member

Registered: 01/01/01
Posts: 715
Loc: Greater Washington DC Area
Nice. Might give this a look for 2.03 or later.
_________________________
-Home Fries

The average Naval Aviator, despite the sometimes swaggering exterior, is very much capable of such feelings as love, affection, intimacy, and caring.
These feelings just don't involve anyone else.

F-22 Air Dominance Project

Top Bookmark and Share
#2881676 - 10/17/09 12:53 PM Re: SURFACE Textures Colors Shaders [Re: mikew]
DrKevDog Offline
SimHQ Member

Registered: 06/27/06
Posts: 596
Originally Posted By: mikew
...any chance of some screen shots showing this in action?



These are early trials and are designed to find a scheme that is complimentary to the 2.0 terrain. This set includes a combination of Gouraud shading and Flat shading mixed with conventional TAW Textures and weighted toward Gauraud. The addition of the Gauraud component is not well appreciated by the viewer outside of the game environment.



















Edited by DrKevDog (10/19/09 07:34 PM)

Top Bookmark and Share
#2881790 - 10/17/09 06:11 PM Re: SURFACE Textures Colors Shaders [Re: DrKevDog]
HomeFries Online   cool
F22 Air Dominance Project
SimHQ Member

Registered: 01/01/01
Posts: 715
Loc: Greater Washington DC Area
Wow, DKD. Great find, and these enhancements can certainly spruce up the look in TAW 2.0.

If you're interested in conforming to the 2.0 look, you can probably just as easily make them work for legacy TAW. Using the 1200 palette a base, I made major changes to the sky colors (row 9, 2nd half of row 2), water colors( row 8), and the upper half of the sand colors in row 4. Sure, I made differences in the palettes based off the 1200 palette, but the colors were adjusted in something of a linear fashion.

In other words, what you make work for 2.0 is likely to work for 1.0 as well.

Realizing that you are using the greens and blacks to illustrate your changes (rather than use them as final colors), I have some recommendations for color selection:

For Concrete/Buildings, use row 13 (colors 192-207). Row 12 can be used if necessary, since these colors are often directly related to buildings.

For ocean colors (row 8), limit yourself to colors 118-124.

For Tans, limit yourself to row 3 and row 4 only up to color 56. If you wish to use the tans in rows 12/13, have at it!

For Greens, have at it. No restrictions.


One thing also to note: with Glide there are two palettes (east/west) for sunrise and sunset timeframes (0600, 0800, 1800, 2000). In these timeframes the terrain colors or water have not changed. However, the sky colors and the colors in rows 12/13 differ between palettes in order to show sun glare. These colors are brighter on the darker sky palette, showing the sun shining on the direction you are looking if you look away from the sun.

For example, at 1800 you will see a bright orange as you look west, where the sun is setting. In this direction, the buildings will appear "normal" because you are looking at the shadow side of them. If you look east at 1800, you will see a darker sky, but the buildings will have an orange hue because you're looking at the side of the building receiving the setting sun.

I mention this because you will want to test your settings in glide and make sure the buildings look OK from both directions.
_________________________
-Home Fries

The average Naval Aviator, despite the sometimes swaggering exterior, is very much capable of such feelings as love, affection, intimacy, and caring.
These feelings just don't involve anyone else.

F-22 Air Dominance Project

Top Bookmark and Share
#2882192 - 10/18/09 02:33 PM Re: SURFACE Textures Colors Shaders [Re: mikew]
DrKevDog Offline
SimHQ Member

Registered: 06/27/06
Posts: 596
The behavior of the "colr" type seems similar if not identical to the "gour" type. That seems redundant and illogical. The switch statements for the different surface types are: txtr, colr, gour and fade. The code uses a jump table to direct the 4 switch statements:

align 10h
; jump table for switch statement


AUTO:00574F60 off_574F60......dd offset loc_575002
AUTO:00574F60......................dd offset loc_5750A3
AUTO:00574F60......................dd offset loc_5750A3
AUTO:00574F60......................dd offset loc_5750E8
AUTO:00574F70


If I am interpreting this correctly, It appears that 2 of the types jump to the same subroutine. Even so there could be some distinguishing differences.

Could someone take a look at the code in the executable and see what you come up with?

Thanks smile

Top Bookmark and Share
#2882628 - 10/19/09 10:10 AM Re: SURFACE Textures Colors Shaders [Re: HomeFries]
DrKevDog Offline
SimHQ Member

Registered: 06/27/06
Posts: 596
Okay, so lets GO ARMY!

(Army green that is)















The shading for light affects is correct but better appreciated in game. These are Gouraud shaded with paletted textures. Kept it very basic, as you requested yep

Feedback?



Top Bookmark and Share
Page 1 of 3 1 2 3 >



Forum Use Agreement | Privacy Statement | SimHQ Staff
Copyright 2009, SimHQ Inc. All Rights Reserved.