Panagiotis Christopoulos Charitos 13 年之前
父节点
当前提交
e937b45c42
共有 3 个文件被更改,包括 42 次插入7 次删除
  1. 3 1
      include/anki/gl/ShaderProgram.h
  2. 1 1
      src/gl/ShaderProgram.cpp
  3. 38 5
      src/renderer/Is.cpp

+ 3 - 1
include/anki/gl/ShaderProgram.h

@@ -8,6 +8,7 @@
 #include "anki/gl/Ogl.h"
 #include "anki/util/Vector.h"
 #include "anki/util/StdTypes.h"
+#include "anki/util/NonCopyable.h"
 #include <string>
 #include <memory>
 
@@ -74,7 +75,7 @@ public:
 
 	ShaderProgramVariable& operator=(const ShaderProgramVariable& b)
 	{
-		ANKI_ASSERT(type == b.type)
+		ANKI_ASSERT(type == b.type);
 		loc = b.loc;
 		name = b.name;
 		glDataType = b.glDataType;
@@ -184,6 +185,7 @@ class ShaderProgramAttributeVariable: public ShaderProgramVariable
 {
 	friend class ShaderProgram;
 
+public:
 	ShaderProgramAttributeVariable()
 		: ShaderProgramVariable(SPVT_ATTRIBUTE)
 	{}

+ 1 - 1
src/gl/ShaderProgram.cpp

@@ -520,7 +520,7 @@ void ShaderProgram::initUniformBlocks()
 		/* Offset in block */
 		GLint offset;
 		glGetActiveUniformsiv(glId, 1, &(uni.index),  GL_UNIFORM_OFFSET, 
-			&blockIndex);
+			&offset);
 		ANKI_ASSERT(offset != -1); // If -1 then it should break before
 		uni.offset = offset;
 	}

+ 38 - 5
src/renderer/Is.cpp

@@ -582,6 +582,10 @@ void Is::lightPass()
 	// Quickly get the lights
 	//
 
+	U spotsNoShadowCount = 0, spotsShadowCount = 0;
+	Array<SpotLight*, MAX_SPOT_LIGHTS> visibleSpotNoShadowLights, 
+		visibleSpotShadowLights;
+
 	for(auto it = vi.getLightsBegin(); it != vi.getLightsEnd(); ++it)
 	{
 		Light* light = (*it)->getLight();
@@ -594,22 +598,51 @@ void Is::lightPass()
 			++visiblePointLightsCount;
 			break;
 		case Light::LT_SPOT:
-			// Use % to avoid overflows
-			visibleSpotLights[visibleSpotLightsCount % MAX_SPOT_LIGHTS] = 
-				static_cast<SpotLight*>(light);
-			++visibleSpotLightsCount;
-			break;
+			{
+				SpotLight* slight = static_cast<SpotLight*>(light);
+				
+				if(slight->getShadowEnabled())
+				{
+					visibleSpotShadowLights[
+						spotsShadowCount % MAX_SPOT_LIGHTS] = slight;
+					++spotsShadowCount;
+				}
+				else
+				{
+					visibleSpotNoShadowLights[
+						spotsNoShadowCount % MAX_SPOT_LIGHTS] = slight;
+					++spotsNoShadowCount;
+				}
+				break;
+			}
 		case Light::LT_NUM:
 			break;
 		}
 	}
 
+	visibleSpotLightsCount = spotsNoShadowCount + spotsShadowCount;
+
 	if(visiblePointLightsCount > MAX_POINT_LIGHTS 
 		|| visibleSpotLightsCount > MAX_SPOT_LIGHTS)
 	{
 		throw ANKI_EXCEPTION("Too many visible lights");
 	}
 
+	U i;
+	for(i = 0; i < spotsNoShadowCount; i++)
+	{
+		visibleSpotLights[i] = visibleSpotNoShadowLights[i];
+	}
+
+	for(; i < visibleSpotLightsCount; i++)
+	{
+		visibleSpotLights[i] = visibleSpotShadowLights[i];
+	}
+
+	//
+	// Do shadows pass
+	//
+
 	//
 	// Write the lights UBO
 	//