Fog of war
Hello, and first of all sorry if the question seems too easy or was already answered.
I'm a new user of shader forge and I'd like to translate a fog of war shader to shader forge. The shader is this one:
Shader "FogOfWar/FogShader" {
Properties {
_OldFogTex ("Old Fog Texture", 2D) = "gray" {}
_FogTex ("Fog Texture", 2D) = "gray" {}
_Color ("Color", Color) = (0,0,0,0)
}
Subshader {
Tags {"Queue"="Transparent"}
Pass {
ZWrite Off
Blend DstColor Zero
Offset -1, -1
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "UnityCG.cginc"
struct v2f {
float4 uvShadow : TEXCOORD0;
UNITY_FOG_COORDS(2)
float4 pos : SV_POSITION;
};
float4x4 unity_Projector;
float4x4 unity_ProjectorClip;
v2f vert (float4 vertex : POSITION)
{
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, vertex);
o.uvShadow = mul (unity_Projector, vertex);
UNITY_TRANSFER_FOG(o,o.pos);
return o;
}
sampler2D _OldFogTex;
sampler2D _FogTex;
fixed4 _Color;
uniform float _Blend;
fixed4 frag (v2f i) : SV_Target
{
fixed a1 = tex2Dproj (_OldFogTex, UNITY_PROJ_COORD(i.uvShadow)).a;
fixed a2 = tex2Dproj (_FogTex, UNITY_PROJ_COORD(i.uvShadow)).a;
fixed a = lerp(a1, a2, _Blend);
fixed4 col = lerp(_Color, fixed4(1,1,1,1), a);
UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(1,1,1,1));
return col;
}
ENDCG
}
}
}
I'm having a hard time trying to figure out how can I change the tex2Dproj function for some Shader forge node and the Apply fog color as well. Is it the right approach to try to find a translation directly? Is there any other way I could do it?
Thanks in advance.
Answer
SF doesn't have built-in support for Tex2Dproj, but you can likely do it manually, though I'm not entirely sure how this fog of war shader is supposed to work. It's more of a question for the forums though, this place is for requesting features and reporting bugs
Customer support service by UserEcho
SF doesn't have built-in support for Tex2Dproj, but you can likely do it manually, though I'm not entirely sure how this fog of war shader is supposed to work. It's more of a question for the forums though, this place is for requesting features and reporting bugs