Hello !
I am currently using a shader allowing me to place my texture relative to the world. I simply put the textures used for the floor (normals pointing up) and for the walls (normals pointing elsewhere).
struct Input
{
float3 worldNormal;
float3 worldPos;
};
void surf (Input IN, inout SurfaceOutput o)
{
float2 UV;
fixed4 c;
if(abs(IN.worldNormal.x)>0.5)
{
UV = IN.worldPos.zy; // side
c = tex2D(_MainTexWall, UV* _Scale); // use WALLSIDE texture
}
else if(abs(IN.worldNormal.z)>0.5)
{
UV = IN.worldPos.xy; // front
c = tex2D(_MainTexWall, UV* _Scale); // use WALL texture
}
else
{
UV = IN.worldPos.xz; // top
c = tex2D(_MainTexFlr, UV* _FlrScale); // use FLR texture
}
o.Albedo = c.rgb;
}
I want to add normalmapping to this shader. Some of you might already know what my question is going to be since the problem is written in the doc :
I can’t read worldNormal as soon as I add
o.Normal = something
and
struct Input
{
float3 worldNormal;
float3 worldPos;
INTERNAL_DATA
};
But using WorldNormalVector(IN, o.Normal) doesn’t seem to do much if i haven’t changed the value of o.Normal before…
I feel like in order to read my worldNormal, I need to write it myself, which doesn’t seem possible since I can’t read it…
So, does anybody have any idea so I can add normalmapping to my textures ?
Thanks a lot for your help !