.qc (dot qc) - the group for quake c coders of all denominations. If you make quake one mods and write code in quake c, join our group! I'll try to answer any quake c questions - please post your inquiry in the forums...

Forum Thread
by member
  Posts  
Darkplaces Alpha Texture (Groups : qc : Forum : discuss() : Darkplaces Alpha Texture) Locked
Thread Options
Oct 12 2012, 2:17am Anchor

This is a tutorial candidate.

Question:

How can I do alpha texture in darkplaces ?
(I gather this means alpha blend texture.  Something to this effect: Moddb.com
Where you can see through wall or model textures.)

Answer:

There are 2 methods to do this.

A. As an override texture.  Darkplaces allows .tga and .jpg to be used to override in game textures.  This has a big advantage of allowing a full 32 bit palette, where the in game miptex are limited to 8 bits (a 256 color palette.)

This is a complex process that takes advantage of transparency (alpha channel) in .tga files and darkplaces ability to use tga for overriding in game miptex.

1. Use gimp or an other editor to make the texture.  The texture must have an alpha channel and some measure of transparency.
   (In other words if the texture cannot be seen through in the editor, it will not be transparent in the game.)
2. Save the texture as a .tga file.  This file must have a resolution base (i.e. 256 x 256 pixels) that allows easy import as a miptex.
3. Save a smaller version as a .tga file.  Make it 64 x 64 pixels for the miptex.
4. Use wally or other wad editor to import the texture and save it as a mip in the wad. The mip must be named the same as the texture - "NEWTEX" for "newtex.tga".
5. Put the larger .tga in "quake/id1/textures" - this is where darkplaces looks for override textures.  If you do not override you will NOT have the transparent effect!
6. Make a map that has wall brush textured with NEWTEX.  If you use radiant, "newtex.tga" will have to be placed in the folder where radiant stores map editing textures.  This will vary for other map editors - consult your editor documentation.  Some editors may use the wad file.
7. Compile the map and load it up with darkplaces.

You can do the same thing with model skins.  Darkplaces looks for model skin overrides in "quake/id1/progs" with the following convention: for player.mdl, the skin0 override would be "player.mdl_0.tga", for skin1 - "player.mdl_1.tga" and so on.  Those tga can be made exactly the same way with transparency.  You can have all or part of a model skin be transparent.  NOTE: Making models transparent is tricky because of internal triangles - if the model isnt made just right, you might see things that dont normally show up.

Potential problems:

Darkplaces is not seeing the override texture.  Make sure "quake/id1/textures" (or "quake/id1/progs" for model skins) is setup right and override textures stored there work.

The map compiler (qbsp or hmap2) did not find NEWTEX in the wad file - this will register as a warning:
loaded wad "maptex.wad" (580 miptex found)
miptex used: newtex (NOT FOUND)
Make sure the map has "wad" "maptex.wad" in the worldspawn entity.  ("maptex.wad" contains your custom textures or all map textures.  Some compilers allow "wad" "maptex.wad; quake101.wad" wad strings.)
If the override exists and the mip was not found you will see the correct texture, but with a scale issue.

The override texture is not _really_ transparent.  Make sure it has an alpha channel.  Make sure it was saved with some transparent pixel values that can actually be seen through.  Make sure the texture is saved as a tga and NOT a jpg.  Both are supported by darkplaces but jpg does not handle transparency.

This method should work on any darkplaces derived engine.  Other engines that use .tga overrides may or may not work correctly.

B. As a code controlled model property.  This will not work on map walls and possibly things like func_door and func_wall.

You can also make any entity that displays a model transparent with this quake-c code:

.float alpha; // defined anywhere, like at the end of "defs.qc".

for some entity like the player:

self.alpha = 0.5; // level of transparency

This makes the _entire_ entity transparent at 50%.  You can not pick and choose parts of a model like you can with the skin override.
This has the advantage that it can be turned on and off.  And be used for really cool fade out effects.

Potential problems:

The model has no transparency.  Make sure you set the correct entities ".alpha".
If you know the entity number you can enter this at the console: prvm_edict server 1
This will show all non default values for entity 1 - the main player in SP or lan server DM.
In this example you might see:

server EDICT 1:
modelindex       168.0000
alpha       0.5000

If alpha is >= 1 or 0 you will not have a transparent model.

This provides 2 methods for in game texture transparency.

Reply to Thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.