   Alpha, How to get rid on selfblend?
  Hello!I have opacity/alpha on an animated mesh. I use my own custom shader and the result i'm looking for is that the mesh will blend the alpha like normal with one expection, that it won't blend with itself. How can I fix this? Do I need to do something in my shader or is it possible to solve it with an command in the engine I use(Truevision3D)?heres an image.http://img688.imageshack.us/img688/8609/alphablend.jpg   
  The problem is that the triangles of the mesh are not sorted; thus, if (and only if) the pixels happen to be written in back-to-front order, the blending is correct. Also remember that the z-buffer values of the pixels are written regardless of whether or not the alpha channel effectively makes them transparent.To solve this problem, there are several workarounds (google for these):-back-to-front sorting of triangles (easy, but not very efficient)-depth peeling (moderate difficulty, most of the process can be implemented in hardware but requires multiple passes on common hw)-true order-independent transparency (intermediate-difficult, requires D3D11-level hw and a lot of GPU time)Of course, redesigning your renderer to not rely on correctly-sorted transparency would make the above techniques unnecessary.EDIT: I misread your problem. You could render the opaque characters into a separate render target, and when finished, composite it with the rest of the scene by rendering the whole image as a texture on top of the background; adjusting the alpha of this compositing operation to make the top "layer" partially transparent.I don't have enough experience with TrueVision to assert whether it supports this kind of techniques.   ;Quote:Original post by Nik02You could render the opaque characters into a separate render target, and when finished, composite it with the rest of the scene by rendering the whole image as a texture on top of the background; adjusting the alpha of this compositing operation to make the top "layer" partially transparent.I don't have enough experience with TrueVision to assert whether it supports this kind of techniques.Totally doable in Truevision3D! Good idea too I might add! :)-Toaster;  A problem with the suggested approach is that you must consider depth to be able to composite the separate render target correctly.A simpler way is to sort the characters back-to-front, and then draw the characters in two passes: first draw Z-only (no color), and then draw the alpha blended character. Depending on the look you want, you can do this in one of two ways:1. This way will give you separate characters, blended against each other (so they can be seen through each other):for character 1: draw z, draw colorfor character 2: draw z, draw color...for character N: draw z, draw color2. This way will give you a "layered" look, where they are blended, but can't be seen though each other:for character 1-N, draw zfor character 1-N, draw colorThe Z-buffer test will make sure only the pixels closest to the camera are drawn for each character. Drawing them separately back-to-front will make sure they composite correctly against each other (given that the objects don't intersect each other).I don't know if this is possible to do using the engine you suggested, but this approach will look right and it will save you the trouble of using a separate render target and then composite. ;  Thanks for the answers. I managed to render the transparent meshes as suggested but yes, the depth buffer is a problem yeah. Currently i'm rendering the landscape, then the surface with the transparent meshes and then the other meshes. It works good but there is two problems.First, the meshes is always rendered infront of the surface.. Maybe this can be solved somehow..2nd, It's slow to render using surfaces. I guess its because its rendered to the memory before rendered to the scene and it's slower then rendering it directly to the scene. I will look into the simonjacoby's suggestion. Thanks for the tips and keep em coming! :)EDIT:I looked into simonjacoby's suggestion and it worked wonders. Its looking awsome and it's fast. I'm totaly satisfied thanks to you![Edited by - tedlin01 on June 2, 2010 6:57:48 AM]