Скрытый текст:
Что в шейдер добавить то?
Синтаксис:
Используется glsl
Shader "Pixesed/Portal"
{
Properties
{
[HideInInspector] _MainTex ("Texture", 2D) = "white" {}
//_MainTex ("Texture", 2D) = "white" {}
_Offset("Offset", float) = 0
_ZTest("ZTest", int) = 4
}
SubShader
{
Tags {"RenderType" = "Opaque"}
LOD 100
Offset [_Offset], [_Offset] // 0 or -0.03 max
ZWrite On
ZTest [_ZTest]
Pass {
CGPROGRAM
#include "UnityCG.cginc"
#pragma vertex vert
#pragma fragment frag
//#pragma multi_compile_fwdbase_fullshadows
#pragma multi_compile_fog
#pragma target 3.0
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float4 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
UNITY_FOG_COORDS(1)
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert(appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = ComputeScreenPos(o.vertex);
UNITY_TRANSFER_FOG(o, o.vertex);
return o;
}
fixed4 frag(v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv.xy/i.uv.w);
//fixed4 col = tex2Dproj(_MainTex, UNITY_PROJ_COORD(i.refl));
UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}
ENDCG
}
}
Fallback Off
}
{
Properties
{
[HideInInspector] _MainTex ("Texture", 2D) = "white" {}
//_MainTex ("Texture", 2D) = "white" {}
_Offset("Offset", float) = 0
_ZTest("ZTest", int) = 4
}
SubShader
{
Tags {"RenderType" = "Opaque"}
LOD 100
Offset [_Offset], [_Offset] // 0 or -0.03 max
ZWrite On
ZTest [_ZTest]
Pass {
CGPROGRAM
#include "UnityCG.cginc"
#pragma vertex vert
#pragma fragment frag
//#pragma multi_compile_fwdbase_fullshadows
#pragma multi_compile_fog
#pragma target 3.0
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float4 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
UNITY_FOG_COORDS(1)
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert(appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = ComputeScreenPos(o.vertex);
UNITY_TRANSFER_FOG(o, o.vertex);
return o;
}
fixed4 frag(v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv.xy/i.uv.w);
//fixed4 col = tex2Dproj(_MainTex, UNITY_PROJ_COORD(i.refl));
UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}
ENDCG
}
}
Fallback Off
}