# HG changeset patch # User John Tsiombikas # Date 1401338872 -10800 # Node ID 56d504cc555ace02160d90a7f4ecde6046caa20f # Parent 11cdaa510201a86b2b89d18b251d9ff34db1bd76 - debugging scale factor for render size - fixed un-normalized normals after transforms in the SceneNode diff -r 11cdaa510201 -r 56d504cc555a liberebus/src/object.cc --- a/liberebus/src/object.cc Thu May 29 03:35:04 2014 +0300 +++ b/liberebus/src/object.cc Thu May 29 07:47:52 2014 +0300 @@ -16,7 +16,7 @@ Vector3 norm = ((const GeomObject*)obj)->calc_normal(*this); const Matrix4x4 &xform = node->get_inv_matrix(); - return norm.transformed(Matrix3x3(xform).transposed()); + return norm.transformed(Matrix3x3(xform).transposed()).normalized(); } Vector3 RayHit::calc_tangent() const diff -r 11cdaa510201 -r 56d504cc555a liberebus/src/rt.cc --- a/liberebus/src/rt.cc Thu May 29 03:35:04 2014 +0300 +++ b/liberebus/src/rt.cc Thu May 29 07:47:52 2014 +0300 @@ -28,8 +28,14 @@ const Material *mtl = &obj->mtl; const Reflectance *brdf = obj->brdf; const Ray &ray = hit.world_ray; + bool entering = true; Vector3 norm = hit.calc_normal(); + if(dot_product(ray.dir, norm) > 0.0) { + entering = false; + norm = -norm; + } + //return norm * 0.5 + Vector3(0.5, 0.5, 0.5); Vector2 texcoords = hit.calc_texcoords(); diff -r 11cdaa510201 -r 56d504cc555a liberebus/src/scene.cc --- a/liberebus/src/scene.cc Thu May 29 03:35:04 2014 +0300 +++ b/liberebus/src/scene.cc Thu May 29 07:47:52 2014 +0300 @@ -125,6 +125,16 @@ static char *strip_wspace(char *str) { while(*str && isspace(*str)) str++; + + char *comment = strchr(str, '#'); + if(comment) *comment = 0; + + if(str) { + char *end = str + strlen(str) - 1; + while(end > str && isspace(*end)) end--; + end[1] = 0; + } + return str; } diff -r 11cdaa510201 -r 56d504cc555a src/main.cc --- a/src/main.cc Thu May 29 03:35:04 2014 +0300 +++ b/src/main.cc Thu May 29 07:47:52 2014 +0300 @@ -5,6 +5,8 @@ #include "opengl.h" #include "erebus.h" +#define SCALE 2 + static bool init(); static void cleanup(); static void resize_rtarget(int xsz, int ysz); @@ -59,8 +61,8 @@ static bool init() { - width = glutGet(GLUT_WINDOW_WIDTH) / 2; - height = glutGet(GLUT_WINDOW_HEIGHT) / 2; + width = glutGet(GLUT_WINDOW_WIDTH) / SCALE; + height = glutGet(GLUT_WINDOW_HEIGHT) / SCALE; if(!(erb = erb_init())) { return false; @@ -95,8 +97,8 @@ { static unsigned char *defpix; - width = xsz / 2; - height = ysz / 2; + width = xsz / SCALE; + height = ysz / SCALE; if(width <= rtex_width && height <= rtex_height) { return; diff -r 11cdaa510201 -r 56d504cc555a test/scene --- a/test/scene Thu May 29 03:35:04 2014 +0300 +++ b/test/scene Thu May 29 07:47:52 2014 +0300 @@ -1,9 +1,10 @@ # test scene -sphere -position 0 0 0 -scaling 1 1 1 -diffuse 1 0.5 0.4 +sphere -position 0 0 0 -scaling 1 1 1 -diffuse 1 0.6 0.5 -box -position 0 -1.25 0 -scaling 4 0.5 4 -diffuse 0.3 0.4 1.0 -brdf composite -brdf lambert -brdf-weight 0.5 -brdf mirror -brdf-weight 0.5 +box -position 0 -1.25 0 -scaling 4 0.5 4 -diffuse 0.3 0.4 1.0 -brdf composite -brdf lambert -brdf-weight 0.3 -brdf mirror -brdf-weight 0.7 +box -position 0 3.75 0 -scaling 20 10 20 -diffuse 1.0 1.0 1.0 -brdf lambert -box -position 0 5 0 -scaling 3 0.1 3 -emissive 5 5 5 +box -position 0 4 0 -scaling 3 0.1 3 -emissive 6 6 6 camera -position 0 3 -6 -target 0 0 0