afi Posted September 6, 2012 Share Posted September 6, 2012 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? Link to comment
Azatha Posted September 6, 2012 Share Posted September 6, 2012 models/players/folder/file{ cull disable { map models/players/folder/file alphaFunc GE192 depthWrite rgbGen lightingDiffuse }} Link to comment
afi Posted September 6, 2012 Author Share Posted September 6, 2012 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 Link to comment
Azatha Posted September 6, 2012 Share Posted September 6, 2012 Ahh.. for a menu, I have no clue. Sorry! Link to comment
Ruxith Posted September 6, 2012 Share Posted September 6, 2012 (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 September 6, 2012 by Ruxith Link to comment
afi Posted September 6, 2012 Author Share Posted September 6, 2012 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. Link to comment
Inyri Posted September 7, 2012 Share Posted September 7, 2012 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
eezstreet Posted September 7, 2012 Share Posted September 7, 2012 Shaders with nopicmip set will also suffer greatly reduced aliasing when scaled down or proportions are changed. Handy. Link to comment
Inyri Posted September 7, 2012 Share Posted September 7, 2012 Yeah it's useful for things like HUD's where it's very consistent. Probably impractical on things like player models or weapons. eezstreet likes this Link to comment
afi Posted September 7, 2012 Author Share Posted September 7, 2012 Ok pngs worked this time... Somehow it screwed up ingame the last time I tried. Link to comment
CaptainChar Posted September 14, 2012 Share Posted September 14, 2012 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now