Эх сурвалжийг харах

Bug fixes in rasterizer and light class.

angel 7 жил өмнө
parent
commit
03e0491d2d

+ 2 - 4
include/light.h

@@ -24,9 +24,9 @@ struct BaseLight{
             case 'o':
                 float orbX   = std::sin(ang) * radius; 
                 float orbZ   = std::cos(ang) * radius;
-                position.x   = orbX;
+                position.x   = orbZ;
                 position.y   = orbX;
-                position.z   = orbZ;
+                position.z   = orbX;
             break;
 
             case 'f':
@@ -38,8 +38,6 @@ struct BaseLight{
                 color.x       = colX;
                 color.y       = 1.0f-colY;
                 color.z       = colY;
-                printf("%f\n",ang);
-                color.print();
             break;
 
             case 'l':

+ 5 - 5
scenes/firehydrant/firehydrant_config.txt

@@ -9,20 +9,20 @@ rot 0.0 0.0 0.0
 sca 1.0 1.0 1.0 
 /
 //SECTION: lights
-l 3
-l01 sun fixed
+l 2
+l01 f
 pos 1.0 0.0 0.0
 col 1.0 1.0 1.0
 /
-l02 sun fixed
+l02 f
 pos 1.0 0.0 1.0
 col 1.0 0.0 1.0
 /
-l03 sun fixed
+l03 f
 pos 1.0 0.0 1.0
 col 0.0 0.0 1.0
 /
-l04 sun fixed
+l04 f
 pos 1.0 1.0 1.0
 col 1.0 0.0 1.0
 /

+ 4 - 4
scenes/teapot/teapot_config.txt

@@ -15,19 +15,19 @@ sca 0.4 0.4 0.4
 /
 //SECTION: lights
 l 4
-l01 sun fixed
+l01 f
 pos 1.0 0.0 0.0
 col 1.0 1.0 1.0
 /
-l02 sun fixed
+l02 f
 pos 1.0 0.0 2.0
 col 0.0 1.0 0.0
 /
-l03 sun fixed
+l03 f
 pos 0.0 0.0 -1.0
 col 0.5 0.0 0.0
 /
-l04 sun fixed
+l04 f
 pos 1.0 1.0 1.0
 col 0.0 0.0 1.0
 /

+ 1 - 1
src/rasterizer.cpp

@@ -246,6 +246,6 @@ float Rasterizer::clamp(float n, float lower, float upper) {
 //Gamma adjustment table precalculated for a 2.2 gamma value
 //signficant ms gains from this!!
 int Rasterizer::gammaAdjust(float n) {
-    int val = (int)clamp(n*255, 0, 255);
+    int val = (int)(clamp(n*255, 0, 255)+0.5f);
     return gammaTable[val];
 }