Quantcast

Jump to content

» «
Photo

Alphas, Opacity, Reflections and Prelighting

8 replies to this topic
jcab42
  • jcab42

    Custom Planet Builder

  • Members
  • Joined: 21 Sep 2002

#1

Posted 12 July 2004 - 02:19 AM Edited by jcab42, 03 December 2010 - 03:03 PM.

Overview:

GTA3 and VC have some great surface effects for making your models more realistic. Alpha channels are used to create graphics like shadows and explosions with transparent backgrounds. Illumination (pre-lighting, glowing) and reflections can be mixed in infinite ways to create the perfect level of colorful reflected light. At least one effect is not available to us lowly modders: the vertex lighting that Rockstar used to create the illusion of scattered light on an object is not available using either Zmod or 3ds Max. Apparently Rockstar has a better DFF filter for 3ds Max then we do.

Pre-lighting is not to be confused with the ingame "light bulbs" that you can create using the 2dfx entries in the IDE file. This tutorial will not cover 2dfx lights as there is already one written at this address:
http://www.gtaforums...howtopic=137858

This collection of tutorials is a Work In Progress so feedback is welcome and updates are imminent.

Important Definitions
  • alpha channel - an 8 bit grayscale texture that works in conjunction with the main texture called by the DFF. Alphas are used to create complicated patterns with various levels or transparency within one simple DFF. The sections of the texture that correspond to the black in the alpha image will be transparent and the sections that correspond to white will be opaque. The different shades of gray give you different levels of partial transparency.
  • opacity - Zmod and 3ds Max allow you to give the whole DFF a certain amount of transparency.
  • pre-lighting - when a model glows (light comes from the object). It's caused by vertex color pre-lighting (VCPL) in both games. Reflections have pre-lighting that is not caused by VCPL in VC. Reflections in GTA3 have no pre-lighting.
  • vertex color pre-lighting - for the sake of this tutorial, I will refer to this as VCPL. This is the process of placing a light in the scene of your modeling program (3ds Max) and then applying it to the models as VCPL thus giving every vertex a color and light intesity value.
  • reflections - caused by the addition of a second texture that serves as the mirror image in the reflection. It uses the same mapping as the main texture and is added as the "reflection texture" in the modeling program.
.
.
Lesson 1: Create a Pac-man Ghost Using the Alpha Channel

Alphas can be used to give a simple four vertex DFF different levels of transparency. In this example, a Pac-man ghost will be made using the alpha channel.

required programs:
IMG Tool - http://www.codenameg..._file.asp?Id=46
TXD Builder - http://www.steve-m.c...t=details&ID=19
TXD Tool 1.1 - list missing
Zmodeler - http://www.zmodeler2.com/ (use version 1.7)
or
3ds Max r3 with DFF exporter - http://www.codenameg...file.asp?Id=247
An image editing program like Photoshop or PSP - http://www.jasc.com (free trial)

Important: this tutorial starts with the creation of a main texture and an alpha texture. The number of colors in the palette of the alpha PLUS the number of colors in the main texture's palette needs to be less than 256, otherwise the TXD program will not import the textures properly. For more information about color palettes, see appendix A at the bottom of this post.

1. We'll start by creating the alpha texture. Open your image editor, click new, and create an 8-bit 128x128 pixel canvas in grayscale mode. You may want a different resolution, but remember that using powers of 2 will keep you compatible with Moomapper.

2. Remember that black alpha = 100% transparency. Since we want the ghost to have a see through background, the background of the alpha should be black. If your canvas is white then click "negative image" to turn it black.

3. Draw a white ghost with a gray border to make his body opaque with a partially transparent outline. If you want to get a bit fancy like I did then make a white ghost (see 1st pic) and blur it (mine is a Photoshop gaussian blur with a radius of five pixels). Name the image GOSTA.BMP. I called it "gost" because "ghost" is already used in GTA3 and I added an "a" to remind me that it is an alpha texture. ALPHA DONE (2nd pic).

user posted image user posted image
note: these are not the actual bitmaps. This board doesn't allow .bmp files.

4. Now to move on to the main texture. Since the alpha is doing most of the work, all we need in the main is eyes and color. Click new and create an 8-bit 128x128 pixel canvas in color mode.

5. Copy the alpha to the new canvas. Draw a couple of eyes with the marquee tool and make sure the eyes are white.

user posted image

6. Invert the selection to paint over everything but the eyes with the color you want the ghost to be (I chose red).

7. Deselect all and paint a couple of black pupils in the eyes. Name the image GOST.BMP.

user posted image

8. Apply the texture to a mesh: open your modeling program and create a mesh from four vertices (2 faces). Import the GOST.BMP into a material and apply it to the mesh and UVW map it. The mesh should now look just like the main texture. Export the object as GOST.DFF. Notice there is no need to apply the alpha to the model. That work is done by the TXD file.

For a more detailed explanation of model texturing, check appendix B at the bottom of this post for 3ds Max or the following link for Zmod:
http://www.gtaforums...howtopic=138060

9. Now it's time to import the textures into the TXD. The only TXD program that I've had alpha success with is TXD Tool 1.1. Unfortunately that program won't create TXD's from scratch, which is why I recommend creating the TXD with TXD builder and then updating the alpha with TXD Tool:
a. Open TXD Builder, Click "Add", open the GOST.BMP file (the main texture). Click "change". Check the "has alpha" checkbox. Click "no alpha selected" and open the GOSTA.BMP file (the alpha texture). Click "apply". Click "build TXD". Name the file GOST.TXD. Close TXD Builder. If TXD Builder works properly then skip to step #10 (it won't).
b. Open TXD Tool and open the GOST.TXD. You should see the eyes with red background. Click commands -> import -> alpha and select the GOSTA.BMP. If you want to view the alpha, click commands -> draw -> alpha. Close the TXD Tool.

10. Get your new models and textures into the game:
a. create GOST.IDE, GOST.COL, and GOST.IPL files
b. make references to them in the GTA3.DAT file (GTA_VC.DAT for VC)
c. import the TXD and DFF into the gta3.img file using the IMG Tool.

Important: whenever you make a DFF with transparency, the last entry in the IDE file needs be a "4". Otherwise you won't see all the models behind the ghost properly. My IDE file looks like this when you open it with notepad:

CODE
objs
5000, gost, gost, 1, 300, 4
end


BTW, the first "gost" is the DFF name and the second "gost" is the TXD name. For more info on how to get scratch models and textures into the game, check this address:
http://www.gtaforums...howtopic=137836

user posted image




Troubleshooting:

problem: your ghost doesn't look like mine. It may look like a black ghost with a pixilated red transparent outline, or it might look like a red spotted square with eyes.

answer: you need to use TXD Tool to reimport the textures.


problem: TXD Tool is giving an error when importing the textures.

answer: there are more than 256 when adding the number of colors in the palettes of the main and alpha texture. See appendix A to find out how to solve this problem.


problem: the alpha doesn't seem to be working at all

answer: it could be that the alpha is not enabled in the TXD. Both TXD Gold and TXD Workshop give you a checkbox to turn the alpha on or off for each texture. In TXD Workshop, highlight the texture, click properties, and then you can rename both textures and turn the alpha on or off. Remember, if the alpha is off then it will still be in the TXD and TXD Tool will allow you to update it, but it won't work ingame.


=================================================


Lesson 2: Make the Ghost Transparent with Zmod's Opacity Slider:

of course we could have made it more transparent by starting with a gray ghost instead of a white one back in the last lesson, but this way we can explore what happens when we use both alpha and opacity (see #5). If you'd rather use 3ds Max then skip to appendix A, #4.

required programs:
Zmodeler - http://www.zmodeler2.com/ (use version 1.7)
TXD Workshop - http://www.infofeast...tm##txdworkshop

1. Start by importing the DFF we made in the last lesson into Zmodeler. Zmod only retains the texturing if the DFF is accompanied by a TGA file. Take this opportunity to make a proper TGA complete with alpha by using TXD Workshop to export a TGA from the TXD you made in the last lesson. Place the GOST.TGA in the same folder as the GOST.DFF and import the GOST.DFF into Zmod.

2. Open the material editor by pressing "E".
At the top of the editor, pull down the menu and select the GOST.TGA texture.

user posted image

3. Under the material view change the "Type" pull down menu to "glowing" and click "apply changes". The alpha should now be enabled.

4. Adjust the "opacity" slider and click "apply changes". Notice that the whole ghost is affected. Keep experimenting with the slider to find the right level of transparency.

5. IMPORTANT: if you want to use Zmodís glowing effect with alpha AND half-opacity, you must set the "use alpha" pull down menu to "semi-transparent glowing for depth test" and apply the GHOST.TGA texture as a "light map" (see picture). This will be covered more in the next lesson. Finally, press "ok" at the bottom of the material editor.

6. export as GOST.DFF and replace the old DFF in the gta3.img file to see how it looks in the game.

user posted image

=================================================


Appendix A: How to keep the number of colors under control.

Remember, the main texture and the alpha texture are treated as one 8-bit texture. 8-bit textures have up to 256 colors in their palette, so the number of grays in the palette of the alpha plus the number of colors in the palette of the main texture needs to be less than 256. Paint Shop Pro (PSP) makes it very easy to control numbers of colors in the palette.

Open PSP, open the main texture. Click image -> count image colors. In my case there are 96 colors in my "eyes with red background" texture (the main). Since 256 - 96 = 160, there needs to be less than 160 colors in my alpha texture. Take note of how many colors are in the current alpha. There are many ways to reduce the number of colors, but my favorite method is to click adjust -> brightness/contrast -> brightness/contrast (increase contrast for more black and white, increase brightness for more gray). Play with those two numbers a bit and then check the number of colors again. Repeat this until the number is 160 or less.

* the brightness/contrast trick only works on black and white images. This next method is easier and works for both b/w and color. Simply open the image in PSP and click image->decrease color depth->X Colors. Then you can choose the exact number of colors.



Appendix B: How to apply a texture in 3ds Max:

1. (This is how I made my ghost) first, draw a square shape.
2. Right click on it and select "convert to editable mesh".
3. Press "M" to bring up the material editor. The top left material should be selected.
4. Click the map browser button (see pic) next to diffuse, double-click bitmap, and open the texture. Notice the opacity level just to the right.
5. Click the "assign material to selection" and the "show map in viewport" buttons, close the material editor.
user posted image
6. Click the "modify" tab. Click "UVW map"
7. If you don't see your texture correctly, then scroll down through the UVW parameters until you see "alignment". Try all three possibilities (x, y, z). More adjustments could be made with the mapping parameters and the coordinates in the material editor.
8. Click file export and switch to the DFF extension. If it's not available then you need to copy the DFF filter (rw30exp.dle) into the plugins folder of 3ds Max.


Stay tuned for the next two lessons:

"Give the Ghost some Firey Reflections"
and
"Possibilities With Pre-Lighting"

and more pics and tables. We all love pics and tables biggrin.gif

cookie.gif and check out Ashdexx's reflections tutorial a few posts down cookie.gif

bjiz
  • bjiz

    Poly pleasure

  • Members
  • Joined: 16 Feb 2004

#2

Posted 12 July 2004 - 01:01 PM Edited by bjiz, 12 July 2004 - 01:05 PM.

now that is what I needed, soon as i get home from work i'll try something !!!!

GT-1
  • GT-1

  • Feroci Racing
  • Joined: 21 Nov 2003

#3

Posted 28 July 2004 - 07:09 PM

Nice one Jcab ill be looking out for the pre-lighting one because thats something which could be useful for me to learn. smile.gif Its a small bump, but the title does say WIP.

beire21
  • beire21

    maya

  • Members
  • Joined: 31 May 2004

#4

Posted 31 July 2004 - 01:31 AM

same here, still waiting for the pre-lightning in zmod tutorial
nice job on the first part tho

jcab42
  • jcab42

    Custom Planet Builder

  • Members
  • Joined: 21 Sep 2002

#5

Posted 07 August 2004 - 09:24 PM

thanks guys for the feedback.

bjiz, did you ever try something? Wondering if this actually worked for anyone.

GT-1, I'm glad I waited for that update because I'm still learning (thanx Steve). I went ahead and crossed something out up there becuase now I'm thinking that it wasn't true. Update coming soon.

beire21, I didn't forget about you buddy, I got some kinks to work out in the zmod issue too.

DexX
  • DexX

    Black Hat

  • Feroci Racing
  • Joined: 16 May 2002

#6

Posted 08 August 2004 - 02:16 AM

QUOTE
reflections - caused by the addition of a second texture that serves as the mirror image that appears as the reflection mixed in with some VC style warping effects. It uses the same mapping as the main texture and is added as the "reflection texture" in the modeling program. This effect does not work properly in GTA3.

What exactly do you mean by this? The only "defect" i know of in gta3 reflections, is that the reflected image, say on a car, won't rotate with the player / camera, as it does in vice. In gta3 you have to drive the car to see the reflection move, in vice you can just walk around the vehicle to see it work.

Is that what you meant, or is there something else im not aware of?

jcab42
  • jcab42

    Custom Planet Builder

  • Members
  • Joined: 21 Sep 2002

#7

Posted 08 August 2004 - 11:41 AM Edited by jcab42, 10 August 2004 - 06:38 AM.

I'm glad you asked that. This tut is mainly a mapping tut. Most of it translates to vehicles, but you found an example that doesn't. What I was talking about is strictly for mapped models. For example, if you apply reflections to a building, it will have all kinds of wonderful pre-lit reflections in VC, but in GTA3 it will only have white brightness that will flicker on and off depending what angle you are looking at it from, and it won't have any reflections nor does it have pre-light. It's more like mixing a white texture in with the one that's already there. Very crappy looking.

Bottom line: don't apply reflections to mapped models if they are to be used in GTA3.


Well leave it to me to be wronge. I've been learning alot in the past few days. For one thing the reflections work fine in GTA3. The only difference is that in VC the reflections are pre-lit, even if there is no vertex pre-lighting. In GTA3 the reflections don't cause pre-lighting.

And the other thing I'm learning is what the Myriad crew has been knowing about (I haven't been keeping up with them well): VERTEX COLOR PRE-LIGHTING IS AVAILABLE WITH THE MAX DFF PLUGIN. It seems that with the exception of the above VC/reflection scenerio, the only way to get pre-lighting is with vertex pre-lighting. When you turn pre-lighing on in Max, but not vertex-prelighting, it's actually still using vertex-prelighting. It simply turns on every vertex to full brightness.

Now I'm going to attempt a reworking of the Myriad related pre-lighting tutorials but in the meantime, here's the important links:

The Myriad Pre-Lighting Standard

Pre-lighting your lots with MAX 3

From what I can tell this is due to the work of sAdIsTiCmAcHiNe , _RicH_, and illspirit.

DexX
  • DexX

    Black Hat

  • Feroci Racing
  • Joined: 16 May 2002

#8

Posted 10 August 2004 - 08:23 AM

Mind if i append your tutorial a bit jcab? thanks.
the Max 3 dff exporter also supports bump mapping, though not in the way it should. Test it out if you want, but the game may run a bit worse. I don't recommend using it on alot of objects.

Reflections on gta3, Max 3:
there are 2 ways to get reflections to work in gta3, atleast for the vehicles, this wasn't tested on any static objects.
-To have the object use a specific reflection map that you assign, simply assign it as normal through the Reflection map entry in the material editor, and max will export it along with the diffuse texture on export.

OR...now not many people know this...

-Set the Specular level on the material (0-100). This will set, and affect the default, "reflection01" to your material ingame, and use it as the reflection map.
0 - no reflection. "disable blending" if imported in zmodeler.
50 - normal, most cars use a setting close to this, neither "disable blending" nor "high blending" will be enabled if imported into zmodeler.
100 - if imported into zmodeler, this will have "High blending" enabled for this material, and appear ultra shiny ingame.

You can set any number, 0-100 to get the desired reflection amount. If you use the Disable / High blending settings in zmodeler though, it will be either 0, 50, or 100, as you cannot specify the exact amount of blending for it to use.

Note: using reflection / bump maps exported from max 3, will work ingame, but you cannot edit those files with RWA (renderware analyze), as they will be corrupted upon resaving the file. Max 3 / Renderware 3.1, has a f*cked method of exporting bump / reflection maps, which has been corrected in later versions of renderware.

Reflections in Vice:
The "set specular level and have the game use the default reflection map" system, doesn't work on Vice (hence why you can't use high blending on vice cars). You MUST assign a reflection map to each material that you want reflections on.

Important note: reflections on cars in Vice, are capped to half reflectivity. There is apparently some sort of hardcoded limit on the reflections levels cars can use. If you want a good example, watch the opening cutscene again, on the cutscene Admiral, note how much shinier the chrome is on that car, than the normal admiral. Examining that model with RWA and one exported from zmodeler, shows that both materials, have the reflection level set to 100, wheras the cutscene model is significantly more pronounced. its not capped on non-vehicle objects. There is no solution for this.

QUOTE
And the other thing I'm learning is what the Myriad crew has been knowing about (I haven't been keeping up with them well): VERTEX COLOR PRE-LIGHTING IS AVAILABLE WITH THE MAX DFF PLUGIN.

Sure is. Ive known about this since sept 2003 tounge.gif
you can use your scene lights to vertex-prelight your models too, its quite nifty. give it a shot.

Good tutorial here, ive never tried the opacity maps..

bjiz
  • bjiz

    Poly pleasure

  • Members
  • Joined: 16 Feb 2004

#9

Posted 10 August 2004 - 12:39 PM

I tried it, but Zmod was being nasty to me... sad.gif

I'll try it some other time and If I get something to work i'll also post it in here ok?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users