Make fog work.

This commit is contained in:
Masataka SUMI
2021-09-21 17:16:56 +09:00
parent 62947f47f8
commit 5bfb052997
3 changed files with 9 additions and 8 deletions

View File

@@ -25,8 +25,8 @@ struct Varyings
half4 tangentWS : TEXCOORD3;
#endif
float3 viewDirWS : TEXCOORD4;
UNITY_FOG_COORDS(6)
UNITY_LIGHTING_COORDS(7,8)
UNITY_FOG_COORDS(5)
UNITY_LIGHTING_COORDS(6,7)
float4 pos : SV_POSITION; // UnityCG macro specified name. Accurately "positionCS"
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
@@ -38,4 +38,4 @@ struct FragmentInput
MTOON_FRONT_FACE_TYPE facing : MTOON_FRONT_FACE_SEMANTIC;
};
#endif
#endif

View File

@@ -43,11 +43,12 @@ half4 MToonFragment(const FragmentInput fragmentInput) : SV_Target
mtoonInput.viewDirWS = normalize(input.viewDirWS);
mtoonInput.litColor = litColor.rgb;
mtoonInput.alpha = alpha;
const half4 col = GetMToonLighting(unityLighting, mtoonInput);
half4 col = GetMToonLighting(unityLighting, mtoonInput);
UNITY_APPLY_FOG(i.fogCoord, col);
// Apply Fog
UNITY_APPLY_FOG(fragmentInput.varyings.fogCoord, col);
return col;
}
#endif
#endif

View File

@@ -41,10 +41,10 @@ Varyings MToonVertex(const Attributes v) // v is UnityCG macro specified name.
output.tangentWS = half4(UnityObjectToWorldDir(v.tangentOS), tangentSign);
#endif
UNITY_TRANSFER_FOG(output, output.positionWS);
UNITY_TRANSFER_FOG(output, output.pos);
UNITY_TRANSFER_LIGHTING(output, v.texcoord1.xy);
return output;
}
#endif
#endif