Jump to content

Shader for transparency


afi

Recommended Posts

Posted

Hi, I need a shader to make something transparent in a tga file.

So, everyone that's (for example) black needs to be cut out. Somehow I fail at doing so.

Anyone can help?

Posted

Doesn't work :| Is this only working for models...? I'm seriously a noob when it comes to shaders.

I need that shader for a menu

Posted (edited)

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
Posted

Creating the transparency in Photoshop was the first thing I tried... I ended up with a white background.

Thanks for all the tips though, I'll try it all out tomorrow. :)

Posted

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.

Posted

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

}

}

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...