I use the shader “VertexLit with z” from wiki, but i’m having troubles, when 2 models with the shader, when 1 is in alpha, it “cut” the other model.
This only occur in this angle of vision.
I use the shader “VertexLit with z” from wiki, but i’m having troubles, when 2 models with the shader, when 1 is in alpha, it “cut” the other model.
This only occur in this angle of vision.
Sorting of transparent surfaces is a very difficult problem to solve in general, but you can usually fix it by using opaque shaders for as many polygons as possible. Why do you need the bones rendered with alpha blending?
Hi Daniel.
I need it because the alpha is controled by the user and is progressive.
The user can set transparency to different bones and ligaments.
Is there a way to correct it?
Hmm…I just started having this problem with a custom shadow i made that has transparency shader. Any solutions?
Unfortunatly, we didn`t came up with a solution yet…
Does anybody have any idea?
Regards.
From what i understand, Unity3D will sort alpha blended objects according to pivots’ depth and render them back to front (though it will not sort polygons inside a mesh). Normally, if your objects’ pivots are ordered like the whole of the corresponding geometry, you shouldn’t have z-sorting issues. If object A has a pivot behind object B’s pivot but has some geometry in front of object B’s pivot then you have a problem. You may need do to divide objects into smaller parts to avoid these situations whatever the angle of the camera.
You can also use a 2 pass shader to render opaque geometry with alpha test and transclucent geometry with alpha blend. You’ll still have the problem but it will be less visible since it will happen only with translucent objects.
I tried the two passes, but it didn`t work.
My meshes are grouped according to types, so their pivots are in the same position.
Is there a way to correct this without changing all the objects and their pivots?
Thanks
If the model is always seen from that perspective, a cheap hack is to try engineering the mesh so that the bits you want transparent are created last, then re-export it to Unity. That should force those triangles to be rendered last (as they’ll be at the end of the vertex list). Unfortunately, if the mesh is seen from the other side, you’ll get the same issue occurring.
Alternatively, try and set up a script to change the pivot point of a mesh at run-time so their origins are at the centre of mass of the object?
Hi Farfarer, thanks for the reply.
The user is able to move the objects, so i cant use the first option... the meshes pivots are on the center of them all, so they can be equaly rotated. I have no idea about what to do…
One approach in this sort of situation is to break your mesh down into smaller parts. Ideally, the breakdown is such that from any angle, there is a definite ordering from farthest to nearest to the camera. That is, for any two meshes A and B, either all of A’s surfaces can be rendered in front of B’s, or all of B’s surfaces can be rendered in front of A’s. If you can do this, then Unity’s built-in back-to-front sorting of meshes will work fine. Note that mesh origins have to be at the centre of their vertices rather than at a common location.
Rotations can still be easily accomplished by adding common parents and rotating them instead of trying to manually align all the children.
We separated all abjects with their pivots center to each object and broke one of the cilinder objects into two pieces. It worked for the front objects, those who are not crossing with the other alpha objects, but thos who are crossing are not working… the images below show white stripes, the 1 is working and the 2 is not:
Do the bones have a shader that doesn’t use transparency at all?
If so, having two separate shaders would help.
Use the tag “Queue” = “Geometry” with the bones’ shader and “Queue” = “Transparent” with the tendons’ (or are they ligaments?).
That way, the alpha sorting issue should only affect the tendons.
Could you post up the code for shader you’re using? I can have a look at it tomorrow.
Nope:
The bones who have tranpsrency are right Iliacus and the vertebras. The other bones doesnt have shaders. The transparency are being applied to those bones, ligaments and joints. The shader im using is the “VertexLit with Z” from community (http://www.unifycommunity.com/wiki/index.php?title=AlphaVertexLitZ):
Shader “Transparent/VertexLit with Z” {
Properties {
_Color (“Main Color”, Color) = (1,1,1,1)
_MainTex (“Base (RGB) Trans (A)”, 2D) = “white” {}
}
SubShader {
Tags {“RenderType”=“Transparent” “Queue”=“Transparent”}
// Render into depth buffer only
Pass {
ColorMask 0
}
// Render normally
Pass {
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
ColorMask RGB
Material {
Diffuse [_Color]
Ambient [_Color]
}
Lighting On
SetTexture [_MainTex] {
Combine texture * primary DOUBLE, texture * primary
}
}
}
}
Best Regards
Thanks everybody for the replies.
We applied levels for the alpha through “Tags {“RenderType”=“Transparent” “Queue”=“Transparent-1”}”.
And it works nicely for us.
Best Regards.