Hi,
Im trying to optimise a my shader as far as possible,
I have a single texture that i want to split into 2 essentially, here’s what im trying to do:
1 texture -
rgd = uv1
a = uv2
I have an asset that has a diffuse texture layout in uv1 and an AO Bake hidden in the alpha channel that requires uv2.
Currently I am having to pull in the texture with a
sampler2D - attach that to a fixed4 and apply the uv1 to it
but then to achieve the second uv2 I need to repeat the above? im also having to use two separate texture slots for the same texture?
is there a more efficient way of doing this?
my current shader below:
Shader "Custom/OptimalDiffuse_uv2-AOBake" {
Properties
{
_MainTex ("Main Texture (RGB)", 2D) = "white" {}
_AOBake ("Main Texture (A) - AO Bake", 2D) = "white" {}
}
SubShader {
Tags {"Queue"="Geometry" "IgnoreProjector"="True" "RenderType"="opaque"}
LOD 250
CGPROGRAM
#pragma surface surf Lambert noforwardadd
sampler2D _MainTex;
sampler2D _AOBake;
struct Input
{
fixed2 uv_MainTex;
fixed2 uv2_AOBake;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
fixed4 c2 = tex2D (_AOBake, IN.uv2_AOBake);
o.Albedo = (c.rgb * c2.a);
}
ENDCG
}
Fallback "Mobile/Diffuse"
}
Any Advice would really be welcome, Thanks.