   alpha in a simple triangle
  While I know how to make a simple triangle and change the color of each vertex, how do I change the opacity of each vertex and make it actually work?  Is it even possible to have something like a fully opaque red vertex, a semi-transparent green vertex, and a fully transparent blue vertex?  I've messed around with a few things in D3D and OpenGL but I can't get it right, and it doesn't look like there are that many tutorials on the subject.  Also, I don't (think I) want to use blending to blend several triangles to get this effect.   
  Are you using the fixed function pipeline? I'm not sure if you can with the fixed function pipeline though to be honest I haven't worked with it in forever...You could easily achieve this with shaders, though. You can just pass a float for opacity or a float4 for an RGBA color.But in reality this has limited practicality, you might be better off with just implementing alpha maps.   ;  Of course you can. The trick is to get the states set up right.You can use the alpha bits of the vertex diffuse color for transparency. Then you enable alpha blending and set the stages for color and alpha to modulating both texture (arg1) and diffuse (arg2). You also should disable lighting for starts.   ;  Thanks for the responses.  I've gotten transparency to work somewhat through alpha blending in D3D using the SRCBLEND and DESTBLEND flags, though it feels like instead of transparency at one point, the triangle just dilutes the color at that point yet anything behind it can't be seen clearly (such as another triangle).  Maybe the default shading has something to do with it?Weirdly enough, I had been using the glBlendFunc function in OpenGL for a while and never really noticed that it does what I was looking for in the original post; instead it felt more like it was the only way to get colorkeying to work on any texture being used (as seen in the NeHe tutorials).   ;Quote:Original post by obi-wan shinobiThanks for the responses.  I've gotten transparency to work somewhat through alpha blending in D3D using the SRCBLEND and DESTBLEND flags, though it feels like instead of transparency at one point, the triangle just dilutes the color at that point yet anything behind it can't be seen clearly (such as another triangle).  Maybe the default shading has something to do with it?Could you show a screenshot of what it looks like, and draw a picture of what you expect it to look like?   ;  Its easy but you need some texturing tricks. The problem here is the pixel shading pipeline not the vertex pipeline. So if you still dont know how to do texture alpha blend then find a good tutorial about that.First, build your vertices as usual, transformed or not. The trick is having a uv coordinate on each vertex.Build a texture with the alpha information. A 1x256 texture is okay. Paint the texture red and the alpha in a degrade from black to white. Save it as your preferred format (if DX then pick a DXT format with alpha). You should have a red texture which vanishes.Assign the uv coords of your triangle to a point within the texture. If using a fixed pipeline, setup the cascade so that in the first stage you pick the texture color likeIn the first texturing stage (0)setup your texture 0 to the one above (load it first of course)setup color arg0 to diffuse (the vertex color)setup color arg1 to texture (the texture diffuse color)setup color operation to modulate (the vertex color by the diffuse color)setup alpha arg0 to diffusesetup alpha arg1 to texturesetup alpha operation to selectarg1 (select the alpha from the texture)In the second texturing stage (1)setup color operation to null (meaning that it ends here)Enable the alpha blendSetup your alpha blend to src alpha, 1 minus src alphaEnable the ztestsDisable the zwritesRender your trianglesThis means the triangles will be transformed (if they are untransformed) and lit (if they are unlit) and then passsed to the pixel pipeline. In the pixel pipe the triangle gets rasterized and each pixel takes the color of the vertex modulated by the texture color, and the alpha is the color of the texture alpha. As the texture is transparent the triangle will get transparent.Dont forget to render opaque triangles first and transparent triangles second or you will get rendering artifacts. Also, enable the alpha blending functions, test z to avoid over rendering and disable the zwrited so that translucent tris wint fill the zbuffer.Luck!Guimo