Просмотр исходного кода

Fixed spotlights in new renderer

Ivan Safrin 10 лет назад
Родитель
Сommit
baf02aedd2

BIN
assets/default/default.pak


+ 4 - 4
assets/default/default/DefaultShader.frag

@@ -101,11 +101,11 @@ void spotLight(in int i, in vec3 normal, in vec4 pos, inout vec4 diffuse, inout
 
 void doLights(in int numLights, in vec3 normal, in vec4 pos, inout vec4 diffuse, inout vec4 specular) {
 	for (int i = 0; i < numLights; i++) {
-//		if (lights[i].spotCosCutoff == 180.0) {
+		if (lights[i].spotCosCutoff == 180.0) {
 			pointLight(i, normal, pos, diffuse, specular);
-//		} else {
-//			spotLight(i, normal, pos, diffuse, specular);
-//		}
+		} else {
+			spotLight(i, normal, pos, diffuse, specular);
+		}
     }
 }
 

+ 0 - 1
include/polycode/core/PolyTexture.h

@@ -76,7 +76,6 @@ namespace Polycode {
 
             void *platformData;
             void *depthBufferPlatformData;
-            void *colorBufferPlatformData;
         private:
         
             unsigned int width;

+ 6 - 1
src/core/PolyRenderer.cpp

@@ -95,7 +95,11 @@ void RenderThread::processDrawBuffer(GPUDrawBuffer *buffer) {
             lights[i].position->setVector3(buffer->lights[i].position);
             lights[i].direction->setVector3(buffer->lights[i].direction);
             lights[i].spotExponent->setNumber(buffer->lights[i].spotlightExponent);
-            lights[i].spotCosCutoff->setNumber(buffer->lights[i].spotlightCutoff);
+            if(buffer->lights[i].type == 0) {
+                lights[i].spotCosCutoff->setNumber(180.0);
+            } else {
+                lights[i].spotCosCutoff->setNumber(cos((buffer->lights[i].spotlightCutoff) * TORADIANS));
+            }
             
             lights[i].constantAttenuation->setNumber(buffer->lights[i].constantAttenuation);
             lights[i].linearAttenuation->setNumber(buffer->lights[i].linearAttenuation);
@@ -104,6 +108,7 @@ void RenderThread::processDrawBuffer(GPUDrawBuffer *buffer) {
         } else {
             lights[i].diffuse->setColor(Color(0.0, 0.0, 0.0, 1.0));
             lights[i].specular->setColor(Color(0.0, 0.0, 0.0, 1.0));
+            lights[i].spotCosCutoff->setNumber(180.0);
         }
     }