# VS to PS - which values are interpolated?

This topic is 3738 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi everybody. Right now I'm implementing fog in HLSL for my small terrain engine. Everything works fine, but I'd like to know what gets interpolated from the VS to the PS. The reason behind this is the following: To save fillrate I calculate the distance from the camera to the vertex inside the VS and just use this value in the PS to calculate the lerp factor for my fog. Like this:
VS()
{
output.WorldPos = mul(input.Position, matWorld);
output.Distance = distance(output.WorldPos, cameraPos);
}

PS()
{
color = calculateFog(color, input.Distance);
}


While this works fine for my terrain, my water plane (just two triangles stretched across the whole terrain), is almost entirely drawn in my fog color, so I have to do this:
VS()
{
output.WorldPos = mul(input.Position, matWorld);
}

PS()
{
color = calculateFog(color, distance(input.WorldPos, CameraPos));
}


So, which one is better? And why is WorldPos interpolated to the PS, while Distance is not? regards