- Home /
Fading an object shader question
Hi, I'm trying to make an object fade to fully transparent but I'm running into an issue.
I'm using some code to search through all the components in the hierarchy of an object, then access their materials. If the material the shader is associated with isn't transparent diffuse, I change it to this shader and then add all the materials to a list within Start(). Come run time, I loop through the the material list and lerp their alpha's to 0.
Now this 'works', except (not surprisingly) when I change the shader from diffuse to transparent diffuse, I get some wierd visual artifacts. Beyond this, it all works great. So aside from editting the source assets (I'm assuming this is the only way to sort this), would there be anyway to prevent the artifacts when I switch shaders? The switch in shaders cause the object to be semi transparent in areas (though their alpha value is 1.0f which confuses me slightly). I thought setting the materials alpha to 1 would resolve this issue, but unfortunately not.
Thanks for any help!
It seems a bug if you are completely sure about what you say. submit it with your project. help>report a bug
I think the actual problem is that once I switch to transparent diffuse, you have semi transparent objects in front of other semi transparent objects, so you get an odd brightening effect. Don't know how to get around this.
Apparently I need to change the blend mode of the shader to normal....but I can't see how to do this!
i don't know if it's possible to modify the shaders of unity or not but i think their source is available in unity's resources section of the website at http://www.unity3d.com/support/resources and you can modify and use them. There is a package in asset store called hard surface shaders which allows to choose the rendering order of transparent and semi transparent objects but i think it's $50. It can generate really good looking effects for metalic, plastic, vax, glass and many other types of materials, if you have the money and it can be helpful. buy and use it.
You need to research why the problems occur. Alpha is not opacity. It's a blending multiplier. It is not a bug. http://www.unifycommunity.com/wiki/index.php?title=AlphaVertexLitZ
Your answer
Follow this Question
Related Questions
Altering Material through Script Causes Transparent Rendering Error - C# 1 Answer
WebGl Transparent Background Issue 0 Answers
Why my 2d character would not be displayed correctly at the very beginning? 0 Answers
Multiple intersecting meshes with per-pixel-alpha-sorting transparancy shader 0 Answers