Any ETA on transparency support?

Dec 29, 2010 at 10:45 PM

I'd love to use Balder for a Silverlight project I'm doing, but I'd need transparency support to pull it off.

I recall another user mentioned something about a custom renderer? Can anyone post any info? 

I don't need to do anything fancy, just some solid colors on cylinders with transparency.


Dec 30, 2010 at 1:17 AM
Edited Dec 30, 2010 at 1:23 AM

Here is what I did to get on/off trasparency. (NOT full alpha support)
also I think this will only work if you are using a texture with an alpha channel, such as a PNG 32

Step 1) Get the Balder source and open it in Visual Studio
    (make sure you can compile it alright)

Step 2) Find the class Balder.Materials.Material and make the accessor on the property Renderer public
     public Triangle Renderer {get;set;}

Step 3) Identify what triangle renderer you are using, this can be found by following the procedure SetRenderer
   (this depends on what options you've choosen for your material such as shading or various maps and such, I have only ever done TextureTriangle as that's all I needed)

Step 4) Copy the class found in the folder: Rendering/Silverlight/Drawing/....some triangle renderer to your project and ensure you have all proper dependencies (add refference to Bader as well)

Step 5) look inside the triangle renderer code and find the DrawSpan method.

Step 6) Replace the following: NOTE this may be different if you choose a renderer other than TextureTriangle... 
Framebuffer[offset] = Color.Blend(Texture1.Pixels[intu, intv],MaterialDiffuseAsInt,Texture1Factor) | Color.AlphaFull;
DepthBuffer[offset] = bufferZ;

with this:
var Pixel = Texture1.Pixels[intu, intv];
if (((Pixel >> 24) & 0xff) > 128)
 Framebuffer[offset] = Pixel;
 DepthBuffer[offset] = bufferZ;

Step 7) For the material you are using you need to set the renderer to the proper value.  This is the last thing I do after I create a new instance of a material and setup all the properties. (probably needs to be one of the last things or the renderer will get reset)

Step 8) Make sure you use that material for your meshes.

That's a lot of steps and is pretty specific to what I needed to do so you may have to adjust based on your needs.  The hardest part will probably be findind the right renderer to copy and change.

Hope this helps!