Panagiotis Christopoulos Charitos 14 лет назад
Родитель
Сommit
6e151277bf
1 измененных файлов с 7 добавлено и 1 удалено
  1. 7 1
      src/Renderer/Is.h

+ 7 - 1
src/Renderer/Is.h

@@ -37,7 +37,13 @@ class Is: private RenderingPass
 		static void calcViewVectors(const boost::array<float, 2>& screenSize, const Mat4& invProjectionMat,
 		                            boost::array<Vec3, 4>& viewVectors);
 
-		/// Calculate the planes needed for the calculation of the frag pos in view space in shaders
+		/// Calculate the planes needed for the calculation of the fragment position z in view space.
+		/// Having the fragment's depth, the camera's zNear and zFar the z of the fragment is being calculated inside
+		/// the fragment shader from:
+		/// @code z = (- zFar * zNear) / (zFar - depth * (zFar - zNear)) @endcode
+		/// The above can be optimized and this method actually precalculates a few things in order to lift a few 
+		/// calculations from the fragment shader. So the z is:
+		/// @code z =  -planes.y / (planes.x + depth) @endcode
 		/// @param[in] cameraRange The zNear, zFar
 		/// @param[out] planes The planes
 		static void calcPlanes(const Vec2& cameraRange, Vec2& planes);