void main_triplanar_reference_vp(
	float4 position: POSITION, 
	float3 normal: NORMAL,
	
	uniform float3 eyePosition,
	uniform float4x4 worldviewproj,
	
	#if FOGLINEAR || FOGEXPONENTIAL || FOGEXPONENTIAL2
	uniform float4 fogParams,
	#endif
	
	out float3 oPos: TEXCOORD0,
	out float4 oNormAndFogVal: TEXCOORD1,
	out float3 oEyePos: TEXCOORD2,
	out float4 oClipPos: POSITION
){
	oClipPos = mul(worldviewproj, position);
	
	oPos = position.xyz;
	oNormAndFogVal.xyz = normal;
	oEyePos = eyePosition;
		
	// Fog like in the terrain component, but exp2 added
	#if FOGLINEAR
	oNormAndFogVal.w = saturate((oClipPos.z - fogParams.y) * fogParams.w);
	#endif
	#if FOGEXPONENTIAL
    // Fog density increases  exponentially from the camera (fog = 1/e^(distance * density))
	oNormAndFogVal.w = 1 - saturate(1 / (exp(oClipPos.z * fogParams.x)));
	#endif
	#if FOGEXPONENTIAL2
    // Fog density increases at the square of FOG_EXP, i.e. even quicker (fog = 1/e^(distance * density)^2)
	float distanceTimesDensity = exp(oClipPos.z * fogParams.x);
	oNormAndFogVal.w = 1 - saturate(1 / (distanceTimesDensity * distanceTimesDensity));
	#endif
}
