Jump to content

Shader for transparency


afi

Recommended Posts

Maybe just try using a .tga / .png file, I worked with them last time I edited a menu image. Don't think they need a shader file for transparency with menus.

Making things transparent in a .tga file will require you to create an "alpha mask". It's more simple to do than you would think.

 

Did a quick google search that sums up how to do it (If I can remember!)

http://www.axialis.c...al-misc001.html

Edited by Ruxith
Link to comment

If these aren't working you may need alpha channels. When I don't want to deal with alpha channels I just make a PNG with transparency lol. However.

 

insert/file/path/here
}
    {
         map insert/file/path/here
         blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
         rgbGen lightingDiffuse
    }
}

 

Specific example from the game

 

gfx/hud/hudleft
{
    nopicmip
    {
         map gfx/hud/hudleft
         blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
    }
}

 

The 'nopicmip' section isn't necessary. Per the shader manual it "causes the texture to ignore user-set values for the r_picmip cvar command. The image will always be high resolution." It might be something you want to leave in there, but if you leave it out no big deal. The in-game example lacks an rgbGen line because the engine will select the default "identity" (usually) if nothing is specified. My template has lightingDiffuse because I pulled it from a model. You can leave that out, or you can change it.

 

It's a big-ass read, but if you're ever interested in what any part of a shader means check the shader manual. I have found if absolutely invaluable over the years in understanding and dissecting shaders. You can usually take a shader you already have, look up each part in the manual (because it has a table of contents and is easy to search) and learn a thing or two to help you in the future.

 

If you need help making an alpha channel let us know and myself or someone else can probably walk you through it.

Link to comment

I generally converted my PNG's to TGA's

 

example of the shader I used, however if you open the TGA in photoshop, if there is black, it will show black, for my shader to work, the black must not be present and show a checkerboard pattern, this means the alpha is present in the actual texture. figured i'd share the Shader I used:

 

textures/cvrace/fence

{

Cull none

qer_editorimage textures/cvrace/fence.tga

{

map textures/cvrace/fence.tga

blendFunc blend

alphaFunc GT0

depthWrite

rgbGen identity

}

{

map $lightmap

rgbGen identity

blendFunc GL_DST_COLOR GL_ZERO

depthFunc equal

}

}

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...