- Home /
How to make a gameObject's color fade to transparency (picture)
Hello, I have been working on a cave model, finished it, and textured it. I found out you can't make caves in the Unity Terrain System, so I found a way around it, similar to Skyrim's. I want the blackness to fade in so it looks more natural. Right now, it just looks bleh. Here is a picture:
So currently the black is part of the terrain with a black texture?
No, it is an individual block with a black material on it.
Is the cave itself behind this block or is it just meant as a region, which switches the scene when player goes into it?
If it is the latter then I understand you want a gradient(transparent-black) between the rock and black texture?
When you enter the trigger, it teleports you to a new transform that is inside the cave.
(The trigger is the black piece)
Answer by SterlingStudios · Jul 25, 2014 at 01:42 PM
Alright I figured it out. I edited the Alpha of the color on the Transparent Diffuse shader, which made it semi-transparent, then I took 0tucan approach and lined them up. I think it looks pretty nice now here it is:
Thanks for all your help, Unity3D truly has a great community.
Answer by 0tacun · Jul 24, 2014 at 04:55 PM
enable fog in the render settings: http://docs.unity3d.com/Manual/class-RenderSettings.html
and adjust the fogdensity/linearFogStart/linearFogEnd values as you need them.
Another approuch would be to expand this block and texture it blackier the deeper it is.
First, I have the fog enabled. And I don't think that would solve my problem.
Visually it won't make a difference(for the now obvious transition), but I guess Otacun means that the fog would become stronger as you head deeper into the cave and once it is dark enough you switch to the cave scene.
Answer by Pendrokar · Jul 24, 2014 at 05:18 PM
Assuming that the objects around the black block are GameObjects/Meshes then you could use a decal that would do the gradient transition. Otherwise make a few meshes that have the gradient texture and fit them on these meshes, though this might cause Z-fighting issues(objects randomly popping on top one another).
http://docs.unity3d.com/Manual/shader-NormalDecal.html
OR
Assuming that the objects around the black block is part of Terrain, you can use a black Terrain Texture and paint it with a soft brush on the parts that interact between the block and the terrain.
Sadly, the rocks around it are meshes. Is it possible to edit the transparency of a shader without using a texture?
Your answer
Follow this Question
Related Questions
Fade In _TintColor Over Time 2 Answers
Transparent Shader changing color after Ambient Light 0 Answers
Shader Edges Transparent Relative to Camera 0 Answers
Material doesn't have property '_Color' 4 Answers
Change Fog Color Smoothly 1 Answer