Hi, so i have 2 shaders created. A stencil shader and a shader created in shadergraph which has a texture, mask and 2 colour inputs. The texture is coloured with the first colour, and the mask the second color. My problem is coming from when I am trying to basically combine these shaders. I generate the code for the shader created via the shadergraph but that doesnt show me the fragment shader information, and therefore how the output is calculates. I need to know this so i can figure it out for my stencil shader code. I have also tried putting in the stencil code into the generated code but that doesnt seem to work, and there is so much generated code, its a bit of a pain to navigate around.
This is the code im using to work with the stencil shaders. By chance does anyone know how to get the information of the texture with a colour overlaid, along with the mask and cover overlaid mixed and passed out. Thanks for any help (Also, does anyone know a way that i can see the fragment shader code, from the generated shaderlab shaders)
Shader "Unlit/WallTest"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Mask ("Mask", 2D) = "white" {}
_MainColor("MainColor", Color) = (0.8679245, 0.7858012, 0.4380563, 1)
_SecondaryColor("SecondaryColor", Color) = (0.6226415, 0.1850303, 0.1850303, 0)
}
SubShader
{
Tags { "Queue" = "Geometry" }
Stencil
{
Ref 2
Comp NotEqual // if 2 is not equal to the comparison value, then keep value
Pass Keep
}
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// make fog work
#pragma multi_compile_fog
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
UNITY_FOG_COORDS(1)
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
sampler2D _Mask;
float4 _MainTex_ST;
float4 _MainColor; // Color for the main texture
float4 _SecondaryColor; // Color for the mask
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 mainTexColor = tex2D(_MainTex, i.uv) * _MainColor;
fixed4 maskTexColor = tex2D(_Mask, i.uv) * _SecondaryColor;
return mainTexColor;
}
ENDCG
}
}
}