- Home /
Object with Transparent Vertex Lit Z - Lightmap
Hello,
I'm trying to get a building slightly transparent. At first I tried using the built in transparent shader within Unity, but this was giving weird effects to the Z depth, meaning I could see the other side of the building, through the building model. I then tried using this Alpha Vertex Lit Z:
http://wiki.unity3d.com/index.php?title=AlphaVertexLitZ
Which is suppose to give the effect I want, but as soon as I apply it to my building, the entire model goes transparent (no matter what my alpha value is at):
Normal diffuse on both building and cubes:

AlphaVertexLitZ on both cubes and building with 25% alpha:

What am I doing wrong here? Is it because I have a lightmap on my building? Or, maybe some kind of import settings I need to play with?
Thanks
Yeah it appears to be my lightmap thats causing it - thats pretty annoying :/ Any workarounds?
Answer by oliver-jones · Oct 04, 2013 at 12:52 PM
I found a work around. If you want to use a lightmap on an object that uses transparent, then use this:
Shader "Transparent/Diffuse ZWrite" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 200
// extra pass that renders to depth buffer only
Pass {
ZWrite On
ColorMask 0
}
// paste in forward rendering passes from Transparent/Diffuse
UsePass "Transparent/Diffuse/FORWARD"
}
Fallback "Transparent/VertexLit"
}
Your answer
Follow this Question
Related Questions
Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers
Transparent/Diffuse shader which uses UV2 0 Answers
Transparent texture contains other color 1 Answer
Creating lights with no fading/alpha, but solid color/hard edges 1 Answer
Fade an object out 0 Answers