HELP!!!! Transparency Material

I’m working on a 3D visualization application using unity Engine. A 3D geometry with animation (fbx) is loaded into the app which consist of sliders to play back the animation. But the challenge i’m having is that while the user scrubs through the slider to view the animation, i have other sliders that is intended to control the transparency of individual parts of the 3d geometry.

My approach was to create different material for each part (Transparent-diffuse Material) of the geometry and tie the alpha of the material to the slider min and max. this appears to work but the geometry keeps showing an annoying transparency when its supposed to be fully opaque.

Kindly help!!! with script, suggestions, material , any walk-around to this problem , all i want to achieve i sjust to control the transparency of a geometry from full opaque to full transparent using a slider

Are you getting the issue where even at full opacity, inside edges are rendering? If so, its an inherent weakness with the way Unity’s shaders handles transparent (or in this case, potentially transparent) materials.

The first work around that comes to mind is to use a transparent shader that depth writes. I remember seeing this one on the wiki a while back but it’s pretty old and I have no idea if it stills works correctly with current versions of Unity.

The other work around is you could change the materials shader when your slider is set to full opacity. So at 99% opacity you’ll see the ugly see through effect, but then it’ll click over to looking normal again. (you often see this effect in games, when an object begins fading out) It’ll definitely work, although it might look a touch ugly.

Thanks Sycle, i’ll try the material swapping solution and get back to you…thanks a bunch …

Now i must confess i dont have a hang on the below , does this mean that i have to write my shaders (Diffuse and Transparent/diffuse) …

// Toggle between Diffuse and Transparent/Diffuse shaders
// when space key is pressed

var shader1 : Shader = Shader.Find( “Diffuse” );
var shader2 : Shader = Shader.Find( “Transparent/Diffuse” );

function Update() {
if( Input.GetButtonDown(“Jump”) ) {
if( renderer.material.shader == shader1 )
renderer.material.shader = shader2;
else
renderer.material.shader = shader1;
}
}

can you help with a simple code

Solved my problem!!
Thanks Sycle for your heads up

here is the code i used eventually

var a : float;

//declare shaders to hold both diffuse and tranparent diffuse
//variables assigned outside of a function are assigned using the parameterless constructor.
//you cannot use Find in the parameterless constructor.

var shader1 : Shader;
var shader2 : Shader;

//force the geometry to pick up the shader Diffuse
function Start ()
{
shader1 = Shader.Find( “Diffuse” );
shader2 = Shader.Find( “Transparent/Diffuse” );
renderer.material.shader =shader1;
}

function OnGUI ()
{
//Check condition for switching between shaders using the alphacontrol as passed from the main script-menucontrolscript

if( menucontrolscript.alphacontrol1<0.9)
{
// if alphacontrol (alpha level is less than 0.5, switch render material to shader 2 -tranparent/diffuse
renderer.material.shader = shader2;
//update the materia color
renderer.material.color.a = menucontrolscript.alphacontrol1 ;
}

//else render the shader1
else
renderer.material.shader = shader1;
}