jmgek
July 18, 2016, 4:56pm
1
As the title says I am using a texture on a quad that is z-Fighting ‘stitching’ so I have to have it hover above the faces normal.
I tried with .forward but that wont work.
firstObj.transform.position = secondObj.transform.position + (-Vector3.forward * 0.1f)
I know it has something to do with the normal but I cant remember.
Thanks, any help will be appreciated!
Cherno
July 18, 2016, 6:29pm
2
You can use this shader which makes the object render slightly towards the camera so you don’t have to manually adjust the transform.position.
Shader "Custom/BlendedDecal"
{
Properties
{
_Color ("Tint", Color) = (1,1,1,1)
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Lighting Off
ZTest LEqual
ZWrite Off
Tags {"Queue" = "Transparent"}
Pass
{
Alphatest Greater 0
Blend SrcAlpha OneMinusSrcAlpha
Offset -1, -1
SetTexture [_MainTex]
{
ConstantColor[_Color]
Combine texture * constant
}
}
}
}