Преглед на файлове

Fixed spotlights in new renderer

Ivan Safrin преди 10 години
родител
ревизия
baf02aedd2
променени са 4 файла, в които са добавени 10 реда и са изтрити 6 реда
  1. BIN
      assets/default/default.pak
  2. 4 4
      assets/default/default/DefaultShader.frag
  3. 0 1
      include/polycode/core/PolyTexture.h
  4. 6 1
      src/core/PolyRenderer.cpp

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) {
 void doLights(in int numLights, in vec3 normal, in vec4 pos, inout vec4 diffuse, inout vec4 specular) {
 	for (int i = 0; i < numLights; i++) {
 	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);
 			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 *platformData;
             void *depthBufferPlatformData;
             void *depthBufferPlatformData;
-            void *colorBufferPlatformData;
         private:
         private:
         
         
             unsigned int width;
             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].position->setVector3(buffer->lights[i].position);
             lights[i].direction->setVector3(buffer->lights[i].direction);
             lights[i].direction->setVector3(buffer->lights[i].direction);
             lights[i].spotExponent->setNumber(buffer->lights[i].spotlightExponent);
             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].constantAttenuation->setNumber(buffer->lights[i].constantAttenuation);
             lights[i].linearAttenuation->setNumber(buffer->lights[i].linearAttenuation);
             lights[i].linearAttenuation->setNumber(buffer->lights[i].linearAttenuation);
@@ -104,6 +108,7 @@ void RenderThread::processDrawBuffer(GPUDrawBuffer *buffer) {
         } else {
         } else {
             lights[i].diffuse->setColor(Color(0.0, 0.0, 0.0, 1.0));
             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].specular->setColor(Color(0.0, 0.0, 0.0, 1.0));
+            lights[i].spotCosCutoff->setNumber(180.0);
         }
         }
     }
     }