Kaynağa Gözat

Renderer optimizations

Panagiotis Christopoulos Charitos 14 yıl önce
ebeveyn
işleme
4f45881e68

+ 1 - 1
build/debug/gen.cfg.py

@@ -11,4 +11,4 @@ compiler = "g++"
 
 compilerFlags = "-DPLATFORM_LINUX -DMATH_INTEL_SIMD -DREVISION=\\\"`svnversion -c ../..`\\\" -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -pipe -g3 -fsingle-precision-constant -msse4"
 
-linkerFlags = "-rdynamic -pg -L../../extern/lib-x86-64-linux -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lGLU -Wl,-Bdynamic -lGL -ljpeg -lSDL -lpng -lpython2.6 -lboost_system -lboost_python -lboost_filesystem -lboost_thread"
+linkerFlags = "-rdynamic -L../../extern/lib-x86-64-linux -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lGLU -Wl,-Bdynamic -lGL -ljpeg -lSDL -lpng -lpython2.6 -lboost_system -lboost_python -lboost_filesystem -lboost_thread"

+ 16 - 26
shaders/IsLpGeneric.glsl

@@ -4,24 +4,7 @@
 
 #pragma anki vertShaderBegins
 
-layout(location = 0) in vec2 position; ///< the vert coords are {1.0,1.0}, {0.0,1.0}, {0.0,0.0}, {1.0,0.0}
-layout(location = 1) in vec3 viewVector;
-
-out vec2 vTexCoords;
-out vec3 vPosition;
-
-
-//======================================================================================================================
-// main                                                                                                                =
-//======================================================================================================================
-void main()
-{
-	vPosition = viewVector;
-	vTexCoords = position;
-	vec2 _vertPosNdc_ = position * 2.0 - 1.0;
-	gl_Position = vec4(_vertPosNdc_, 0.0, 1.0);
-}
-
+#pragma anki include "shaders/SimpleVert.glsl"
 
 #pragma anki fragShaderBegins
 
@@ -29,8 +12,12 @@ void main()
 
 /// @name Uniforms
 /// @{
+uniform vec2 planes; ///< for the calculation of frag pos in view space
+uniform vec2 limitsOfNearPlane; ///< for the calculation of frag pos in view space
+uniform vec2 limitsOfNearPlane2; ///< This is an optimization see PpsSsao.glsl and r403 for the clean one
+uniform float zNear; ///< for the calculation of frag pos in view space
+
 uniform sampler2D msNormalFai, msDiffuseFai, msSpecularFai, msDepthFai;
-uniform vec2 planes; ///< for the calculation of frag pos in view space	
 uniform vec3 lightPos; ///< Light pos in eye space
 uniform float lightRadius;
 uniform vec3 lightDiffuseCol;
@@ -48,7 +35,6 @@ uniform vec3 lightSpecularCol;
 /// @name Varyings
 /// @{
 in vec2 vTexCoords;
-in vec3 vPosition; ///< for the calculation of frag pos in view space
 /// @}
 
 /// @name Output
@@ -63,17 +49,21 @@ out vec3 fColor;
 /// @return frag pos in view space
 vec3 getFragPosVSpace()
 {
-	float _depth_ = texture2D(msDepthFai, vTexCoords).r;
+	float depth = texture2D(msDepthFai, vTexCoords).r;
 
-	if(_depth_ == 1.0)
+	/*if(depth == 1.0)
 	{
 		discard;
-	}
+	}*/
 
 	vec3 fragPosVspace;
-	vec3 vposn = normalize(vPosition);
-	fragPosVspace.z = -planes.y / (planes.x + _depth_);
-	fragPosVspace.xy = vposn.xy * (fragPosVspace.z / vposn.z);
+	fragPosVspace.z = -planes.y / (planes.x + depth);
+
+	fragPosVspace.xy = (vTexCoords * limitsOfNearPlane2) - limitsOfNearPlane;
+
+	float sc = -fragPosVspace.z / zNear;
+	fragPosVspace.xy *= sc;
+
 	return fragPosVspace;
 }
 

+ 2 - 2
src/Core/App.cpp

@@ -35,7 +35,7 @@ void App::handleMessageHanlderMsgs(const char* file, int line, const char* func,
 //======================================================================================================================
 void App::parseCommandLineArgs(int argc, char* argv[])
 {
-	for(int i=1; i<argc; i++)
+	for(int i = 1; i < argc; i++)
 	{
 		char* arg = argv[i];
 		if(strcmp(arg, "--terminal-coloring") == 0)
@@ -202,7 +202,7 @@ void App::initDirs()
 void App::initRenderer()
 {
 	RendererInitializer initializer;
-	initializer.ms.ez.enabled = false;
+	initializer.ms.ez.enabled = true;
 	initializer.dbg.enabled = true;
 	initializer.is.sm.bilinearEnabled = true;
 	initializer.is.sm.enabled = true;

+ 1 - 1
src/Core/App.h

@@ -66,7 +66,7 @@ class App
 		GETTER_R(boost::filesystem::path, cachePath, getCachePath)
 		/// @}
 
-	private:
+	public: /// @todo
 		uint windowW; ///< The main window width
 		uint windowH; ///< The main window height
 		boost::filesystem::path settingsPath; ///< The path that holds the configuration

+ 8 - 0
src/Core/AsyncLoader.cpp

@@ -1,5 +1,7 @@
+#include <SDL/SDL.h>
 #include "AsyncLoader.h"
 #include "Logger.h"
+#include "App.h"
 
 
 //======================================================================================================================
@@ -32,6 +34,12 @@ void AsyncLoader::load(const char* filename, LoadCallback loadCallback, void* st
 //======================================================================================================================
 void AsyncLoader::workingFunc()
 {
+	/*SDL_GLContext glContext;
+	glContext = SDL_GL_CreateContext(AppSingleton::getInstance().windowId);
+
+	ERROR(SDL_GetError() << " " << glContext);*/
+
+
 	while(1)
 	{
 		Request req;

+ 2 - 2
src/Math/Mat4.inl.h

@@ -191,12 +191,12 @@ inline const float& Mat4::operator[](const uint i) const
 }
 
 #if defined(MATH_INTEL_SIMD)
-	const __m128& Mat4::getMm(uint i) const
+	inline const __m128& Mat4::getMm(uint i) const
 	{
 		return arrMm[i];
 	}
 	
-	__m128& Mat4::getMm(uint i)
+	inline __m128& Mat4::getMm(uint i)
 	{
 		return arrMm[i];
 	}

+ 9 - 14
src/Renderer/Ez.cpp

@@ -27,7 +27,8 @@ void Ez::init(const RendererInitializer& initializer)
 
 		fbo.setNumOfColorAttachements(0);
 
-		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, r.getMs().getDepthFai().getGlId(), 0);
+		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D,
+		                       r.getMs().getDepthFai().getGlId(), 0);
 
 		fbo.checkIfGood();
 
@@ -50,6 +51,8 @@ void Ez::run()
 		return;
 	}
 
+	const Camera& cam = r.getCamera();
+
 	fbo.bind();
 
 	Renderer::setViewport(0, 0, r.getWidth(), r.getHeight());
@@ -58,20 +61,12 @@ void Ez::run()
 	GlStateMachineSingleton::getInstance().setDepthTestEnabled(true);
 	GlStateMachineSingleton::getInstance().setBlendingEnabled(false);
 
-	/// @todo Uncomment
-	/*for(Vec<MeshNode*>::iterator it=app->getScene().meshNodes.begin(); it!=app->getScene().meshNodes.end(); it++)
-	{
-		MeshNode* meshNode = (*it);
-		if(meshNode->mesh->material->renderInBlendingStage())
-		{
-			continue;
-		}
-
-		//RASSERT_THROW_EXCEPTION(meshNode->mesh->material->getDepthMtl() == NULL);
+	glClear(GL_DEPTH_BUFFER_BIT);
 
-		r.setupMaterial(meshNode->mesh->material->getDepthMtl(), *meshNode, r.getCamera());
-		meshNode->renderDepth();
-	}*/
+	BOOST_FOREACH(const RenderableNode* node, cam.getVisibleMsRenderableNodes())
+	{
+		r.getSceneDrawer().renderRenderableNode(*node, cam, SceneDrawer::RPT_DEPTH);
+	}
 
 	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
 }

+ 15 - 99
src/Renderer/Is.cpp

@@ -26,67 +26,6 @@ Is::Is(Renderer& r_):
 {}
 
 
-//======================================================================================================================
-// calcViewVectors                                                                                                     =
-//======================================================================================================================
-void Is::calcViewVectors(const boost::array<float, 2>& screenSize, const Mat4& invProjectionMat,
-                         boost::array<Vec3, 4>& viewVectors)
-{
-	uint w = screenSize[0];
-	uint h = screenSize[1];
-
-	// From right up and CC wise to right down, Just like we render the quad
-	uint pixels[4][2] = {{w, h}, {0, h}, {0, 0}, {w, 0}};
-	boost::array<uint, 4> viewport = {{0, 0, w, h}};
-
-	for(int i = 0; i < 4; i++)
-	{
-		/*
-		Original Code:
-		Renderer::unProject(pixels[i][0], pixels[i][1], 10, cam.getViewMatrix(), cam.getProjectionMatrix(), viewport,
-		                    viewVectors[i].x, viewVectors[i].y, viewVectors[i].z);
-		viewVectors[i] = cam.getViewMatrix() * viewVectors[i];
-		The original code is the above 3 lines. The optimized follows:
-		*/
-
-		Vec3 vec;
-		vec.x() = (2.0 * (pixels[i][0] - viewport[0])) / viewport[2] - 1.0;
-		vec.y() = (2.0 * (pixels[i][1] - viewport[1])) / viewport[3] - 1.0;
-		vec.z() = 1.0;
-
-		viewVectors[i] = vec.getTransformed(invProjectionMat);
-		// end of optimized code
-	}
-}
-
-
-//======================================================================================================================
-// calcViewVectors                                                                                                     =
-//======================================================================================================================
-void Is::calcViewVectors()
-{
-	boost::array<Vec3, 4> viewVectors;
-	boost::array<float, 2> screenSize = {{r.getWidth(), r.getHeight()}};
-
-	calcViewVectors(screenSize, r.getCamera().getInvProjectionMatrix(), viewVectors);
-
-	viewVectorsVbo.write(&viewVectors[0]);
-}
-
-
-//======================================================================================================================
-// calcPlanes                                                                                                          =
-//======================================================================================================================
-void Is::calcPlanes(const Vec2& cameraRange, Vec2& planes)
-{
-	float zNear = cameraRange.x();
-	float zFar = cameraRange.y();
-
-	planes.x() = zFar / (zNear - zFar);
-	planes.y() = (zFar * zNear) / (zNear -zFar);
-}
-
-
 //======================================================================================================================
 // initFbo                                                                                                             =
 //======================================================================================================================
@@ -163,32 +102,6 @@ void Is::init(const RendererInitializer& initializer)
 
 	// init the rest
 	initFbo();
-
-	// The VBOs and VAOs
-	float quadVertCoords[][2] = {{1.0, 1.0}, {0.0, 1.0}, {0.0, 0.0}, {1.0, 0.0}};
-	quadPositionsVbo.create(GL_ARRAY_BUFFER, sizeof(quadVertCoords), quadVertCoords, GL_STATIC_DRAW);
-
-	ushort quadVertIndeces[2][3] = {{0, 1, 3}, {1, 2, 3}};
-	quadVertIndecesVbo.create(GL_ELEMENT_ARRAY_BUFFER, sizeof(quadVertIndeces), quadVertIndeces, GL_STATIC_DRAW);
-
-	viewVectorsVbo.create(GL_ARRAY_BUFFER, 4 * sizeof(Vec3), NULL, GL_DYNAMIC_DRAW);
-
-	vao.create();
-	vao.attachArrayBufferVbo(quadPositionsVbo, 0, 2, GL_FLOAT, false, 0, NULL);
-	vao.attachArrayBufferVbo(viewVectorsVbo, 1, 3, GL_FLOAT, false, 0, NULL);
-	vao.attachElementArrayBufferVbo(quadVertIndecesVbo);
-}
-
-
-//======================================================================================================================
-// drawLightPassQuad                                                                                                   =
-//======================================================================================================================
-void Is::drawLightPassQuad() const
-{
-	vao.bind();
-	glDrawElements(GL_TRIANGLES, 2 * 3, GL_UNSIGNED_SHORT, 0);
-	vao.unbind();
-	ON_GL_FAIL_THROW_EXCEPTION();
 }
 
 
@@ -229,7 +142,11 @@ void Is::pointLightPass(const PointLight& light)
 	shader.findUniVar("msDiffuseFai")->set(r.getMs().getDiffuseFai(), 1);
 	shader.findUniVar("msSpecularFai")->set(r.getMs().getSpecularFai(), 2);
 	shader.findUniVar("msDepthFai")->set(r.getMs().getDepthFai(), 3);
-	shader.findUniVar("planes")->set(&planes);
+	shader.findUniVar("planes")->set(&r.getPlanes());
+	shader.findUniVar("limitsOfNearPlane")->set(&r.getLimitsOfNearPlane());
+	shader.findUniVar("limitsOfNearPlane2")->set(&r.getLimitsOfNearPlane2());
+	float zNear = cam.getZNear();
+	shader.findUniVar("zNear")->set(&zNear);
 	Vec3 lightPosEyeSpace = light.getWorldTransform().getOrigin().getTransformed(cam.getViewMatrix());
 	shader.findUniVar("lightPos")->set(&lightPosEyeSpace);
 	shader.findUniVar("lightRadius")->set(&light.getRadius());
@@ -237,7 +154,7 @@ void Is::pointLightPass(const PointLight& light)
 	shader.findUniVar("lightSpecularCol")->set(&light.getSpecularCol());
 
 	// render quad
-	drawLightPassQuad();
+	r.drawQuad();
 }
 
 
@@ -257,11 +174,7 @@ void Is::spotLightPass(const SpotLight& light)
 
 		const Plane& plane = cam.getWSpaceFrustumPlane(Camera::FP_NEAR);
 
-		//float dist = (light.getWorldTransform().getOrigin() - cam.getWorldTransform().getOrigin()).getLength();
 		float dist = seg.testPlane(plane);
-		//float dist = plane.test(light.getWorldTransform().getOrigin());
-
-		//INFO(dist);
 
 		sm.run(light.getCamera(), dist);
 
@@ -301,8 +214,12 @@ void Is::spotLightPass(const SpotLight& light)
 	shdr->findUniVar("msSpecularFai")->set(r.getMs().getSpecularFai(), 2);
 	shdr->findUniVar("msDepthFai")->set(r.getMs().getDepthFai(), 3);
 
-	// the planes
-	shdr->findUniVar("planes")->set(&planes);
+	// the ???
+	shdr->findUniVar("planes")->set(&r.getPlanes());
+	shdr->findUniVar("limitsOfNearPlane")->set(&r.getLimitsOfNearPlane());
+	shdr->findUniVar("limitsOfNearPlane2")->set(&r.getLimitsOfNearPlane2());
+	float zNear = cam.getZNear();
+	shdr->findUniVar("zNear")->set(&zNear);
 
 	// the light params
 	Vec3 lightPosEyeSpace = light.getWorldTransform().getOrigin().getTransformed(cam.getViewMatrix());
@@ -330,7 +247,7 @@ void Is::spotLightPass(const SpotLight& light)
 	}
 
 	// render quad
-	drawLightPassQuad();
+	r.drawQuad();
 }
 
 
@@ -339,6 +256,8 @@ void Is::spotLightPass(const SpotLight& light)
 //======================================================================================================================
 void Is::run()
 {
+	const Camera& cam = r.getCamera();
+
 	// FBO
 	fbo.bind();
 
@@ -355,9 +274,6 @@ void Is::run()
 	glBlendFunc(GL_ONE, GL_ONE);
 	glEnable(GL_STENCIL_TEST);
 
-	calcViewVectors();
-	calcPlanes(Vec2(r.getCamera().getZNear(), r.getCamera().getZFar()), planes);
-
 	// for all lights
 	BOOST_FOREACH(const PointLight* light, r.getCamera().getVisiblePointLights())
 	{

+ 0 - 35
src/Renderer/Is.h

@@ -30,24 +30,6 @@ class Is: private RenderingPass
 		const Texture& getFai() const {return fai;}
 		/// @}
 
-		/// Calculate the view vectors needed for the calculation of the frag pos in view space in shaders
-		/// @param[in] screenSize The width and height of the screen
-		/// @param[in] invProjectionMat The inverted camera projection matrix
-		/// @param[out] viewVectors The output
-		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 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);
-
 	private:
 		Sm sm; ///< Shadowmapping pass
 		Smo smo; /// Stencil masking optimizations pass
@@ -59,23 +41,6 @@ class Is: private RenderingPass
 		RsrcPtr<ShaderProg> spotLightNoShadowSProg; ///< Illumination stage spot light w/o shadow shader program
 		RsrcPtr<ShaderProg> spotLightShadowSProg; ///< Illumination stage spot light w/ shadow shader program
 
-		/// @name For the quad drawing in light passes
-		/// @{
-		Vbo quadPositionsVbo; ///< The VBO for quad positions
-		Vbo viewVectorsVbo; ///< The VBO to pass the @ref viewVectors.
-		Vbo quadVertIndecesVbo; ///< The VBO for quad array buffer elements
-		Vao vao; ///< This VAO is used in light passes only
-		/// @}
-
-		Vec2 planes; ///< Used to to calculate the frag pos in view space inside the shader program
-
-		/// Draws the vao that has attached the viewVectorsVbo as well. Used in light passes
-		void drawLightPassQuad() const;
-
-		/// Calc the view vector that we will use inside the shader to calculate the frag pos in view space. This
-		/// calculates the view vectors and updates the @ref viewVectorsVbo
-		void calcViewVectors();
-
 		/// The ambient pass
 		void ambientPass(const Vec3& color);
 

+ 2 - 2
src/Renderer/MainRenderer.cpp

@@ -100,9 +100,9 @@ void MainRenderer::render(Camera& cam_)
 	GlStateMachineSingleton::getInstance().setDepthTestEnabled(false);
 	GlStateMachineSingleton::getInstance().setBlendingEnabled(false);
 	sProg->bind();
-	sProg->findUniVar("rasterImage")->set(ms.getNormalFai(), 0);
+	//sProg->findUniVar("rasterImage")->set(ms.getNormalFai(), 0);
 	//sProg->findUniVar("rasterImage")->set(pps.getSsao().getFai(), 0);
-	//sProg->findUniVar("rasterImage")->set(pps.getPostPassFai(), 0);
+	sProg->findUniVar("rasterImage")->set(pps.getPostPassFai(), 0);
 	drawQuad();
 }
 

+ 1 - 1
src/Renderer/Ms.cpp

@@ -91,7 +91,7 @@ void Ms::run()
 		glDepthFunc(GL_EQUAL);
 	}
 
-	glClear(GL_COLOR_BUFFER_BIT);
+	//glClear(GL_COLOR_BUFFER_BIT);
 
 	// render all
 	BOOST_FOREACH(const RenderableNode* node, r.getCamera().getVisibleMsRenderableNodes())

+ 32 - 0
src/Renderer/Renderer.cpp

@@ -2,6 +2,7 @@
 #include "Camera.h"
 #include "RendererInitializer.h"
 #include "Exception.h"
+#include "PerspectiveCamera.h"
 
 
 //======================================================================================================================
@@ -65,6 +66,16 @@ void Renderer::render(Camera& cam_)
 {
 	cam = &cam_;
 
+	//
+	// Calc a few vars
+	//
+	calcPlanes(Vec2(cam->getZNear(), cam->getZFar()), planes);
+
+	ASSERT(cam->getType() == Camera::CT_PERSPECTIVE);
+	const PerspectiveCamera& pcam = static_cast<const PerspectiveCamera&>(*cam);
+	calcLimitsOfNearPlane(pcam, limitsOfNearPlane);
+	limitsOfNearPlane2 = limitsOfNearPlane * 2.0;
+
 	viewProjectionMat = cam->getProjectionMatrix() * cam->getViewMatrix();
 
 	ms.run();
@@ -132,3 +143,24 @@ void Renderer::createFai(uint width, uint height, int internalFormat, int format
 }
 
 
+//======================================================================================================================
+// calcPlanes                                                                                                          =
+//======================================================================================================================
+void Renderer::calcPlanes(const Vec2& cameraRange, Vec2& planes)
+{
+	float zNear = cameraRange.x();
+	float zFar = cameraRange.y();
+
+	planes.x() = zFar / (zNear - zFar);
+	planes.y() = (zFar * zNear) / (zNear -zFar);
+}
+
+
+//======================================================================================================================
+// calcLimitsOfNearPlane                                                                                               =
+//======================================================================================================================
+void Renderer::calcLimitsOfNearPlane(const PerspectiveCamera& pcam, Vec2& limitsOfNearPlane)
+{
+	limitsOfNearPlane.y() = pcam.getZNear() * tan(0.5 * pcam.getFovY());
+	limitsOfNearPlane.x() = limitsOfNearPlane.y() * (pcam.getFovX() / pcam.getFovY());
+}

+ 25 - 0
src/Renderer/Renderer.h

@@ -56,6 +56,9 @@ class Renderer
 		const Camera& getCamera() const {return *cam;}
 		GETTER_RW(SceneDrawer, sceneDrawer, getSceneDrawer)
 		GETTER_RW(SkinsDeformer, skinsDeformer, getSkinsDeformer)
+		GETTER_R(Vec2, planes, getPlanes)
+		GETTER_R(Vec2, limitsOfNearPlane, getLimitsOfNearPlane)
+		GETTER_R(Vec2, limitsOfNearPlane2, getLimitsOfNearPlane2)
 		/// @}
 
 		/// Init the renderer given an initialization class
@@ -84,6 +87,20 @@ class Renderer
 		/// Create FAI texture
 		static void createFai(uint width, uint height, int internalFormat, int format, int type, Texture& fai);
 
+		/// 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);
+
+		/// Calculates two values needed for the calculation of the fragment position in view space.
+		static void calcLimitsOfNearPlane(const PerspectiveCamera& cam, Vec2& limitsOfNearPlane);
+
 	//==================================================================================================================
 	// Protected                                                                                                       =
 	//==================================================================================================================
@@ -104,6 +121,14 @@ class Renderer
 		SceneDrawer sceneDrawer;
 		SkinsDeformer skinsDeformer;
 
+		/// @name Optimization vars
+		/// Used in other stages
+		/// @{
+		Vec2 planes; ///< Used to to calculate the frag pos in view space inside a few shader programs
+		Vec2 limitsOfNearPlane; ///< Used to to calculate the frag pos in view space inside a few shader programs
+		Vec2 limitsOfNearPlane2; ///< Used to to calculate the frag pos in view space inside a few shader programs
+		/// @}
+
 	//==================================================================================================================
 	// Protected                                                                                                       =
 	//==================================================================================================================

+ 3 - 11
src/Renderer/Ssao.cpp

@@ -110,21 +110,13 @@ void Ssao::run()
 	ssaoSProg->bind();
 	
 	// planes
-	Vec2 planes;
-	Is::calcPlanes(Vec2(r.getCamera().getZNear(), r.getCamera().getZFar()), planes);
-	ssaoSProg->findUniVar("planes")->set(&planes);
+	ssaoSProg->findUniVar("planes")->set(&r.getPlanes());
 
 	// limitsOfNearPlane
-	Vec2 limitsOfNearPlane;
-	ASSERT(cam.getType() == Camera::CT_PERSPECTIVE);
-	const PerspectiveCamera& pcam = static_cast<const PerspectiveCamera&>(cam);
-	limitsOfNearPlane.y() = cam.getZNear() * tan(0.5 * pcam.getFovY());
-	limitsOfNearPlane.x() = limitsOfNearPlane.y() * (pcam.getFovX() / pcam.getFovY());
-	ssaoSProg->findUniVar("limitsOfNearPlane")->set(&limitsOfNearPlane);
+	ssaoSProg->findUniVar("limitsOfNearPlane")->set(&r.getLimitsOfNearPlane());
 
 	// limitsOfNearPlane2
-	limitsOfNearPlane *= 2;
-	ssaoSProg->findUniVar("limitsOfNearPlane2")->set(&limitsOfNearPlane);
+	ssaoSProg->findUniVar("limitsOfNearPlane2")->set(&r.getLimitsOfNearPlane2());
 
 	// zNear
 	float zNear = cam.getZNear();