erebus

changeset 23:56d504cc555a

- debugging scale factor for render size - fixed un-normalized normals after transforms in the SceneNode
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 29 May 2014 07:47:52 +0300
parents 11cdaa510201
children 4336acf8389d
files liberebus/src/object.cc liberebus/src/rt.cc liberebus/src/scene.cc src/main.cc test/scene
diffstat 5 files changed, 27 insertions(+), 8 deletions(-) [+]
line diff
     1.1 --- a/liberebus/src/object.cc	Thu May 29 03:35:04 2014 +0300
     1.2 +++ b/liberebus/src/object.cc	Thu May 29 07:47:52 2014 +0300
     1.3 @@ -16,7 +16,7 @@
     1.4  	Vector3 norm = ((const GeomObject*)obj)->calc_normal(*this);
     1.5  
     1.6  	const Matrix4x4 &xform = node->get_inv_matrix();
     1.7 -	return norm.transformed(Matrix3x3(xform).transposed());
     1.8 +	return norm.transformed(Matrix3x3(xform).transposed()).normalized();
     1.9  }
    1.10  
    1.11  Vector3 RayHit::calc_tangent() const
     2.1 --- a/liberebus/src/rt.cc	Thu May 29 03:35:04 2014 +0300
     2.2 +++ b/liberebus/src/rt.cc	Thu May 29 07:47:52 2014 +0300
     2.3 @@ -28,8 +28,14 @@
     2.4  	const Material *mtl = &obj->mtl;
     2.5  	const Reflectance *brdf = obj->brdf;
     2.6  	const Ray &ray = hit.world_ray;
     2.7 +	bool entering = true;
     2.8  
     2.9  	Vector3 norm = hit.calc_normal();
    2.10 +	if(dot_product(ray.dir, norm) > 0.0) {
    2.11 +		entering = false;
    2.12 +		norm = -norm;
    2.13 +	}
    2.14 +
    2.15  	//return norm * 0.5 + Vector3(0.5, 0.5, 0.5);
    2.16  	Vector2 texcoords = hit.calc_texcoords();
    2.17  
     3.1 --- a/liberebus/src/scene.cc	Thu May 29 03:35:04 2014 +0300
     3.2 +++ b/liberebus/src/scene.cc	Thu May 29 07:47:52 2014 +0300
     3.3 @@ -125,6 +125,16 @@
     3.4  static char *strip_wspace(char *str)
     3.5  {
     3.6  	while(*str && isspace(*str)) str++;
     3.7 +
     3.8 +	char *comment = strchr(str, '#');
     3.9 +	if(comment) *comment = 0;
    3.10 +
    3.11 +	if(str) {
    3.12 +		char *end = str + strlen(str) - 1;
    3.13 +		while(end > str && isspace(*end)) end--;
    3.14 +		end[1] = 0;
    3.15 +	}
    3.16 +
    3.17  	return str;
    3.18  }
    3.19  
     4.1 --- a/src/main.cc	Thu May 29 03:35:04 2014 +0300
     4.2 +++ b/src/main.cc	Thu May 29 07:47:52 2014 +0300
     4.3 @@ -5,6 +5,8 @@
     4.4  #include "opengl.h"
     4.5  #include "erebus.h"
     4.6  
     4.7 +#define SCALE 2
     4.8 +
     4.9  static bool init();
    4.10  static void cleanup();
    4.11  static void resize_rtarget(int xsz, int ysz);
    4.12 @@ -59,8 +61,8 @@
    4.13  
    4.14  static bool init()
    4.15  {
    4.16 -	width = glutGet(GLUT_WINDOW_WIDTH) / 2;
    4.17 -	height = glutGet(GLUT_WINDOW_HEIGHT) / 2;
    4.18 +	width = glutGet(GLUT_WINDOW_WIDTH) / SCALE;
    4.19 +	height = glutGet(GLUT_WINDOW_HEIGHT) / SCALE;
    4.20  
    4.21  	if(!(erb = erb_init())) {
    4.22  		return false;
    4.23 @@ -95,8 +97,8 @@
    4.24  {
    4.25  	static unsigned char *defpix;
    4.26  
    4.27 -	width = xsz / 2;
    4.28 -	height = ysz / 2;
    4.29 +	width = xsz / SCALE;
    4.30 +	height = ysz / SCALE;
    4.31  
    4.32  	if(width <= rtex_width && height <= rtex_height) {
    4.33  		return;
     5.1 --- a/test/scene	Thu May 29 03:35:04 2014 +0300
     5.2 +++ b/test/scene	Thu May 29 07:47:52 2014 +0300
     5.3 @@ -1,9 +1,10 @@
     5.4  # test scene
     5.5  
     5.6 -sphere -position 0 0 0 -scaling 1 1 1 -diffuse 1 0.5 0.4
     5.7 +sphere -position 0 0 0 -scaling 1 1 1 -diffuse 1 0.6 0.5
     5.8  
     5.9 -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
    5.10 +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
    5.11 +box -position 0 3.75 0 -scaling 20 10 20 -diffuse 1.0 1.0 1.0 -brdf lambert
    5.12  
    5.13 -box -position 0 5 0 -scaling 3 0.1 3 -emissive 5 5 5
    5.14 +box -position 0 4 0 -scaling 3 0.1 3 -emissive 6 6 6
    5.15  
    5.16  camera -position 0 3 -6 -target 0 0 0